UNPKG

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