umt 2.13.0 → 2.15.0
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/module/Array/arraysJoin.js +9 -1
- package/module/Array/arraysJoin.js.map +1 -1
- package/module/Array/sum.js +35 -2
- package/module/Array/sum.js.map +1 -1
- package/module/Array/ultraNumberSort.js +8 -3
- package/module/Array/ultraNumberSort.js.map +1 -1
- package/module/Array/zip.js +21 -5
- package/module/Array/zip.js.map +1 -1
- package/module/Array/zipLongest.js +23 -4
- package/module/Array/zipLongest.js.map +1 -1
- package/module/Crypto/decodeBase32.js +3 -2
- package/module/Crypto/decodeBase32.js.map +1 -1
- package/module/Crypto/decodeBase58.js +6 -4
- package/module/Crypto/decodeBase58.js.map +1 -1
- package/module/Crypto/encodeBase32.js +11 -6
- package/module/Crypto/encodeBase32.js.map +1 -1
- package/module/Crypto/encodeBase58.js +5 -2
- package/module/Crypto/encodeBase58.js.map +1 -1
- package/module/DataStructure/priorityQueue.js +8 -1
- package/module/DataStructure/priorityQueue.js.map +1 -1
- package/module/IP/ipToBinaryString.js +3 -1
- package/module/IP/ipToBinaryString.js.map +1 -1
- package/module/IP/longToIp.d.ts +1 -1
- package/module/IP/longToIp.js +2 -7
- package/module/IP/longToIp.js.map +1 -1
- package/module/Math/addition.js +4 -11
- package/module/Math/addition.js.map +1 -1
- package/module/Math/multiplication.js +14 -6
- package/module/Math/multiplication.js.map +1 -1
- package/module/Math/nCr.js +6 -2
- package/module/Math/nCr.js.map +1 -1
- package/module/Math/standardDeviation.js +12 -7
- package/module/Math/standardDeviation.js.map +1 -1
- package/module/Math/subtract.js +5 -9
- package/module/Math/subtract.js.map +1 -1
- package/module/Object/deepClone.d.ts +10 -0
- package/module/Object/deepClone.js +16 -6
- package/module/Object/deepClone.js.map +1 -1
- package/module/Object/getObjectsCommon.d.ts +10 -0
- package/module/Object/getObjectsCommon.js +10 -0
- package/module/Object/getObjectsCommon.js.map +1 -1
- package/module/Object/getObjectsDiff.d.ts +10 -0
- package/module/Object/getObjectsDiff.js +17 -6
- package/module/Object/getObjectsDiff.js.map +1 -1
- package/module/Object/has.d.ts +10 -0
- package/module/Object/has.js +10 -0
- package/module/Object/has.js.map +1 -1
- package/module/Object/index.d.ts +4 -0
- package/module/Object/index.js +4 -0
- package/module/Object/index.js.map +1 -1
- package/module/Object/keyBy.d.ts +10 -0
- package/module/Object/keyBy.js +10 -0
- package/module/Object/keyBy.js.map +1 -1
- package/module/Object/mapKeys.d.ts +10 -0
- package/module/Object/mapKeys.js +12 -1
- package/module/Object/mapKeys.js.map +1 -1
- package/module/Object/mapValues.d.ts +10 -0
- package/module/Object/mapValues.js +10 -0
- package/module/Object/mapValues.js.map +1 -1
- package/module/Object/merge.d.ts +10 -0
- package/module/Object/merge.js +17 -1
- package/module/Object/merge.js.map +1 -1
- package/module/Object/mergeDeep.d.ts +10 -0
- package/module/Object/mergeDeep.js +29 -15
- package/module/Object/mergeDeep.js.map +1 -1
- package/module/Object/pickDeep.d.ts +10 -0
- package/module/Object/pickDeep.js +10 -5
- package/module/Object/pickDeep.js.map +1 -1
- package/module/Object/removePrototype.d.ts +15 -0
- package/module/Object/removePrototype.js +25 -0
- package/module/Object/removePrototype.js.map +1 -0
- package/module/Object/removePrototypeDeep.d.ts +11 -0
- package/module/Object/removePrototypeDeep.js +60 -0
- package/module/Object/removePrototypeDeep.js.map +1 -0
- package/module/Object/removePrototypeMap.d.ts +9 -0
- package/module/Object/removePrototypeMap.js +13 -0
- package/module/Object/removePrototypeMap.js.map +1 -0
- package/module/Object/removePrototypeMapDeep.d.ts +9 -0
- package/module/Object/removePrototypeMapDeep.js +13 -0
- package/module/Object/removePrototypeMapDeep.js.map +1 -0
- package/module/String/escapeHtml.js +11 -2
- package/module/String/escapeHtml.js.map +1 -1
- package/module/String/formatString/applyFormatter.js +5 -5
- package/module/String/formatString/applyFormatter.js.map +1 -1
- package/module/String/formatString/getValue.js +3 -1
- package/module/String/formatString/getValue.js.map +1 -1
- package/module/String/levenshteinDistance.js +41 -24
- package/module/String/levenshteinDistance.js.map +1 -1
- package/module/String/slugify.js +7 -5
- package/module/String/slugify.js.map +1 -1
- package/module/String/trimEndCharacters.js +3 -1
- package/module/String/trimEndCharacters.js.map +1 -1
- package/module/String/trimStartCharacters.js +3 -1
- package/module/String/trimStartCharacters.js.map +1 -1
- package/module/String/unescapeHtml.d.ts +1 -1
- package/module/String/unescapeHtml.js +48 -4
- package/module/String/unescapeHtml.js.map +1 -1
- package/module/Tool/parseJson.js +13 -1
- package/module/Tool/parseJson.js.map +1 -1
- package/module/URL/buildUrl.js +4 -0
- package/module/URL/buildUrl.js.map +1 -1
- package/module/URL/parseQueryString.js +4 -0
- package/module/URL/parseQueryString.js.map +1 -1
- package/module/Validate/isDeepEqual.js +7 -5
- package/module/Validate/isDeepEqual.js.map +1 -1
- package/module/Validate/isPrimeNumber.js +12 -2
- package/module/Validate/isPrimeNumber.js.map +1 -1
- package/module/Validate/object/index.d.ts +2 -0
- package/module/Validate/object/index.js +2 -0
- package/module/Validate/object/index.js.map +1 -1
- package/module/Validate/object/intersection.d.ts +10 -0
- package/module/Validate/object/intersection.js +25 -0
- package/module/Validate/object/intersection.js.map +1 -0
- package/module/Validate/object/optional.d.ts +6 -0
- package/module/Validate/object/optional.js +6 -0
- package/module/Validate/object/optional.js.map +1 -1
- package/module/Validate/object/union.d.ts +9 -0
- package/module/Validate/object/union.js +27 -0
- package/module/Validate/object/union.js.map +1 -0
- package/module/Validate/parseEmail.js +6 -0
- package/module/Validate/parseEmail.js.map +1 -1
- package/module/Validate/string/uuid.d.ts +1 -5
- package/module/Validate/string/uuid.js +19 -2
- package/module/Validate/string/uuid.js.map +1 -1
- package/module/es5/Array/arraysJoin.js +20 -2
- package/module/es5/Array/sum.js +38 -4
- package/module/es5/Array/ultraNumberSort.js +31 -45
- package/module/es5/Array/zip.js +23 -17
- package/module/es5/Array/zipLongest.js +27 -14
- package/module/es5/Crypto/decodeBase32.js +11 -2
- package/module/es5/Crypto/decodeBase58.js +13 -6
- package/module/es5/Crypto/encodeBase32.js +12 -6
- package/module/es5/Crypto/encodeBase58.js +6 -2
- package/module/es5/DataStructure/priorityQueue.js +8 -3
- package/module/es5/IP/ipToBinaryString.js +2 -2
- package/module/es5/IP/longToIp.d.ts +1 -1
- package/module/es5/IP/longToIp.js +2 -13
- package/module/es5/Math/addition.js +4 -13
- package/module/es5/Math/multiplication.js +37 -6
- package/module/es5/Math/nCr.js +7 -2
- package/module/es5/Math/standardDeviation.js +25 -10
- package/module/es5/Math/subtract.js +12 -9
- package/module/es5/Object/deepClone.d.ts +10 -0
- package/module/es5/Object/deepClone.js +16 -6
- package/module/es5/Object/getObjectsCommon.d.ts +10 -0
- package/module/es5/Object/getObjectsCommon.js +10 -0
- package/module/es5/Object/getObjectsDiff.d.ts +10 -0
- package/module/es5/Object/getObjectsDiff.js +32 -17
- package/module/es5/Object/has.d.ts +10 -0
- package/module/es5/Object/has.js +10 -0
- package/module/es5/Object/index.d.ts +4 -0
- package/module/es5/Object/index.js +44 -0
- package/module/es5/Object/keyBy.d.ts +10 -0
- package/module/es5/Object/keyBy.js +10 -0
- package/module/es5/Object/mapKeys.d.ts +10 -0
- package/module/es5/Object/mapKeys.js +12 -1
- package/module/es5/Object/mapValues.d.ts +10 -0
- package/module/es5/Object/mapValues.js +10 -0
- package/module/es5/Object/merge.d.ts +10 -0
- package/module/es5/Object/merge.js +19 -1
- package/module/es5/Object/mergeDeep.d.ts +10 -0
- package/module/es5/Object/mergeDeep.js +34 -18
- package/module/es5/Object/pickDeep.d.ts +10 -0
- package/module/es5/Object/pickDeep.js +10 -3
- package/module/es5/Object/removePrototype.d.ts +15 -0
- package/module/es5/Object/removePrototype.js +31 -0
- package/module/es5/Object/removePrototypeDeep.d.ts +11 -0
- package/module/es5/Object/removePrototypeDeep.js +81 -0
- package/module/es5/Object/removePrototypeMap.d.ts +9 -0
- package/module/es5/Object/removePrototypeMap.js +20 -0
- package/module/es5/Object/removePrototypeMapDeep.d.ts +9 -0
- package/module/es5/Object/removePrototypeMapDeep.js +20 -0
- package/module/es5/String/escapeHtml.js +12 -3
- package/module/es5/String/formatString/applyFormatter.js +5 -5
- package/module/es5/String/formatString/getValue.js +4 -1
- package/module/es5/String/levenshteinDistance.js +43 -28
- package/module/es5/String/slugify.js +8 -1
- package/module/es5/String/trimEndCharacters.js +3 -1
- package/module/es5/String/trimStartCharacters.js +3 -1
- package/module/es5/String/unescapeHtml.d.ts +1 -1
- package/module/es5/String/unescapeHtml.js +46 -4
- package/module/es5/Tool/parseJson.js +14 -1
- package/module/es5/URL/buildUrl.js +4 -0
- package/module/es5/URL/parseQueryString.js +4 -0
- package/module/es5/Validate/isDeepEqual.js +48 -39
- package/module/es5/Validate/isPrimeNumber.js +14 -2
- package/module/es5/Validate/object/index.d.ts +2 -0
- package/module/es5/Validate/object/index.js +22 -0
- package/module/es5/Validate/object/intersection.d.ts +10 -0
- package/module/es5/Validate/object/intersection.js +34 -0
- package/module/es5/Validate/object/optional.d.ts +6 -0
- package/module/es5/Validate/object/optional.js +6 -0
- package/module/es5/Validate/object/union.d.ts +9 -0
- package/module/es5/Validate/object/union.js +36 -0
- package/module/es5/Validate/parseEmail.js +8 -0
- package/module/es5/Validate/string/uuid.d.ts +1 -5
- package/module/es5/Validate/string/uuid.js +24 -2
- package/package.json +33 -28
- package/module/es5/tsconfig.tsbuildinfo +0 -1
|
@@ -34,6 +34,16 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
|
|
34
34
|
* @param {...Record<string, unknown>[]} objects - Additional objects to compare.
|
|
35
35
|
* @returns {Partial<T>} Object containing only the key-value pairs shared by all inputs.
|
|
36
36
|
*
|
|
37
|
+
* @remarks
|
|
38
|
+
* **Prototype pollution warning:** This function does not filter out
|
|
39
|
+
* prototype-polluting keys (`__proto__`, `constructor`, `prototype`).
|
|
40
|
+
* If processing user-controlled input, sanitize with the appropriate
|
|
41
|
+
* `removePrototype*` helper before calling this function:
|
|
42
|
+
* - `removePrototype` — shallow sanitization of a single object
|
|
43
|
+
* - `removePrototypeDeep` — recursive sanitization of a single object (for deeply nested data)
|
|
44
|
+
* - `removePrototypeMap` — shallow sanitization of an array of objects
|
|
45
|
+
* - `removePrototypeMapDeep` — recursive sanitization of an array of objects (for deeply nested data)
|
|
46
|
+
*
|
|
37
47
|
* @example
|
|
38
48
|
* ```typescript
|
|
39
49
|
* getObjectsCommon({ a: 1, b: 2 }, { a: 1, c: 3 });
|
|
@@ -13,6 +13,16 @@
|
|
|
13
13
|
* @param {...Record<string, unknown>[]} objects - Additional objects to compare.
|
|
14
14
|
* @returns {Partial<T>} Object containing only key-value pairs unique to one input.
|
|
15
15
|
*
|
|
16
|
+
* @remarks
|
|
17
|
+
* **Prototype pollution warning:** This function does not filter out
|
|
18
|
+
* prototype-polluting keys (`__proto__`, `constructor`, `prototype`).
|
|
19
|
+
* If processing user-controlled input, sanitize with the appropriate
|
|
20
|
+
* `removePrototype*` helper before calling this function:
|
|
21
|
+
* - `removePrototype` — shallow sanitization of a single object
|
|
22
|
+
* - `removePrototypeDeep` — recursive sanitization of a single object (for deeply nested data)
|
|
23
|
+
* - `removePrototypeMap` — shallow sanitization of an array of objects
|
|
24
|
+
* - `removePrototypeMapDeep` — recursive sanitization of an array of objects (for deeply nested data)
|
|
25
|
+
*
|
|
16
26
|
* @example
|
|
17
27
|
* ```typescript
|
|
18
28
|
* getObjectsDiff({ a: 1, b: 2 }, { b: 2, c: 3 });
|
|
@@ -37,6 +37,16 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
|
|
37
37
|
* @param {...Record<string, unknown>[]} objects - Additional objects to compare.
|
|
38
38
|
* @returns {Partial<T>} Object containing only key-value pairs unique to one input.
|
|
39
39
|
*
|
|
40
|
+
* @remarks
|
|
41
|
+
* **Prototype pollution warning:** This function does not filter out
|
|
42
|
+
* prototype-polluting keys (`__proto__`, `constructor`, `prototype`).
|
|
43
|
+
* If processing user-controlled input, sanitize with the appropriate
|
|
44
|
+
* `removePrototype*` helper before calling this function:
|
|
45
|
+
* - `removePrototype` — shallow sanitization of a single object
|
|
46
|
+
* - `removePrototypeDeep` — recursive sanitization of a single object (for deeply nested data)
|
|
47
|
+
* - `removePrototypeMap` — shallow sanitization of an array of objects
|
|
48
|
+
* - `removePrototypeMapDeep` — recursive sanitization of an array of objects (for deeply nested data)
|
|
49
|
+
*
|
|
40
50
|
* @example
|
|
41
51
|
* ```typescript
|
|
42
52
|
* getObjectsDiff({ a: 1, b: 2 }, { b: 2, c: 3 });
|
|
@@ -111,27 +121,32 @@ var _getObjectsDiff = exports.getObjectsDiff = function getObjectsDiff(object) {
|
|
|
111
121
|
}
|
|
112
122
|
var lastUniqueValue = void 0;
|
|
113
123
|
var hasUnique = false;
|
|
124
|
+
|
|
125
|
+
// Count occurrences in a single pass using a Map — O(n) instead of O(n²).
|
|
126
|
+
// Map keys use SameValueZero which matches === for all values except NaN,
|
|
127
|
+
// an acceptable trade-off for object-diff use cases.
|
|
128
|
+
var valueCounts = new Map();
|
|
114
129
|
for (var _i2 = 0, _values = values; _i2 < _values.length; _i2++) {
|
|
130
|
+
var _valueCounts$get;
|
|
115
131
|
var value = _values[_i2];
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
132
|
+
valueCounts.set(value, ((_valueCounts$get = valueCounts.get(value)) !== null && _valueCounts$get !== void 0 ? _valueCounts$get : 0) + 1);
|
|
133
|
+
}
|
|
134
|
+
var _iterator4 = _createForOfIteratorHelper(valueCounts),
|
|
135
|
+
_step4;
|
|
136
|
+
try {
|
|
137
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
138
|
+
var _step4$value = _slicedToArray(_step4.value, 2),
|
|
139
|
+
_value = _step4$value[0],
|
|
140
|
+
count = _step4$value[1];
|
|
141
|
+
if (count === 1) {
|
|
142
|
+
lastUniqueValue = _value;
|
|
143
|
+
hasUnique = true;
|
|
125
144
|
}
|
|
126
|
-
} catch (err) {
|
|
127
|
-
_iterator4.e(err);
|
|
128
|
-
} finally {
|
|
129
|
-
_iterator4.f();
|
|
130
|
-
}
|
|
131
|
-
if (count === 1) {
|
|
132
|
-
lastUniqueValue = value;
|
|
133
|
-
hasUnique = true;
|
|
134
145
|
}
|
|
146
|
+
} catch (err) {
|
|
147
|
+
_iterator4.e(err);
|
|
148
|
+
} finally {
|
|
149
|
+
_iterator4.f();
|
|
135
150
|
}
|
|
136
151
|
if (hasUnique) {
|
|
137
152
|
result[_key2] = lastUniqueValue;
|
|
@@ -6,6 +6,16 @@
|
|
|
6
6
|
* @example has({ a: { b: 1 } }, "a.b"); // true
|
|
7
7
|
* has({ a: { b: 1 } }, ["a", "b"]); // true
|
|
8
8
|
* has({ a: { b: 1 } }, "a.c"); // false
|
|
9
|
+
*
|
|
10
|
+
* @remarks
|
|
11
|
+
* **Prototype pollution warning:** This function does not filter out
|
|
12
|
+
* prototype-polluting keys (`__proto__`, `constructor`, `prototype`).
|
|
13
|
+
* If processing user-controlled input, sanitize with the appropriate
|
|
14
|
+
* `removePrototype*` helper before calling this function:
|
|
15
|
+
* - `removePrototype` — shallow sanitization of a single object
|
|
16
|
+
* - `removePrototypeDeep` — recursive sanitization of a single object (for deeply nested data)
|
|
17
|
+
* - `removePrototypeMap` — shallow sanitization of an array of objects
|
|
18
|
+
* - `removePrototypeMapDeep` — recursive sanitization of an array of objects (for deeply nested data)
|
|
9
19
|
*/
|
|
10
20
|
export declare const has: <T extends {
|
|
11
21
|
[key: string]: unknown;
|
package/module/es5/Object/has.js
CHANGED
|
@@ -21,6 +21,16 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
|
|
21
21
|
* @example has({ a: { b: 1 } }, "a.b"); // true
|
|
22
22
|
* has({ a: { b: 1 } }, ["a", "b"]); // true
|
|
23
23
|
* has({ a: { b: 1 } }, "a.c"); // false
|
|
24
|
+
*
|
|
25
|
+
* @remarks
|
|
26
|
+
* **Prototype pollution warning:** This function does not filter out
|
|
27
|
+
* prototype-polluting keys (`__proto__`, `constructor`, `prototype`).
|
|
28
|
+
* If processing user-controlled input, sanitize with the appropriate
|
|
29
|
+
* `removePrototype*` helper before calling this function:
|
|
30
|
+
* - `removePrototype` — shallow sanitization of a single object
|
|
31
|
+
* - `removePrototypeDeep` — recursive sanitization of a single object (for deeply nested data)
|
|
32
|
+
* - `removePrototypeMap` — shallow sanitization of an array of objects
|
|
33
|
+
* - `removePrototypeMapDeep` — recursive sanitization of an array of objects (for deeply nested data)
|
|
24
34
|
*/
|
|
25
35
|
var has = exports.has = function has(object, path) {
|
|
26
36
|
var localPath = typeof path === "string" ? path.split(".") : path;
|
|
@@ -12,3 +12,7 @@ export * from "./mergeDeep";
|
|
|
12
12
|
export * from "./omit";
|
|
13
13
|
export * from "./pick";
|
|
14
14
|
export * from "./pickDeep";
|
|
15
|
+
export * from "./removePrototype";
|
|
16
|
+
export * from "./removePrototypeDeep";
|
|
17
|
+
export * from "./removePrototypeMap";
|
|
18
|
+
export * from "./removePrototypeMapDeep";
|
|
@@ -156,4 +156,48 @@ Object.keys(_pickDeep).forEach(function (key) {
|
|
|
156
156
|
return _pickDeep[key];
|
|
157
157
|
}
|
|
158
158
|
});
|
|
159
|
+
});
|
|
160
|
+
var _removePrototype = require("./removePrototype");
|
|
161
|
+
Object.keys(_removePrototype).forEach(function (key) {
|
|
162
|
+
if (key === "default" || key === "__esModule") return;
|
|
163
|
+
if (key in exports && exports[key] === _removePrototype[key]) return;
|
|
164
|
+
Object.defineProperty(exports, key, {
|
|
165
|
+
enumerable: true,
|
|
166
|
+
get: function get() {
|
|
167
|
+
return _removePrototype[key];
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
});
|
|
171
|
+
var _removePrototypeDeep = require("./removePrototypeDeep");
|
|
172
|
+
Object.keys(_removePrototypeDeep).forEach(function (key) {
|
|
173
|
+
if (key === "default" || key === "__esModule") return;
|
|
174
|
+
if (key in exports && exports[key] === _removePrototypeDeep[key]) return;
|
|
175
|
+
Object.defineProperty(exports, key, {
|
|
176
|
+
enumerable: true,
|
|
177
|
+
get: function get() {
|
|
178
|
+
return _removePrototypeDeep[key];
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
});
|
|
182
|
+
var _removePrototypeMap = require("./removePrototypeMap");
|
|
183
|
+
Object.keys(_removePrototypeMap).forEach(function (key) {
|
|
184
|
+
if (key === "default" || key === "__esModule") return;
|
|
185
|
+
if (key in exports && exports[key] === _removePrototypeMap[key]) return;
|
|
186
|
+
Object.defineProperty(exports, key, {
|
|
187
|
+
enumerable: true,
|
|
188
|
+
get: function get() {
|
|
189
|
+
return _removePrototypeMap[key];
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
});
|
|
193
|
+
var _removePrototypeMapDeep = require("./removePrototypeMapDeep");
|
|
194
|
+
Object.keys(_removePrototypeMapDeep).forEach(function (key) {
|
|
195
|
+
if (key === "default" || key === "__esModule") return;
|
|
196
|
+
if (key in exports && exports[key] === _removePrototypeMapDeep[key]) return;
|
|
197
|
+
Object.defineProperty(exports, key, {
|
|
198
|
+
enumerable: true,
|
|
199
|
+
get: function get() {
|
|
200
|
+
return _removePrototypeMapDeep[key];
|
|
201
|
+
}
|
|
202
|
+
});
|
|
159
203
|
});
|
|
@@ -5,6 +5,16 @@ type Iteratee<T> = IterateeFunction<T> | keyof T;
|
|
|
5
5
|
* Creates an object composed of keys generated from the results of running each element of collection through iteratee
|
|
6
6
|
* @param collection The collection to iterate over
|
|
7
7
|
* @param iteratee The iteratee function or property name to generate the key
|
|
8
|
+
*
|
|
9
|
+
* @remarks
|
|
10
|
+
* **Prototype pollution warning:** This function does not filter out
|
|
11
|
+
* prototype-polluting keys (`__proto__`, `constructor`, `prototype`).
|
|
12
|
+
* If processing user-controlled input, sanitize with the appropriate
|
|
13
|
+
* `removePrototype*` helper before calling this function:
|
|
14
|
+
* - `removePrototype` — shallow sanitization of a single object
|
|
15
|
+
* - `removePrototypeDeep` — recursive sanitization of a single object (for deeply nested data)
|
|
16
|
+
* - `removePrototypeMap` — shallow sanitization of an array of objects
|
|
17
|
+
* - `removePrototypeMapDeep` — recursive sanitization of an array of objects (for deeply nested data)
|
|
8
18
|
*/
|
|
9
19
|
export declare function keyBy<T>(collection: T[] | Record<PropertyName, T>, iteratee?: Iteratee<T>): Record<PropertyName, T>;
|
|
10
20
|
export {};
|
|
@@ -11,6 +11,16 @@ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length)
|
|
|
11
11
|
* Creates an object composed of keys generated from the results of running each element of collection through iteratee
|
|
12
12
|
* @param collection The collection to iterate over
|
|
13
13
|
* @param iteratee The iteratee function or property name to generate the key
|
|
14
|
+
*
|
|
15
|
+
* @remarks
|
|
16
|
+
* **Prototype pollution warning:** This function does not filter out
|
|
17
|
+
* prototype-polluting keys (`__proto__`, `constructor`, `prototype`).
|
|
18
|
+
* If processing user-controlled input, sanitize with the appropriate
|
|
19
|
+
* `removePrototype*` helper before calling this function:
|
|
20
|
+
* - `removePrototype` — shallow sanitization of a single object
|
|
21
|
+
* - `removePrototypeDeep` — recursive sanitization of a single object (for deeply nested data)
|
|
22
|
+
* - `removePrototypeMap` — shallow sanitization of an array of objects
|
|
23
|
+
* - `removePrototypeMapDeep` — recursive sanitization of an array of objects (for deeply nested data)
|
|
14
24
|
*/
|
|
15
25
|
function keyBy(collection, iteratee) {
|
|
16
26
|
var getKey = normalizeIteratee(iteratee);
|
|
@@ -6,6 +6,16 @@
|
|
|
6
6
|
* @param function_ - The function invoked per key. Receives (value, key).
|
|
7
7
|
* @returns A new object with transformed keys.
|
|
8
8
|
*
|
|
9
|
+
* @remarks
|
|
10
|
+
* **Prototype pollution warning:** This function does not filter out
|
|
11
|
+
* prototype-polluting keys (`__proto__`, `constructor`, `prototype`).
|
|
12
|
+
* If processing user-controlled input, sanitize with the appropriate
|
|
13
|
+
* `removePrototype*` helper before calling this function:
|
|
14
|
+
* - `removePrototype` — shallow sanitization of a single object
|
|
15
|
+
* - `removePrototypeDeep` — recursive sanitization of a single object (for deeply nested data)
|
|
16
|
+
* - `removePrototypeMap` — shallow sanitization of an array of objects
|
|
17
|
+
* - `removePrototypeMapDeep` — recursive sanitization of an array of objects (for deeply nested data)
|
|
18
|
+
*
|
|
9
19
|
* @example
|
|
10
20
|
* ```typescript
|
|
11
21
|
* mapKeys({ a: 1, b: 2 }, (_value, key) => key.toUpperCase());
|
|
@@ -12,6 +12,16 @@ exports.mapKeys = void 0;
|
|
|
12
12
|
* @param function_ - The function invoked per key. Receives (value, key).
|
|
13
13
|
* @returns A new object with transformed keys.
|
|
14
14
|
*
|
|
15
|
+
* @remarks
|
|
16
|
+
* **Prototype pollution warning:** This function does not filter out
|
|
17
|
+
* prototype-polluting keys (`__proto__`, `constructor`, `prototype`).
|
|
18
|
+
* If processing user-controlled input, sanitize with the appropriate
|
|
19
|
+
* `removePrototype*` helper before calling this function:
|
|
20
|
+
* - `removePrototype` — shallow sanitization of a single object
|
|
21
|
+
* - `removePrototypeDeep` — recursive sanitization of a single object (for deeply nested data)
|
|
22
|
+
* - `removePrototypeMap` — shallow sanitization of an array of objects
|
|
23
|
+
* - `removePrototypeMapDeep` — recursive sanitization of an array of objects (for deeply nested data)
|
|
24
|
+
*
|
|
15
25
|
* @example
|
|
16
26
|
* ```typescript
|
|
17
27
|
* mapKeys({ a: 1, b: 2 }, (_value, key) => key.toUpperCase());
|
|
@@ -26,7 +36,8 @@ var mapKeys = exports.mapKeys = function mapKeys(object, function_) {
|
|
|
26
36
|
while (index < length) {
|
|
27
37
|
var key = keys[index];
|
|
28
38
|
var value = object[key];
|
|
29
|
-
|
|
39
|
+
var newKey = function_(value, key);
|
|
40
|
+
result[newKey] = value;
|
|
30
41
|
index += 1;
|
|
31
42
|
}
|
|
32
43
|
return result;
|
|
@@ -6,6 +6,16 @@
|
|
|
6
6
|
* @param function_ - The function invoked per value. Receives (value, key).
|
|
7
7
|
* @returns A new object with transformed values.
|
|
8
8
|
*
|
|
9
|
+
* @remarks
|
|
10
|
+
* **Prototype pollution warning:** This function does not filter out
|
|
11
|
+
* prototype-polluting keys (`__proto__`, `constructor`, `prototype`).
|
|
12
|
+
* If processing user-controlled input, sanitize with the appropriate
|
|
13
|
+
* `removePrototype*` helper before calling this function:
|
|
14
|
+
* - `removePrototype` — shallow sanitization of a single object
|
|
15
|
+
* - `removePrototypeDeep` — recursive sanitization of a single object (for deeply nested data)
|
|
16
|
+
* - `removePrototypeMap` — shallow sanitization of an array of objects
|
|
17
|
+
* - `removePrototypeMapDeep` — recursive sanitization of an array of objects (for deeply nested data)
|
|
18
|
+
*
|
|
9
19
|
* @example
|
|
10
20
|
* ```typescript
|
|
11
21
|
* mapValues({ a: 1, b: 2 }, (value) => value * 2);
|
|
@@ -12,6 +12,16 @@ exports.mapValues = void 0;
|
|
|
12
12
|
* @param function_ - The function invoked per value. Receives (value, key).
|
|
13
13
|
* @returns A new object with transformed values.
|
|
14
14
|
*
|
|
15
|
+
* @remarks
|
|
16
|
+
* **Prototype pollution warning:** This function does not filter out
|
|
17
|
+
* prototype-polluting keys (`__proto__`, `constructor`, `prototype`).
|
|
18
|
+
* If processing user-controlled input, sanitize with the appropriate
|
|
19
|
+
* `removePrototype*` helper before calling this function:
|
|
20
|
+
* - `removePrototype` — shallow sanitization of a single object
|
|
21
|
+
* - `removePrototypeDeep` — recursive sanitization of a single object (for deeply nested data)
|
|
22
|
+
* - `removePrototypeMap` — shallow sanitization of an array of objects
|
|
23
|
+
* - `removePrototypeMapDeep` — recursive sanitization of an array of objects (for deeply nested data)
|
|
24
|
+
*
|
|
15
25
|
* @example
|
|
16
26
|
* ```typescript
|
|
17
27
|
* mapValues({ a: 1, b: 2 }, (value) => value * 2);
|
|
@@ -4,5 +4,15 @@ import type { UnionToIntersection } from "../types/logic/unionToIntersection";
|
|
|
4
4
|
* @param target - The target object to merge into
|
|
5
5
|
* @param sources - The source objects to merge from
|
|
6
6
|
* @returns The merged object
|
|
7
|
+
*
|
|
8
|
+
* @remarks
|
|
9
|
+
* **Prototype pollution warning:** This function does not filter out
|
|
10
|
+
* prototype-polluting keys (`__proto__`, `constructor`, `prototype`).
|
|
11
|
+
* If processing user-controlled input, sanitize with the appropriate
|
|
12
|
+
* `removePrototype*` helper before calling this function:
|
|
13
|
+
* - `removePrototype` — shallow sanitization of a single object
|
|
14
|
+
* - `removePrototypeDeep` — recursive sanitization of a single object (for deeply nested data)
|
|
15
|
+
* - `removePrototypeMap` — shallow sanitization of an array of objects
|
|
16
|
+
* - `removePrototypeMapDeep` — recursive sanitization of an array of objects (for deeply nested data)
|
|
7
17
|
*/
|
|
8
18
|
export declare const merge: <T extends Record<string, unknown>, U extends Record<string, unknown>[]>(target: T, ...sources: U) => T & UnionToIntersection<U[number]>;
|
|
@@ -9,10 +9,28 @@ exports.merge = void 0;
|
|
|
9
9
|
* @param target - The target object to merge into
|
|
10
10
|
* @param sources - The source objects to merge from
|
|
11
11
|
* @returns The merged object
|
|
12
|
+
*
|
|
13
|
+
* @remarks
|
|
14
|
+
* **Prototype pollution warning:** This function does not filter out
|
|
15
|
+
* prototype-polluting keys (`__proto__`, `constructor`, `prototype`).
|
|
16
|
+
* If processing user-controlled input, sanitize with the appropriate
|
|
17
|
+
* `removePrototype*` helper before calling this function:
|
|
18
|
+
* - `removePrototype` — shallow sanitization of a single object
|
|
19
|
+
* - `removePrototypeDeep` — recursive sanitization of a single object (for deeply nested data)
|
|
20
|
+
* - `removePrototypeMap` — shallow sanitization of an array of objects
|
|
21
|
+
* - `removePrototypeMapDeep` — recursive sanitization of an array of objects (for deeply nested data)
|
|
12
22
|
*/
|
|
13
23
|
var merge = exports.merge = function merge(target) {
|
|
24
|
+
var result = {};
|
|
14
25
|
for (var _len = arguments.length, sources = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
15
26
|
sources[_key - 1] = arguments[_key];
|
|
16
27
|
}
|
|
17
|
-
|
|
28
|
+
for (var _i = 0, _arr = [target].concat(sources); _i < _arr.length; _i++) {
|
|
29
|
+
var object = _arr[_i];
|
|
30
|
+
for (var _i2 = 0, _Object$keys = Object.keys(object); _i2 < _Object$keys.length; _i2++) {
|
|
31
|
+
var key = _Object$keys[_i2];
|
|
32
|
+
result[key] = object[key];
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return result;
|
|
18
36
|
};
|
|
@@ -4,5 +4,15 @@ import type { UnionToIntersection } from "../types/logic/unionToIntersection";
|
|
|
4
4
|
* @param target - The target object to merge into
|
|
5
5
|
* @param sources - The source objects to merge from
|
|
6
6
|
* @returns The deeply merged object
|
|
7
|
+
*
|
|
8
|
+
* @remarks
|
|
9
|
+
* **Prototype pollution warning:** This function does not filter out
|
|
10
|
+
* prototype-polluting keys (`__proto__`, `constructor`, `prototype`).
|
|
11
|
+
* If processing user-controlled input, sanitize with the appropriate
|
|
12
|
+
* `removePrototype*` helper before calling this function:
|
|
13
|
+
* - `removePrototype` — shallow sanitization of a single object
|
|
14
|
+
* - `removePrototypeDeep` — recursive sanitization of a single object (for deeply nested data)
|
|
15
|
+
* - `removePrototypeMap` — shallow sanitization of an array of objects
|
|
16
|
+
* - `removePrototypeMapDeep` — recursive sanitization of an array of objects (for deeply nested data)
|
|
7
17
|
*/
|
|
8
18
|
export declare const mergeDeep: <T extends Record<string, unknown>, U extends Record<string, unknown>[]>(target: T, ...sources: U) => T & UnionToIntersection<U[number]>;
|
|
@@ -11,33 +11,49 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
11
11
|
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
12
12
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
13
13
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
for (var _len = arguments.length, sources = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
22
|
-
sources[_key - 1] = arguments[_key];
|
|
23
|
-
}
|
|
24
|
-
if (sources.length === 0) {
|
|
14
|
+
// Performance: use an index parameter instead of Array.shift() to advance
|
|
15
|
+
// through sources. shift() is O(n) because it re-indexes every remaining
|
|
16
|
+
// element, making the overall merge O(n²) in the number of sources.
|
|
17
|
+
// An index makes each step O(1) and avoids mutating the sources array.
|
|
18
|
+
var _mergeDeepInternal = function mergeDeepInternal(target, sources, depth) {
|
|
19
|
+
var sourceIndex = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
|
|
20
|
+
if (sourceIndex >= sources.length) {
|
|
25
21
|
return target;
|
|
26
22
|
}
|
|
27
|
-
var source = sources
|
|
23
|
+
var source = sources[sourceIndex];
|
|
28
24
|
if ((0, _isPlainObject.isPlainObject)(target) && (0, _isPlainObject.isPlainObject)(source)) {
|
|
29
25
|
var result = _objectSpread({}, target);
|
|
30
26
|
for (var key in source) {
|
|
31
|
-
if (key === "__proto__" || key === "constructor" || key === "prototype") {
|
|
32
|
-
continue;
|
|
33
|
-
}
|
|
34
27
|
if (Object.hasOwn(source, key)) {
|
|
35
28
|
var sourceValue = source[key];
|
|
36
29
|
var targetValue = result[key];
|
|
37
|
-
result[key] = (0, _isPlainObject.isPlainObject)(targetValue) && (0, _isPlainObject.isPlainObject)(sourceValue) ?
|
|
30
|
+
result[key] = (0, _isPlainObject.isPlainObject)(targetValue) && (0, _isPlainObject.isPlainObject)(sourceValue) ? _mergeDeepInternal(targetValue, [sourceValue], depth + 1) : sourceValue;
|
|
38
31
|
}
|
|
39
32
|
}
|
|
40
|
-
return
|
|
33
|
+
return _mergeDeepInternal(result, sources, depth + 1, sourceIndex + 1);
|
|
34
|
+
}
|
|
35
|
+
return _mergeDeepInternal(source, sources, depth + 1, sourceIndex + 1);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Deeply merges multiple objects into a single object
|
|
40
|
+
* @param target - The target object to merge into
|
|
41
|
+
* @param sources - The source objects to merge from
|
|
42
|
+
* @returns The deeply merged object
|
|
43
|
+
*
|
|
44
|
+
* @remarks
|
|
45
|
+
* **Prototype pollution warning:** This function does not filter out
|
|
46
|
+
* prototype-polluting keys (`__proto__`, `constructor`, `prototype`).
|
|
47
|
+
* If processing user-controlled input, sanitize with the appropriate
|
|
48
|
+
* `removePrototype*` helper before calling this function:
|
|
49
|
+
* - `removePrototype` — shallow sanitization of a single object
|
|
50
|
+
* - `removePrototypeDeep` — recursive sanitization of a single object (for deeply nested data)
|
|
51
|
+
* - `removePrototypeMap` — shallow sanitization of an array of objects
|
|
52
|
+
* - `removePrototypeMapDeep` — recursive sanitization of an array of objects (for deeply nested data)
|
|
53
|
+
*/
|
|
54
|
+
var mergeDeep = exports.mergeDeep = function mergeDeep(target) {
|
|
55
|
+
for (var _len = arguments.length, sources = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
56
|
+
sources[_key - 1] = arguments[_key];
|
|
41
57
|
}
|
|
42
|
-
return
|
|
58
|
+
return _mergeDeepInternal(target, sources, 0);
|
|
43
59
|
};
|
|
@@ -9,6 +9,16 @@ import type { PickDeepKey } from "../types/object/pickDeepKey";
|
|
|
9
9
|
* @param {...K[]} keys - Property keys to extract. Can use dot notation for nested properties.
|
|
10
10
|
* @returns {PickDeep<T, K>} A new object containing only the specified properties.
|
|
11
11
|
*
|
|
12
|
+
* @remarks
|
|
13
|
+
* **Prototype pollution warning:** This function does not filter out
|
|
14
|
+
* prototype-polluting keys (`__proto__`, `constructor`, `prototype`).
|
|
15
|
+
* If processing user-controlled input, sanitize with the appropriate
|
|
16
|
+
* `removePrototype*` helper before calling this function:
|
|
17
|
+
* - `removePrototype` — shallow sanitization of a single object
|
|
18
|
+
* - `removePrototypeDeep` — recursive sanitization of a single object (for deeply nested data)
|
|
19
|
+
* - `removePrototypeMap` — shallow sanitization of an array of objects
|
|
20
|
+
* - `removePrototypeMapDeep` — recursive sanitization of an array of objects (for deeply nested data)
|
|
21
|
+
*
|
|
12
22
|
* @example
|
|
13
23
|
* ```typescript
|
|
14
24
|
* const obj = { a: { b: { c: 1, d: 2 }, e: 3 }, f: 4 };
|
|
@@ -21,6 +21,16 @@ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length)
|
|
|
21
21
|
* @param {...K[]} keys - Property keys to extract. Can use dot notation for nested properties.
|
|
22
22
|
* @returns {PickDeep<T, K>} A new object containing only the specified properties.
|
|
23
23
|
*
|
|
24
|
+
* @remarks
|
|
25
|
+
* **Prototype pollution warning:** This function does not filter out
|
|
26
|
+
* prototype-polluting keys (`__proto__`, `constructor`, `prototype`).
|
|
27
|
+
* If processing user-controlled input, sanitize with the appropriate
|
|
28
|
+
* `removePrototype*` helper before calling this function:
|
|
29
|
+
* - `removePrototype` — shallow sanitization of a single object
|
|
30
|
+
* - `removePrototypeDeep` — recursive sanitization of a single object (for deeply nested data)
|
|
31
|
+
* - `removePrototypeMap` — shallow sanitization of an array of objects
|
|
32
|
+
* - `removePrototypeMapDeep` — recursive sanitization of an array of objects (for deeply nested data)
|
|
33
|
+
*
|
|
24
34
|
* @example
|
|
25
35
|
* ```typescript
|
|
26
36
|
* const obj = { a: { b: { c: 1, d: 2 }, e: 3 }, f: 4 };
|
|
@@ -48,9 +58,6 @@ var pickDeep = exports.pickDeep = function pickDeep(object) {
|
|
|
48
58
|
var _step$value = _slicedToArray(_step.value, 2),
|
|
49
59
|
index = _step$value[0],
|
|
50
60
|
part = _step$value[1];
|
|
51
|
-
if (part === "__proto__" || part === "constructor" || part === "prototype") {
|
|
52
|
-
continue;
|
|
53
|
-
}
|
|
54
61
|
if (current && _typeof(current) === "object" && part in current) {
|
|
55
62
|
if (index === parts.length - 1) {
|
|
56
63
|
target[part] = current[part];
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a new object with the same properties as the given object, but with the prototype polluting properties removed.
|
|
3
|
+
* ("__proto__", "constructor", "prototype" are excluded from the shallow copy)
|
|
4
|
+
*
|
|
5
|
+
* @param object - The object to remove the prototype polluting properties from.
|
|
6
|
+
* @returns A new object with the prototype polluting properties removed.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* const obj = JSON.parse('{"__proto__":{"polluted":true},"a":1,"b":2}');
|
|
11
|
+
* const safeObj = removePrototype(obj);
|
|
12
|
+
* // safeObj is { a: 1, b: 2 } and "__proto__" is removed
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export declare const removePrototype: <T extends Record<string, unknown>>(object: T) => Omit<T, "__proto__" | "constructor" | "prototype">;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.removePrototype = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* Creates a new object with the same properties as the given object, but with the prototype polluting properties removed.
|
|
9
|
+
* ("__proto__", "constructor", "prototype" are excluded from the shallow copy)
|
|
10
|
+
*
|
|
11
|
+
* @param object - The object to remove the prototype polluting properties from.
|
|
12
|
+
* @returns A new object with the prototype polluting properties removed.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* const obj = JSON.parse('{"__proto__":{"polluted":true},"a":1,"b":2}');
|
|
17
|
+
* const safeObj = removePrototype(obj);
|
|
18
|
+
* // safeObj is { a: 1, b: 2 } and "__proto__" is removed
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
var removePrototype = exports.removePrototype = function removePrototype(object) {
|
|
22
|
+
var result = Object.create(null);
|
|
23
|
+
var keys = Object.keys(object);
|
|
24
|
+
for (var _i = 0, _keys = keys; _i < _keys.length; _i++) {
|
|
25
|
+
var key = _keys[_i];
|
|
26
|
+
if (key !== "__proto__" && key !== "constructor" && key !== "prototype") {
|
|
27
|
+
result[key] = object[key];
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return result;
|
|
31
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a new object with the same properties as the given object, but with
|
|
3
|
+
* the prototype polluting properties removed recursively.
|
|
4
|
+
* ("__proto__", "constructor", "prototype" are excluded from nested objects
|
|
5
|
+
* and objects inside arrays)
|
|
6
|
+
*
|
|
7
|
+
* @param object - The object to remove the prototype polluting properties from.
|
|
8
|
+
* @returns A new object with the prototype polluting properties removed
|
|
9
|
+
* recursively.
|
|
10
|
+
*/
|
|
11
|
+
export declare const removePrototypeDeep: <T extends Record<string, unknown>>(object: T) => T;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.removePrototypeDeep = void 0;
|
|
7
|
+
var _isPlainObject = require("../Object/isPlainObject");
|
|
8
|
+
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
|
|
9
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
10
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
11
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
12
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
13
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
14
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
15
|
+
/**
|
|
16
|
+
* Creates a new object with the same properties as the given object, but with
|
|
17
|
+
* the prototype polluting properties removed recursively.
|
|
18
|
+
* ("__proto__", "constructor", "prototype" are excluded from nested objects
|
|
19
|
+
* and objects inside arrays)
|
|
20
|
+
*
|
|
21
|
+
* @param object - The object to remove the prototype polluting properties from.
|
|
22
|
+
* @returns A new object with the prototype polluting properties removed
|
|
23
|
+
* recursively.
|
|
24
|
+
*/
|
|
25
|
+
var removePrototypeDeep = exports.removePrototypeDeep = function removePrototypeDeep(object) {
|
|
26
|
+
var result = Object.create(null);
|
|
27
|
+
var stack = [[object, result]];
|
|
28
|
+
while (stack.length > 0) {
|
|
29
|
+
// biome-ignore lint/style/noNonNullAssertion: stack.length > 0 guarantees pop() returns a value
|
|
30
|
+
var _ref = stack.pop(),
|
|
31
|
+
_ref2 = _slicedToArray(_ref, 2),
|
|
32
|
+
source = _ref2[0],
|
|
33
|
+
destination = _ref2[1];
|
|
34
|
+
if (Array.isArray(source)) {
|
|
35
|
+
var array = destination;
|
|
36
|
+
var _iterator = _createForOfIteratorHelper(source),
|
|
37
|
+
_step;
|
|
38
|
+
try {
|
|
39
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
40
|
+
var value = _step.value;
|
|
41
|
+
if (Array.isArray(value)) {
|
|
42
|
+
var child = [];
|
|
43
|
+
array.push(child);
|
|
44
|
+
stack.push([value, child]);
|
|
45
|
+
} else if ((0, _isPlainObject.isPlainObject)(value)) {
|
|
46
|
+
var _child = Object.create(null);
|
|
47
|
+
array.push(_child);
|
|
48
|
+
stack.push([value, _child]);
|
|
49
|
+
} else {
|
|
50
|
+
array.push(value);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
} catch (err) {
|
|
54
|
+
_iterator.e(err);
|
|
55
|
+
} finally {
|
|
56
|
+
_iterator.f();
|
|
57
|
+
}
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
var target = destination;
|
|
61
|
+
for (var _i = 0, _Object$keys = Object.keys(source); _i < _Object$keys.length; _i++) {
|
|
62
|
+
var key = _Object$keys[_i];
|
|
63
|
+
if (key === "__proto__" || key === "constructor" || key === "prototype") {
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
var _value = source[key];
|
|
67
|
+
if (Array.isArray(_value)) {
|
|
68
|
+
var _child2 = [];
|
|
69
|
+
target[key] = _child2;
|
|
70
|
+
stack.push([_value, _child2]);
|
|
71
|
+
} else if ((0, _isPlainObject.isPlainObject)(_value)) {
|
|
72
|
+
var _child3 = Object.create(null);
|
|
73
|
+
target[key] = _child3;
|
|
74
|
+
stack.push([_value, _child3]);
|
|
75
|
+
} else {
|
|
76
|
+
target[key] = _value;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return result;
|
|
81
|
+
};
|