forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
confidence.d.ts
48 lines (40 loc) · 2.35 KB
/
confidence.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// Type definitions for Confidence v1.4.2
// Project: https://github.com/hapijs/confidence.git
// Definitions by: Jean-Philippe Pellerin <https://github.com/jppellerin>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/**
* Confidence is a configuration document format, an API, and a foundation for A/B testing.
* The configuration format is designed to work with any existing JSON-based configuration,
* serving values based on object path ('/a/b/c' translates to a.b.c). In addition,
* confidence defines special $-prefixed keys used to filter values for a given criteria.
*/
declare module 'confidence' {
export class Store {
/**
* @constructor
* @param {any} document - the configuration document for this document store
*/
constructor(document?: any);
/**
* Validates the provided configuration, clears any existing configuration, then loads the configuration where:
* @param {any} document - an object containing a confidence configuration object generated from a parsed JSON document. If the document is invlaid, will throw an error.
*/
load(document: any): void;
/**
* Retrieves a value from the configuration document after applying the provided criteria where:
* @param {string} key - the requested key path. All keys must begin with '/'. '/' returns the the entire document.
* @param {any} criteria - optional object used as criteria for applying filters in the configuration document. Defaults to {}.
*
* @return {any} Returns the value found after applying the criteria. If the key is invalid or not found, returns undefined.
*/
get(key: string, criteria?: any): any;
/**
* Retrieves the metadata (if any) from the configuration document after applying the provided criteria where:
* @param {string} key - the requested key path. All keys must begin with '/'. '/' returns the the entire document.
* @param {any} criteria - optional object used as criteria for applying filters in the configuration document. Defaults to {}.
*
* @return {any} Returns the metadata found after applying the criteria. If the key is invalid or not found, or if no metadata is available, returns undefined.
*/
meta(key: string, criteria?: any): any;
}
}