UNPKG

2.83 kBTypeScriptView Raw
1// Type definitions for node-config
2// Project: https://github.com/lorenwest/node-config
3// Definitions by: Roman Korneev <https://github.com/RWander>
4// Forrest Bice <https://github.com/forrestbice>
5// James Donald <https://github.com/jndonald3>
6// Alberto Vasquez <https://github.com/albertovasquez>
7// Christian Vaagland Tellnes <https://github.com/tellnes>
8// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
9
10
11
12declare var c: c.IConfig;
13
14declare namespace c {
15
16 // see https://github.com/lorenwest/node-config/wiki/Using-Config-Utilities
17 interface IUtil {
18 // Extend an object (and any object it contains) with one or more objects (and objects contained in them).
19 extendDeep(mergeInto: any, mergeFrom: any, depth?: number): any;
20 extendDeep(mergeInto: any, mergeFrom1: any, mergeFrom2: any, depth?: number): any;
21 extendDeep(mergeInto: any, ...mergeFrom: any): any;
22
23 // Return a deep copy of the specified object.
24 cloneDeep(copyFrom: any, depth?: number): any;
25
26 // Return true if two objects have equal contents.
27 equalsDeep(object1: any, object2: any, dept?: number): boolean;
28
29 // Returns an object containing all elements that differ between two objects.
30 diffDeep(object1: any, object2: any, depth?: number): any;
31
32 // Make a javascript object property immutable (assuring it cannot be changed from the current value).
33 makeImmutable(object: any, propertyName?: string, propertyValue?: string): any;
34
35 // Make an object property hidden so it doesn't appear when enumerating elements of the object.
36 makeHidden(object: any, propertyName: string, propertyValue?: string): any;
37
38 // Get the current value of a config environment variable
39 getEnv(varName: string): string;
40
41 // Return the config for the project based on directory param if not directory then return default one (config).
42 loadFileConfigs(configDir?: string): any;
43
44 // Return the sources for the configurations
45 getConfigSources(): IConfigSource[];
46
47 // Returns a new deep copy of the current config object, or any part of the config if provided.
48 toObject(config?: any): any;
49
50 /**
51 * This allows module developers to attach their configurations onto the default configuration object
52 * so they can be configured by the consumers of the module.
53 */
54 setModuleDefaults(moduleName:string, defaults:any): any;
55 }
56
57 interface IConfig {
58 get<T>(setting: string): T;
59 has(setting: string): boolean;
60 util: IUtil;
61 }
62
63 interface IConfigSource {
64 name: string;
65 original?: string | undefined;
66 parsed: any;
67 }
68}
69
70export = c;