UNPKG

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