UNPKG

4.12 kBTypeScriptView Raw
1// Type definitions for nconf
2// Project: https://github.com/flatiron/nconf
3// Definitions by: Jeff Goddard <https://github.com/jedigo>, Jean-Martin Thibault <https://github.com/jmthibault>
4// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
5
6// Imported from: https://github.com/soywiz/typescript-node-definitions/nconf.d.ts
7
8
9export declare var version: number;
10export declare var stores: any;
11export declare var sources: any[];
12
13export declare function clear(key: string, callback?: ICallbackFunction): any;
14export declare function get(key: string, callback?: ICallbackFunction): any;
15export declare function merge(key: string, value: any, callback?: ICallbackFunction): any;
16export declare function set(key: string, value: any, callback?: ICallbackFunction): any;
17export declare function reset(callback?: ICallbackFunction): any;
18
19export declare function load(callback?: ICallbackFunction): any;
20export declare function mergeSources(data: any): void;
21export declare function loadSources(): any;
22export declare function save(value: any, callback?: ICallbackFunction): any;
23
24export declare function add(name: string, options?: IOptions): Provider;
25export declare function argv(options?: IOptions): Provider;
26export declare function env(options?: IOptions): Provider;
27export declare function file(name: string, options?: IFileOptions): Provider;
28export declare function file(name: string, filename: string): Provider;
29export declare function file(options: IFileOptions): Provider;
30export declare function use(name: string, options?: IOptions): Provider;
31export declare function defaults(options?: IOptions): Provider;
32export declare function init(options?: IOptions): void;
33export declare function overrides(options?: IOptions): Provider;
34export declare function remove(name: string): void;
35export declare function create(name: string, options: IOptions): IStore;
36
37export declare function key(...values: any[]): string;
38export declare function path(key: any): any[];
39export declare function loadFiles(files: any, callback?: ICallbackFunction): void;
40export declare function loadFilesSync(files: any, callback?: ICallbackFunction): void;
41
42export declare var formats: {
43 json: IFormat;
44 ini: IFormat;
45};
46
47export interface IFormat {
48 stringify: (obj: any, replacer: any, spacing?: any) => string;
49 parse: (str: string) => any;
50}
51
52export interface IOptions {
53 [index: string]: any;
54}
55
56export interface IFileOptions {
57 type?: string;
58 file?: string;
59 dir?: string;
60 search?: boolean;
61 format?: IFormat;
62 json_spacing?: number;
63}
64
65export interface ICallbackFunction {
66 (err: Error): void;
67}
68
69export declare class Provider {
70 constructor(options: IOptions);
71
72 stores: any;
73 sources: any[];
74
75 clear(key: string, callback?: ICallbackFunction): any;
76 get(key: string, callback?: ICallbackFunction): any;
77 merge(key: string, value: any, callback?: ICallbackFunction): any;
78 set(key: string, value: any, callback?: ICallbackFunction): any;
79 reset(callback?: ICallbackFunction): any;
80
81 load(callback?: ICallbackFunction): any;
82 mergeSources(data: any): void;
83 loadSources(): any;
84 save(value: any, callback?: ICallbackFunction): any;
85
86 add(name: string, options?: IOptions): Provider;
87 argv(options?: IOptions): Provider;
88 env(options?: IOptions): Provider;
89 file(name: string, options?: IFileOptions): Provider;
90 file(name: string, filename: string): Provider;
91 file(options: IFileOptions): Provider;
92 use(name: string, options?: IOptions): Provider;
93
94 defaults(options?: IOptions): Provider;
95 init(options?: IOptions): void;
96 overrides(options?: IOptions): Provider;
97 remove(name: string): void;
98 create(name: string, options: IOptions): IStore;
99}
100
101export interface IStore {
102 type: string;
103 get(key: string): any;
104 set(key: string, value: any): boolean;
105 clear(key: string): boolean;
106 merge(key: string, value: any): boolean;
107 reset(callback?: ICallbackFunction): boolean;
108}