UNPKG

2.34 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
11export = set;
12
13// Technically, everything will fall to the last overload,
14// but the first one can be useful for signature help.
15
16/**
17 * @param object The object to set `value` on
18 * @param path The of the property to set.
19 * @param value The value to set on `object[prop]`
20 * @param [options]
21 */
22
23declare function set<T extends object, K extends keyof T>(object: T, path: K, value: T[K], options?: set.Options): void;
24declare function set(object: object, path: set.InputType, value: any, options?: set.Options): void;
25
26declare namespace set {
27 interface Options {
28 /**
29 * Do not split properties that include a `/`.
30 * By default, set-value assumes that properties with a `/` are not intended to be split.
31 * This option allows you to disable default behavior.
32 * Note that this option cannot be used if `options.separator` is set to `/`.
33 * @default true
34 */
35 preservePaths?: boolean | undefined;
36 /**
37 * Custom separator to use for splitting object paths.
38 * @default `.`
39 */
40 separator?: string | undefined;
41 /**
42 * Custom `.split()` function to use.
43 */
44 split?: SplitFunc | undefined;
45 /**
46 * Allows you to update plain object values, instead of overwriting them.
47 * @default `undefined`
48 */
49 merge?: boolean | MergeFunc | undefined;
50 }
51
52 type InputType = string | symbol | ReadonlyArray<string | symbol>;
53
54 type MergeFunc = <TObject, TSource>(object: TObject, source: TSource) => TObject & TSource;
55
56 type SplitFunc = (input: string, options?: Options) => string;
57}
58
59````
60
61### Additional Details
62 * Last updated: Tue, 07 Nov 2023 15:11:36 GMT
63 * Dependencies: none
64
65# Credits
66These definitions were written by [Daniel Rosenwasser](https://github.com/DanielRosenwasser), and [Piotr Błażejewicz](https://github.com/DanielRosenwasser).
67
\No newline at end of file