UNPKG

2.68 kBMarkdownView Raw
1# Installation
2> `npm install --save @types/set-value`
3
4# Summary
5This package contains type definitions for set-value (https://github.com/jonschlinkert/set-value).
6
7# Details
8Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/set-value.
9## [index.d.ts](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/set-value/index.d.ts)
10````ts
11// Type definitions for set-value 4.0
12// Project: https://github.com/jonschlinkert/set-value
13// Definitions by: Daniel Rosenwasser <https://github.com/DanielRosenwasser>
14// Piotr Błażejewicz <https://github.com/DanielRosenwasser>
15// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
16
17export = set;
18
19// Technically, everything will fall to the last overload,
20// but the first one can be useful for signature help.
21
22/**
23 * @param object The object to set `value` on
24 * @param path The of the property to set.
25 * @param value The value to set on `object[prop]`
26 * @param [options]
27 */
28
29declare function set<T extends object, K extends keyof T>(object: T, path: K, value: T[K], options?: set.Options): void;
30declare function set(object: object, path: set.InputType, value: any, options?: set.Options): void;
31
32declare namespace set {
33 interface Options {
34 /**
35 * Do not split properties that include a `/`.
36 * By default, set-value assumes that properties with a `/` are not intended to be split.
37 * This option allows you to disable default behavior.
38 * Note that this option cannot be used if `options.separator` is set to `/`.
39 * @default true
40 */
41 preservePaths?: boolean | undefined;
42 /**
43 * Custom separator to use for splitting object paths.
44 * @default `.`
45 */
46 separator?: string | undefined;
47 /**
48 * Custom `.split()` function to use.
49 */
50 split?: SplitFunc | undefined;
51 /**
52 * Allows you to update plain object values, instead of overwriting them.
53 * @default `undefined`
54 */
55 merge?: boolean | MergeFunc | undefined;
56 }
57
58 type InputType = string | symbol | ReadonlyArray<string | symbol>;
59
60 type MergeFunc = <TObject, TSource>(object: TObject, source: TSource) => TObject & TSource;
61
62 type SplitFunc = (input: string, options?: Options) => string;
63}
64
65````
66
67### Additional Details
68 * Last updated: Tue, 06 Jul 2021 16:34:40 GMT
69 * Dependencies: none
70 * Global values: none
71
72# Credits
73These definitions were written by [Daniel Rosenwasser](https://github.com/DanielRosenwasser), and [Piotr Błażejewicz](https://github.com/DanielRosenwasser).
74
\No newline at end of file