UNPKG

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