UNPKG

1.97 kBTypeScriptView Raw
1// Type definitions for get-value 3.0
2// Project: https://github.com/jonschlinkert/get-value
3// Definitions by: Daniel Rosenwasser <https://github.com/DanielRosenwasser>
4// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
5// TypeScript Version: 2.4
6
7export = get;
8
9declare function get<T>(obj: T): T;
10declare function get(obj: object, key: string | string[], options?: get.Options): any;
11
12declare namespace get {
13 interface Options {
14 /**
15 * The default value to return when get-value cannot result a value from the given object.
16 *
17 * default: `undefined`
18 */
19 default?: any;
20 /**
21 * If defined, this function is called on each resolved value.
22 * Useful if you want to do `.hasOwnProperty` or `Object.prototype.propertyIsEnumerable`.
23 */
24 isValid?: (<K extends string>(key: K, object: Record<K, any>) => boolean) | undefined;
25 /**
26 * Custom function to use for splitting the string into object path segments.
27 *
28 * default: `String.split`
29 */
30 split?: ((s: string) => string[]) | undefined;
31 /**
32 * The separator to use for spliting the string.
33 * (this is probably not needed when `options.split` is used).
34 *
35 * default: `"."`
36 */
37 separator?: string | RegExp | undefined;
38 /**
39 * Customize how the object path is created when iterating over path segments.
40 *
41 * default: `Array.join`
42 */
43 join?: ((segs: string[]) => string) | undefined;
44 /**
45 * The character to use when re-joining the string to check for keys
46 * with dots in them (this is probably not needed when `options.join` is used).
47 * This can be a different value than the separator, since the separator can be a string or regex.
48 *
49 * default: `"."`
50 */
51 joinChar?: string | undefined;
52 }
53}
54
\No newline at end of file