@player-devtools/utils 0.0.7--canary.8.483
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.cjs +59 -0
- package/dist/cjs/index.cjs.map +1 -0
- package/dist/index.legacy-esm.js +34 -0
- package/dist/index.mjs +34 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +26 -0
- package/src/index.ts +88 -0
- package/types/index.d.ts +21 -0
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/devtools/utils/core/src/index.ts
|
|
21
|
+
var src_exports = {};
|
|
22
|
+
__export(src_exports, {
|
|
23
|
+
dsetAssign: () => dsetAssign
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(src_exports);
|
|
26
|
+
function deepAssign(target, source, merge = false) {
|
|
27
|
+
if (Array.isArray(target) && Array.isArray(source)) {
|
|
28
|
+
while (!merge && target.length > source.length) target.pop();
|
|
29
|
+
for (const [index, item] of source.entries()) {
|
|
30
|
+
target[index] = deepAssign(target[index], item, merge);
|
|
31
|
+
}
|
|
32
|
+
} else if (target && typeof target === "object" && source && typeof source === "object") {
|
|
33
|
+
const record = target;
|
|
34
|
+
if (!merge)
|
|
35
|
+
for (const key of Object.keys(target)) {
|
|
36
|
+
if (!(key in source)) delete record[key];
|
|
37
|
+
}
|
|
38
|
+
for (const [key, item] of Object.entries(source)) {
|
|
39
|
+
record[key] = deepAssign(record[key], item, merge);
|
|
40
|
+
}
|
|
41
|
+
} else {
|
|
42
|
+
return source;
|
|
43
|
+
}
|
|
44
|
+
return target;
|
|
45
|
+
}
|
|
46
|
+
function dsetAssign(obj, keys, value, merge = false) {
|
|
47
|
+
const key = keys[keys.length - 1];
|
|
48
|
+
if (!key) throw Error("Unable to assign at path containing undefined keys");
|
|
49
|
+
const target = keys.slice(0, -1).reduce(
|
|
50
|
+
(acc, key2) => acc[key2] ?? (acc[key2] = {}),
|
|
51
|
+
obj
|
|
52
|
+
);
|
|
53
|
+
target[key] = deepAssign(target[key], value, merge);
|
|
54
|
+
}
|
|
55
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
56
|
+
0 && (module.exports = {
|
|
57
|
+
dsetAssign
|
|
58
|
+
});
|
|
59
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/devtools/utils/core/src/index.ts"],"sourcesContent":["/**\n * Recursively assigns the contents of `source` into `target`, preserving\n * existing object and array references to maintain key insertion order.\n *\n * - **Objects**: keys present in `target` but absent in `source` are deleted\n * (unless `merge` is true), then each source entry is recursed into.\n * - **Arrays**: target is truncated or extended to match source length\n * (unless `merge` is true), then each element is recursed into.\n * - **Primitives / type mismatch**: source is returned directly; the caller\n * is responsible for assigning the return value.\n *\n * @param target - The existing value to assign into.\n * @param source - The new value to assign from.\n * @param merge - When true, stale keys and excess array elements are preserved\n * rather than deleted. Defaults to false.\n * @returns The mutated `target`, or `source` if types are incompatible.\n */\nfunction deepAssign<T, V>(target: T, source: V, merge: boolean = false) {\n if (Array.isArray(target) && Array.isArray(source)) {\n while (!merge && target.length > source.length) target.pop();\n // recurse and assign new values\n for (const [index, item] of source.entries()) {\n target[index] = deepAssign(target[index], item, merge);\n }\n } else if (\n target &&\n typeof target === \"object\" &&\n source &&\n typeof source === \"object\"\n ) {\n const record = target as Record<string, unknown>;\n\n // clear stale keys\n if (!merge)\n for (const key of Object.keys(target)) {\n if (!(key in source)) delete record[key];\n }\n // recurse and assign new values\n for (const [key, item] of Object.entries(source)) {\n record[key] = deepAssign(record[key], item, merge);\n }\n } else {\n // new data doesn't match the types, so there is no referential equality to retain\n return source;\n }\n\n return target;\n}\n\ntype Index = string | number;\n\n/**\n * Deep-sets a value at a key path on an object, preserving existing nested\n * object and array references to maintain key insertion order.\n *\n * Intermediate objects are auto-vivified as needed. The final assignment is\n * handled by {@link deepAssign}, which mutates the existing value in place\n * rather than replacing it wholesale.\n *\n * @param obj - The root object to assign into.\n * @param keys - Path of keys leading to the target location.\n * @param value - The value to assign at the path.\n * @param merge - When true, stale keys and excess array elements are preserved\n * rather than deleted. Defaults to false.\n * @throws If `keys` is empty or contains an undefined key.\n *\n * @see {@link https://github.com/lukeed/dset} for the original dset implementation that inspired this API\n */\nexport function dsetAssign<V>(\n obj: Record<Index, unknown>,\n keys: Array<Index>,\n value: V,\n merge: boolean = false,\n): void {\n const key = keys[keys.length - 1];\n if (!key) throw Error(\"Unable to assign at path containing undefined keys\");\n\n // Walk the path, auto-vivifying intermediate objects when necessary\n const target = keys\n .slice(0, -1)\n .reduce(\n (acc, key) => (acc[key] ??= {}) as Record<string | number, unknown>,\n obj,\n );\n\n // Deep assign the value into the target object for key\n target[key] = deepAssign(target[key], value, merge);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAiBA,SAAS,WAAiB,QAAW,QAAW,QAAiB,OAAO;AACtE,MAAI,MAAM,QAAQ,MAAM,KAAK,MAAM,QAAQ,MAAM,GAAG;AAClD,WAAO,CAAC,SAAS,OAAO,SAAS,OAAO,OAAQ,QAAO,IAAI;AAE3D,eAAW,CAAC,OAAO,IAAI,KAAK,OAAO,QAAQ,GAAG;AAC5C,aAAO,KAAK,IAAI,WAAW,OAAO,KAAK,GAAG,MAAM,KAAK;AAAA,IACvD;AAAA,EACF,WACE,UACA,OAAO,WAAW,YAClB,UACA,OAAO,WAAW,UAClB;AACA,UAAM,SAAS;AAGf,QAAI,CAAC;AACH,iBAAW,OAAO,OAAO,KAAK,MAAM,GAAG;AACrC,YAAI,EAAE,OAAO,QAAS,QAAO,OAAO,GAAG;AAAA,MACzC;AAEF,eAAW,CAAC,KAAK,IAAI,KAAK,OAAO,QAAQ,MAAM,GAAG;AAChD,aAAO,GAAG,IAAI,WAAW,OAAO,GAAG,GAAG,MAAM,KAAK;AAAA,IACnD;AAAA,EACF,OAAO;AAEL,WAAO;AAAA,EACT;AAEA,SAAO;AACT;AAqBO,SAAS,WACd,KACA,MACA,OACA,QAAiB,OACX;AACN,QAAM,MAAM,KAAK,KAAK,SAAS,CAAC;AAChC,MAAI,CAAC,IAAK,OAAM,MAAM,oDAAoD;AAG1E,QAAM,SAAS,KACZ,MAAM,GAAG,EAAE,EACX;AAAA,IACC,CAAC,KAAKA,SAAS,IAAAA,UAAA,IAAAA,QAAa,CAAC;AAAA,IAC7B;AAAA,EACF;AAGF,SAAO,GAAG,IAAI,WAAW,OAAO,GAAG,GAAG,OAAO,KAAK;AACpD;","names":["key"]}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/devtools/utils/core/src/index.ts
|
|
2
|
+
function deepAssign(target, source, merge = false) {
|
|
3
|
+
if (Array.isArray(target) && Array.isArray(source)) {
|
|
4
|
+
while (!merge && target.length > source.length) target.pop();
|
|
5
|
+
for (const [index, item] of source.entries()) {
|
|
6
|
+
target[index] = deepAssign(target[index], item, merge);
|
|
7
|
+
}
|
|
8
|
+
} else if (target && typeof target === "object" && source && typeof source === "object") {
|
|
9
|
+
const record = target;
|
|
10
|
+
if (!merge)
|
|
11
|
+
for (const key of Object.keys(target)) {
|
|
12
|
+
if (!(key in source)) delete record[key];
|
|
13
|
+
}
|
|
14
|
+
for (const [key, item] of Object.entries(source)) {
|
|
15
|
+
record[key] = deepAssign(record[key], item, merge);
|
|
16
|
+
}
|
|
17
|
+
} else {
|
|
18
|
+
return source;
|
|
19
|
+
}
|
|
20
|
+
return target;
|
|
21
|
+
}
|
|
22
|
+
function dsetAssign(obj, keys, value, merge = false) {
|
|
23
|
+
const key = keys[keys.length - 1];
|
|
24
|
+
if (!key) throw Error("Unable to assign at path containing undefined keys");
|
|
25
|
+
const target = keys.slice(0, -1).reduce(
|
|
26
|
+
(acc, key2) => acc[key2] ?? (acc[key2] = {}),
|
|
27
|
+
obj
|
|
28
|
+
);
|
|
29
|
+
target[key] = deepAssign(target[key], value, merge);
|
|
30
|
+
}
|
|
31
|
+
export {
|
|
32
|
+
dsetAssign
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/devtools/utils/core/src/index.ts
|
|
2
|
+
function deepAssign(target, source, merge = false) {
|
|
3
|
+
if (Array.isArray(target) && Array.isArray(source)) {
|
|
4
|
+
while (!merge && target.length > source.length) target.pop();
|
|
5
|
+
for (const [index, item] of source.entries()) {
|
|
6
|
+
target[index] = deepAssign(target[index], item, merge);
|
|
7
|
+
}
|
|
8
|
+
} else if (target && typeof target === "object" && source && typeof source === "object") {
|
|
9
|
+
const record = target;
|
|
10
|
+
if (!merge)
|
|
11
|
+
for (const key of Object.keys(target)) {
|
|
12
|
+
if (!(key in source)) delete record[key];
|
|
13
|
+
}
|
|
14
|
+
for (const [key, item] of Object.entries(source)) {
|
|
15
|
+
record[key] = deepAssign(record[key], item, merge);
|
|
16
|
+
}
|
|
17
|
+
} else {
|
|
18
|
+
return source;
|
|
19
|
+
}
|
|
20
|
+
return target;
|
|
21
|
+
}
|
|
22
|
+
function dsetAssign(obj, keys, value, merge = false) {
|
|
23
|
+
const key = keys[keys.length - 1];
|
|
24
|
+
if (!key) throw Error("Unable to assign at path containing undefined keys");
|
|
25
|
+
const target = keys.slice(0, -1).reduce(
|
|
26
|
+
(acc, key2) => acc[key2] ?? (acc[key2] = {}),
|
|
27
|
+
obj
|
|
28
|
+
);
|
|
29
|
+
target[key] = deepAssign(target[key], value, merge);
|
|
30
|
+
}
|
|
31
|
+
export {
|
|
32
|
+
dsetAssign
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/devtools/utils/core/src/index.ts"],"sourcesContent":["/**\n * Recursively assigns the contents of `source` into `target`, preserving\n * existing object and array references to maintain key insertion order.\n *\n * - **Objects**: keys present in `target` but absent in `source` are deleted\n * (unless `merge` is true), then each source entry is recursed into.\n * - **Arrays**: target is truncated or extended to match source length\n * (unless `merge` is true), then each element is recursed into.\n * - **Primitives / type mismatch**: source is returned directly; the caller\n * is responsible for assigning the return value.\n *\n * @param target - The existing value to assign into.\n * @param source - The new value to assign from.\n * @param merge - When true, stale keys and excess array elements are preserved\n * rather than deleted. Defaults to false.\n * @returns The mutated `target`, or `source` if types are incompatible.\n */\nfunction deepAssign<T, V>(target: T, source: V, merge: boolean = false) {\n if (Array.isArray(target) && Array.isArray(source)) {\n while (!merge && target.length > source.length) target.pop();\n // recurse and assign new values\n for (const [index, item] of source.entries()) {\n target[index] = deepAssign(target[index], item, merge);\n }\n } else if (\n target &&\n typeof target === \"object\" &&\n source &&\n typeof source === \"object\"\n ) {\n const record = target as Record<string, unknown>;\n\n // clear stale keys\n if (!merge)\n for (const key of Object.keys(target)) {\n if (!(key in source)) delete record[key];\n }\n // recurse and assign new values\n for (const [key, item] of Object.entries(source)) {\n record[key] = deepAssign(record[key], item, merge);\n }\n } else {\n // new data doesn't match the types, so there is no referential equality to retain\n return source;\n }\n\n return target;\n}\n\ntype Index = string | number;\n\n/**\n * Deep-sets a value at a key path on an object, preserving existing nested\n * object and array references to maintain key insertion order.\n *\n * Intermediate objects are auto-vivified as needed. The final assignment is\n * handled by {@link deepAssign}, which mutates the existing value in place\n * rather than replacing it wholesale.\n *\n * @param obj - The root object to assign into.\n * @param keys - Path of keys leading to the target location.\n * @param value - The value to assign at the path.\n * @param merge - When true, stale keys and excess array elements are preserved\n * rather than deleted. Defaults to false.\n * @throws If `keys` is empty or contains an undefined key.\n *\n * @see {@link https://github.com/lukeed/dset} for the original dset implementation that inspired this API\n */\nexport function dsetAssign<V>(\n obj: Record<Index, unknown>,\n keys: Array<Index>,\n value: V,\n merge: boolean = false,\n): void {\n const key = keys[keys.length - 1];\n if (!key) throw Error(\"Unable to assign at path containing undefined keys\");\n\n // Walk the path, auto-vivifying intermediate objects when necessary\n const target = keys\n .slice(0, -1)\n .reduce(\n (acc, key) => (acc[key] ??= {}) as Record<string | number, unknown>,\n obj,\n );\n\n // Deep assign the value into the target object for key\n target[key] = deepAssign(target[key], value, merge);\n}\n"],"mappings":";AAiBA,SAAS,WAAiB,QAAW,QAAW,QAAiB,OAAO;AACtE,MAAI,MAAM,QAAQ,MAAM,KAAK,MAAM,QAAQ,MAAM,GAAG;AAClD,WAAO,CAAC,SAAS,OAAO,SAAS,OAAO,OAAQ,QAAO,IAAI;AAE3D,eAAW,CAAC,OAAO,IAAI,KAAK,OAAO,QAAQ,GAAG;AAC5C,aAAO,KAAK,IAAI,WAAW,OAAO,KAAK,GAAG,MAAM,KAAK;AAAA,IACvD;AAAA,EACF,WACE,UACA,OAAO,WAAW,YAClB,UACA,OAAO,WAAW,UAClB;AACA,UAAM,SAAS;AAGf,QAAI,CAAC;AACH,iBAAW,OAAO,OAAO,KAAK,MAAM,GAAG;AACrC,YAAI,EAAE,OAAO,QAAS,QAAO,OAAO,GAAG;AAAA,MACzC;AAEF,eAAW,CAAC,KAAK,IAAI,KAAK,OAAO,QAAQ,MAAM,GAAG;AAChD,aAAO,GAAG,IAAI,WAAW,OAAO,GAAG,GAAG,MAAM,KAAK;AAAA,IACnD;AAAA,EACF,OAAO;AAEL,WAAO;AAAA,EACT;AAEA,SAAO;AACT;AAqBO,SAAS,WACd,KACA,MACA,OACA,QAAiB,OACX;AACN,QAAM,MAAM,KAAK,KAAK,SAAS,CAAC;AAChC,MAAI,CAAC,IAAK,OAAM,MAAM,oDAAoD;AAG1E,QAAM,SAAS,KACZ,MAAM,GAAG,EAAE,EACX;AAAA,IACC,CAAC,KAAKA,SAAS,IAAAA,UAAA,IAAAA,QAAa,CAAC;AAAA,IAC7B;AAAA,EACF;AAGF,SAAO,GAAG,IAAI,WAAW,OAAO,GAAG,GAAG,OAAO,KAAK;AACpD;","names":["key"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"sideEffects": false,
|
|
3
|
+
"files": [
|
|
4
|
+
"dist",
|
|
5
|
+
"src",
|
|
6
|
+
"types"
|
|
7
|
+
],
|
|
8
|
+
"name": "@player-devtools/utils",
|
|
9
|
+
"version": "0.0.7--canary.8.483",
|
|
10
|
+
"main": "dist/cjs/index.cjs",
|
|
11
|
+
"module": "dist/index.legacy-esm.js",
|
|
12
|
+
"types": "types/index.d.ts",
|
|
13
|
+
"exports": {
|
|
14
|
+
"./package.json": "./package.json",
|
|
15
|
+
"./dist/index.css": "./dist/index.css",
|
|
16
|
+
".": {
|
|
17
|
+
"types": "./types/index.d.ts",
|
|
18
|
+
"import": "./dist/index.mjs",
|
|
19
|
+
"default": "./dist/cjs/index.cjs"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"tslib": "^2.6.2"
|
|
24
|
+
},
|
|
25
|
+
"peerDependencies": {}
|
|
26
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Recursively assigns the contents of `source` into `target`, preserving
|
|
3
|
+
* existing object and array references to maintain key insertion order.
|
|
4
|
+
*
|
|
5
|
+
* - **Objects**: keys present in `target` but absent in `source` are deleted
|
|
6
|
+
* (unless `merge` is true), then each source entry is recursed into.
|
|
7
|
+
* - **Arrays**: target is truncated or extended to match source length
|
|
8
|
+
* (unless `merge` is true), then each element is recursed into.
|
|
9
|
+
* - **Primitives / type mismatch**: source is returned directly; the caller
|
|
10
|
+
* is responsible for assigning the return value.
|
|
11
|
+
*
|
|
12
|
+
* @param target - The existing value to assign into.
|
|
13
|
+
* @param source - The new value to assign from.
|
|
14
|
+
* @param merge - When true, stale keys and excess array elements are preserved
|
|
15
|
+
* rather than deleted. Defaults to false.
|
|
16
|
+
* @returns The mutated `target`, or `source` if types are incompatible.
|
|
17
|
+
*/
|
|
18
|
+
function deepAssign<T, V>(target: T, source: V, merge: boolean = false) {
|
|
19
|
+
if (Array.isArray(target) && Array.isArray(source)) {
|
|
20
|
+
while (!merge && target.length > source.length) target.pop();
|
|
21
|
+
// recurse and assign new values
|
|
22
|
+
for (const [index, item] of source.entries()) {
|
|
23
|
+
target[index] = deepAssign(target[index], item, merge);
|
|
24
|
+
}
|
|
25
|
+
} else if (
|
|
26
|
+
target &&
|
|
27
|
+
typeof target === "object" &&
|
|
28
|
+
source &&
|
|
29
|
+
typeof source === "object"
|
|
30
|
+
) {
|
|
31
|
+
const record = target as Record<string, unknown>;
|
|
32
|
+
|
|
33
|
+
// clear stale keys
|
|
34
|
+
if (!merge)
|
|
35
|
+
for (const key of Object.keys(target)) {
|
|
36
|
+
if (!(key in source)) delete record[key];
|
|
37
|
+
}
|
|
38
|
+
// recurse and assign new values
|
|
39
|
+
for (const [key, item] of Object.entries(source)) {
|
|
40
|
+
record[key] = deepAssign(record[key], item, merge);
|
|
41
|
+
}
|
|
42
|
+
} else {
|
|
43
|
+
// new data doesn't match the types, so there is no referential equality to retain
|
|
44
|
+
return source;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return target;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
type Index = string | number;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Deep-sets a value at a key path on an object, preserving existing nested
|
|
54
|
+
* object and array references to maintain key insertion order.
|
|
55
|
+
*
|
|
56
|
+
* Intermediate objects are auto-vivified as needed. The final assignment is
|
|
57
|
+
* handled by {@link deepAssign}, which mutates the existing value in place
|
|
58
|
+
* rather than replacing it wholesale.
|
|
59
|
+
*
|
|
60
|
+
* @param obj - The root object to assign into.
|
|
61
|
+
* @param keys - Path of keys leading to the target location.
|
|
62
|
+
* @param value - The value to assign at the path.
|
|
63
|
+
* @param merge - When true, stale keys and excess array elements are preserved
|
|
64
|
+
* rather than deleted. Defaults to false.
|
|
65
|
+
* @throws If `keys` is empty or contains an undefined key.
|
|
66
|
+
*
|
|
67
|
+
* @see {@link https://github.com/lukeed/dset} for the original dset implementation that inspired this API
|
|
68
|
+
*/
|
|
69
|
+
export function dsetAssign<V>(
|
|
70
|
+
obj: Record<Index, unknown>,
|
|
71
|
+
keys: Array<Index>,
|
|
72
|
+
value: V,
|
|
73
|
+
merge: boolean = false,
|
|
74
|
+
): void {
|
|
75
|
+
const key = keys[keys.length - 1];
|
|
76
|
+
if (!key) throw Error("Unable to assign at path containing undefined keys");
|
|
77
|
+
|
|
78
|
+
// Walk the path, auto-vivifying intermediate objects when necessary
|
|
79
|
+
const target = keys
|
|
80
|
+
.slice(0, -1)
|
|
81
|
+
.reduce(
|
|
82
|
+
(acc, key) => (acc[key] ??= {}) as Record<string | number, unknown>,
|
|
83
|
+
obj,
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
// Deep assign the value into the target object for key
|
|
87
|
+
target[key] = deepAssign(target[key], value, merge);
|
|
88
|
+
}
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
type Index = string | number;
|
|
2
|
+
/**
|
|
3
|
+
* Deep-sets a value at a key path on an object, preserving existing nested
|
|
4
|
+
* object and array references to maintain key insertion order.
|
|
5
|
+
*
|
|
6
|
+
* Intermediate objects are auto-vivified as needed. The final assignment is
|
|
7
|
+
* handled by {@link deepAssign}, which mutates the existing value in place
|
|
8
|
+
* rather than replacing it wholesale.
|
|
9
|
+
*
|
|
10
|
+
* @param obj - The root object to assign into.
|
|
11
|
+
* @param keys - Path of keys leading to the target location.
|
|
12
|
+
* @param value - The value to assign at the path.
|
|
13
|
+
* @param merge - When true, stale keys and excess array elements are preserved
|
|
14
|
+
* rather than deleted. Defaults to false.
|
|
15
|
+
* @throws If `keys` is empty or contains an undefined key.
|
|
16
|
+
*
|
|
17
|
+
* @see {@link https://github.com/lukeed/dset} for the original dset implementation that inspired this API
|
|
18
|
+
*/
|
|
19
|
+
export declare function dsetAssign<V>(obj: Record<Index, unknown>, keys: Array<Index>, value: V, merge?: boolean): void;
|
|
20
|
+
export {};
|
|
21
|
+
//# sourceMappingURL=index.d.ts.map
|