UNPKG

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