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