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
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { average } from "./average";
|
|
2
|
+
import { addition } from "../Math/addition";
|
|
3
|
+
import { division } from "../Math/division";
|
|
2
4
|
import { multiplication } from "../Math/multiplication";
|
|
3
5
|
import { subtract } from "../Math/subtract";
|
|
4
6
|
/**
|
|
@@ -13,15 +15,18 @@ import { subtract } from "../Math/subtract";
|
|
|
13
15
|
* while a high standard deviation indicates that the values are spread out over a wider range.
|
|
14
16
|
*/
|
|
15
17
|
export const standardDeviation = (values) => {
|
|
18
|
+
if (values.length === 0) {
|
|
19
|
+
return 0;
|
|
20
|
+
}
|
|
16
21
|
const avg = average(values);
|
|
17
|
-
//
|
|
18
|
-
|
|
22
|
+
// Accumulate sum of squared differences in a single pass,
|
|
23
|
+
// avoiding an intermediate array allocation and extra traversal
|
|
24
|
+
let sumSquareDiffs = 0;
|
|
25
|
+
for (const value of values) {
|
|
19
26
|
const diff = subtract(value, avg);
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const avgSquareDiff = average(squareDiffs);
|
|
24
|
-
// Return the square root of the mean squared differences
|
|
27
|
+
sumSquareDiffs = addition(sumSquareDiffs, multiplication(diff, diff));
|
|
28
|
+
}
|
|
29
|
+
const avgSquareDiff = division(sumSquareDiffs, values.length);
|
|
25
30
|
return Math.sqrt(avgSquareDiff);
|
|
26
31
|
};
|
|
27
32
|
//# sourceMappingURL=standardDeviation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standardDeviation.js","sourceRoot":"","sources":["../../src/Math/standardDeviation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3C;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,MAAgB,EAAU,EAAE;IAC5D,MAAM,
|
|
1
|
+
{"version":3,"file":"standardDeviation.js","sourceRoot":"","sources":["../../src/Math/standardDeviation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3C;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,MAAgB,EAAU,EAAE;IAC5D,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACxB,OAAO,CAAC,CAAC;IACX,CAAC;IAED,MAAM,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAE5B,0DAA0D;IAC1D,gEAAgE;IAChE,IAAI,cAAc,GAAG,CAAC,CAAC;IACvB,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,MAAM,IAAI,GAAG,QAAQ,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QAClC,cAAc,GAAG,QAAQ,CAAC,cAAc,EAAE,cAAc,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;IACxE,CAAC;IAED,MAAM,aAAa,GAAG,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IAE9D,OAAO,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;AAClC,CAAC,CAAC"}
|
package/module/Math/subtract.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { addition } from "./addition";
|
|
1
2
|
import { getDecimalLength } from "./getDecimalLength";
|
|
2
3
|
import { max } from "./max";
|
|
3
4
|
import { multiplication } from "./multiplication";
|
|
@@ -14,14 +15,9 @@ import { multiplication } from "./multiplication";
|
|
|
14
15
|
* are subtracted from it.
|
|
15
16
|
*/
|
|
16
17
|
export const subtract = (...numbers) => {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
// Get the power of 10 based on the maximum decimal places
|
|
22
|
-
const z = 10 ** max(getDecimalLength(accumulator), getDecimalLength(current));
|
|
23
|
-
// Scale to integers, subtract, then scale back to original decimal places
|
|
24
|
-
return (multiplication(accumulator, z) - multiplication(current, z)) / z;
|
|
25
|
-
}, 0);
|
|
18
|
+
const [first, ...rest] = numbers;
|
|
19
|
+
const restSum = addition(...rest);
|
|
20
|
+
const z = 10 ** max(getDecimalLength(first), getDecimalLength(restSum));
|
|
21
|
+
return (multiplication(first, z) - multiplication(restSum, z)) / z;
|
|
26
22
|
};
|
|
27
23
|
//# sourceMappingURL=subtract.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subtract.js","sourceRoot":"","sources":["../../src/Math/subtract.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5B,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD;;;;;;;;;;;GAWG;AAEH,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,GAAG,OAAiB,EAAU,EAAE;IACvD,
|
|
1
|
+
{"version":3,"file":"subtract.js","sourceRoot":"","sources":["../../src/Math/subtract.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5B,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD;;;;;;;;;;;GAWG;AAEH,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,GAAG,OAAiB,EAAU,EAAE;IACvD,MAAM,CAAC,KAAK,EAAE,GAAG,IAAI,CAAC,GAAG,OAAO,CAAC;IACjC,MAAM,OAAO,GAAG,QAAQ,CAAC,GAAG,IAAI,CAAC,CAAC;IAClC,MAAM,CAAC,GAAG,EAAE,IAAI,GAAG,CAAC,gBAAgB,CAAC,KAAK,CAAC,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAC;IACxE,OAAO,CAAC,cAAc,CAAC,KAAK,EAAE,CAAC,CAAC,GAAG,cAAc,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;AACrE,CAAC,CAAC"}
|
|
@@ -11,5 +11,15 @@
|
|
|
11
11
|
* cloned.b.c = 99;
|
|
12
12
|
* original.b.c; // still 2
|
|
13
13
|
* ```
|
|
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
|
export declare const deepClone: <T>(value: T) => T;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Recursively clones a value.
|
|
3
3
|
*/
|
|
4
|
-
const cloneValue = (value) => {
|
|
4
|
+
const cloneValue = (value, depth) => {
|
|
5
5
|
if (value === null || typeof value !== "object") {
|
|
6
6
|
return value;
|
|
7
7
|
}
|
|
8
8
|
if (Array.isArray(value)) {
|
|
9
9
|
const result = [];
|
|
10
10
|
for (const element of value) {
|
|
11
|
-
result.push(cloneValue(element));
|
|
11
|
+
result.push(cloneValue(element, depth + 1));
|
|
12
12
|
}
|
|
13
13
|
return result;
|
|
14
14
|
}
|
|
@@ -21,21 +21,21 @@ const cloneValue = (value) => {
|
|
|
21
21
|
if (value instanceof Map) {
|
|
22
22
|
const result = new Map();
|
|
23
23
|
for (const [k, v] of value) {
|
|
24
|
-
result.set(cloneValue(k), cloneValue(v));
|
|
24
|
+
result.set(cloneValue(k, depth + 1), cloneValue(v, depth + 1));
|
|
25
25
|
}
|
|
26
26
|
return result;
|
|
27
27
|
}
|
|
28
28
|
if (value instanceof Set) {
|
|
29
29
|
const result = new Set();
|
|
30
30
|
for (const v of value) {
|
|
31
|
-
result.add(cloneValue(v));
|
|
31
|
+
result.add(cloneValue(v, depth + 1));
|
|
32
32
|
}
|
|
33
33
|
return result;
|
|
34
34
|
}
|
|
35
35
|
// Plain object
|
|
36
36
|
const result = {};
|
|
37
37
|
for (const key of Object.keys(value)) {
|
|
38
|
-
result[key] = cloneValue(value[key]);
|
|
38
|
+
result[key] = cloneValue(value[key], depth + 1);
|
|
39
39
|
}
|
|
40
40
|
return result;
|
|
41
41
|
};
|
|
@@ -52,11 +52,21 @@ const cloneValue = (value) => {
|
|
|
52
52
|
* cloned.b.c = 99;
|
|
53
53
|
* original.b.c; // still 2
|
|
54
54
|
* ```
|
|
55
|
+
*
|
|
56
|
+
* @remarks
|
|
57
|
+
* **Prototype pollution warning:** This function does not filter out
|
|
58
|
+
* prototype-polluting keys (`__proto__`, `constructor`, `prototype`).
|
|
59
|
+
* If processing user-controlled input, sanitize with the appropriate
|
|
60
|
+
* `removePrototype*` helper before calling this function:
|
|
61
|
+
* - `removePrototype` — shallow sanitization of a single object
|
|
62
|
+
* - `removePrototypeDeep` — recursive sanitization of a single object (for deeply nested data)
|
|
63
|
+
* - `removePrototypeMap` — shallow sanitization of an array of objects
|
|
64
|
+
* - `removePrototypeMapDeep` — recursive sanitization of an array of objects (for deeply nested data)
|
|
55
65
|
*/
|
|
56
66
|
export const deepClone = (value) => {
|
|
57
67
|
if (value === null || typeof value !== "object") {
|
|
58
68
|
return value;
|
|
59
69
|
}
|
|
60
|
-
return cloneValue(value);
|
|
70
|
+
return cloneValue(value, 0);
|
|
61
71
|
};
|
|
62
72
|
//# sourceMappingURL=deepClone.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deepClone.js","sourceRoot":"","sources":["../../src/Object/deepClone.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,UAAU,GAAG,CAAC,KA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AG,EAAE,CAAC;QACzB,KAAK,MAAM,CAAC,IAAI,KAAK,EAAE,CAAC;YACtB,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC;QACvC,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,eAAe;IACf,MAAM,MAAM,GAA4B,EAAE,CAAC;IAC3C,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,KAAgC,CAAC,EAAE,CAAC;QAChE,MAAM,CAAC,GAAG,CAAC,GAAG,UAAU,CACrB,KAAiC,CAAC,GAAG,CAAC,EACvC,KAAK,GAAG,CAAC,CACV,CAAC;IACJ,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAI,KAAQ,EAAK,EAAE;IAC1C,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAChD,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,UAAU,CAAC,KAAK,EAAE,CAAC,CAAM,CAAC;AACnC,CAAC,CAAC"}
|
|
@@ -11,6 +11,16 @@
|
|
|
11
11
|
* @param {...Record<string, unknown>[]} objects - Additional objects to compare.
|
|
12
12
|
* @returns {Partial<T>} Object containing only the key-value pairs shared by all inputs.
|
|
13
13
|
*
|
|
14
|
+
* @remarks
|
|
15
|
+
* **Prototype pollution warning:** This function does not filter out
|
|
16
|
+
* prototype-polluting keys (`__proto__`, `constructor`, `prototype`).
|
|
17
|
+
* If processing user-controlled input, sanitize with the appropriate
|
|
18
|
+
* `removePrototype*` helper before calling this function:
|
|
19
|
+
* - `removePrototype` — shallow sanitization of a single object
|
|
20
|
+
* - `removePrototypeDeep` — recursive sanitization of a single object (for deeply nested data)
|
|
21
|
+
* - `removePrototypeMap` — shallow sanitization of an array of objects
|
|
22
|
+
* - `removePrototypeMapDeep` — recursive sanitization of an array of objects (for deeply nested data)
|
|
23
|
+
*
|
|
14
24
|
* @example
|
|
15
25
|
* ```typescript
|
|
16
26
|
* getObjectsCommon({ a: 1, b: 2 }, { a: 1, c: 3 });
|
|
@@ -12,6 +12,16 @@ import { isPlainObject } from "../Object/isPlainObject";
|
|
|
12
12
|
* @param {...Record<string, unknown>[]} objects - Additional objects to compare.
|
|
13
13
|
* @returns {Partial<T>} Object containing only the key-value pairs shared by all inputs.
|
|
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
|
* getObjectsCommon({ a: 1, b: 2 }, { a: 1, c: 3 });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getObjectsCommon.js","sourceRoot":"","sources":["../../src/Object/getObjectsCommon.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEvD
|
|
1
|
+
{"version":3,"file":"getObjectsCommon.js","sourceRoot":"","sources":["../../src/Object/getObjectsCommon.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC9B,MAAS,EACT,GAA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,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;QACnD,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC"}
|
|
@@ -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 });
|
|
@@ -14,6 +14,16 @@ import { isPlainObject } from "../Object/isPlainObject";
|
|
|
14
14
|
* @param {...Record<string, unknown>[]} objects - Additional objects to compare.
|
|
15
15
|
* @returns {Partial<T>} Object containing only key-value pairs unique to one input.
|
|
16
16
|
*
|
|
17
|
+
* @remarks
|
|
18
|
+
* **Prototype pollution warning:** This function does not filter out
|
|
19
|
+
* prototype-polluting keys (`__proto__`, `constructor`, `prototype`).
|
|
20
|
+
* If processing user-controlled input, sanitize with the appropriate
|
|
21
|
+
* `removePrototype*` helper before calling this function:
|
|
22
|
+
* - `removePrototype` — shallow sanitization of a single object
|
|
23
|
+
* - `removePrototypeDeep` — recursive sanitization of a single object (for deeply nested data)
|
|
24
|
+
* - `removePrototypeMap` — shallow sanitization of an array of objects
|
|
25
|
+
* - `removePrototypeMapDeep` — recursive sanitization of an array of objects (for deeply nested data)
|
|
26
|
+
*
|
|
17
27
|
* @example
|
|
18
28
|
* ```typescript
|
|
19
29
|
* getObjectsDiff({ a: 1, b: 2 }, { b: 2, c: 3 });
|
|
@@ -58,13 +68,14 @@ export const getObjectsDiff = (object, ...objects) => {
|
|
|
58
68
|
}
|
|
59
69
|
let lastUniqueValue;
|
|
60
70
|
let hasUnique = false;
|
|
71
|
+
// Count occurrences in a single pass using a Map — O(n) instead of O(n²).
|
|
72
|
+
// Map keys use SameValueZero which matches === for all values except NaN,
|
|
73
|
+
// an acceptable trade-off for object-diff use cases.
|
|
74
|
+
const valueCounts = new Map();
|
|
61
75
|
for (const value of values) {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
count++;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
76
|
+
valueCounts.set(value, (valueCounts.get(value) ?? 0) + 1);
|
|
77
|
+
}
|
|
78
|
+
for (const [value, count] of valueCounts) {
|
|
68
79
|
if (count === 1) {
|
|
69
80
|
lastUniqueValue = value;
|
|
70
81
|
hasUnique = true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getObjectsDiff.js","sourceRoot":"","sources":["../../src/Object/getObjectsDiff.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEvD
|
|
1
|
+
{"version":3,"file":"getObjectsDiff.js","sourceRoot":"","sources":["../../src/Object/getObjectsDiff.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAC5B,MAAS,EACT,GAAG,OAAkC,EACzB,EAAE;IACd,MAAM,UAAU,GAAG,CAAC,MAAiC,EAAE,GAAG,OAAO,CAAC,CAAC;IAEnE,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,E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CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAClC,MAAkC,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC;YACpD,CAAC;YACD,SAAS;QACX,CAAC;QAED,IAAI,eAAwB,CAAC;QAC7B,IAAI,SAAS,GAAG,KAAK,CAAC;QAEtB,0EAA0E;QAC1E,0EAA0E;QAC1E,qDAAqD;QACrD,MAAM,WAAW,GAAG,IAAI,GAAG,EAAmB,CAAC;QAC/C,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;YAC3B,WAAW,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;QAC5D,CAAC;QACD,KAAK,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,WAAW,EAAE,CAAC;YACzC,IAAI,KAAK,KAAK,CAAC,EAAE,CAAC;gBAChB,eAAe,GAAG,KAAK,CAAC;gBACxB,SAAS,GAAG,IAAI,CAAC;YACnB,CAAC;QACH,CAAC;QAED,IAAI,SAAS,EAAE,CAAC;YACb,MAAkC,CAAC,GAAG,CAAC,GAAG,eAAe,CAAC;QAC7D,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC"}
|
package/module/Object/has.d.ts
CHANGED
|
@@ -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/Object/has.js
CHANGED
|
@@ -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 const has = (object, path) => {
|
|
11
21
|
const localPath = typeof path === "string" ? path.split(".") : path;
|
package/module/Object/has.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"has.js","sourceRoot":"","sources":["../../src/Object/has.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"has.js","sourceRoot":"","sources":["../../src/Object/has.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,MAAM,GAAG,GAAG,CACjB,MAAS,EACT,IAAuB,EACd,EAAE;IACX,MAAM,SAAS,GAAG,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACpE,IAAI,OAAO,GAAG,EAAE,GAAG,MAAM,EAAE,CAAC;IAC5B,KAAK,MAAM,GAAG,IAAI,SAAS,EAAE,CAAC;QAC5B,IAAI,OAAO,IAAI,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,GAAG,CAAC,EAAE,CAAC;YACpD,OAAO,KAAK,CAAC;QACf,CAAC;QACD,OAAO,GAAG,OAAO,CAAC,GAAG,CAAM,CAAC;IAC9B,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC,CAAC"}
|
package/module/Object/index.d.ts
CHANGED
|
@@ -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";
|
package/module/Object/index.js
CHANGED
|
@@ -12,4 +12,8 @@ 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";
|
|
15
19
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Object/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,OAAO,CAAC;AACtB,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Object/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,OAAO,CAAC;AACtB,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC"}
|
package/module/Object/keyBy.d.ts
CHANGED
|
@@ -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 {};
|
package/module/Object/keyBy.js
CHANGED
|
@@ -2,6 +2,16 @@
|
|
|
2
2
|
* Creates an object composed of keys generated from the results of running each element of collection through iteratee
|
|
3
3
|
* @param collection The collection to iterate over
|
|
4
4
|
* @param iteratee The iteratee function or property name to generate the key
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* **Prototype pollution warning:** This function does not filter out
|
|
8
|
+
* prototype-polluting keys (`__proto__`, `constructor`, `prototype`).
|
|
9
|
+
* If processing user-controlled input, sanitize with the appropriate
|
|
10
|
+
* `removePrototype*` helper before calling this function:
|
|
11
|
+
* - `removePrototype` — shallow sanitization of a single object
|
|
12
|
+
* - `removePrototypeDeep` — recursive sanitization of a single object (for deeply nested data)
|
|
13
|
+
* - `removePrototypeMap` — shallow sanitization of an array of objects
|
|
14
|
+
* - `removePrototypeMapDeep` — recursive sanitization of an array of objects (for deeply nested data)
|
|
5
15
|
*/
|
|
6
16
|
export function keyBy(collection, iteratee) {
|
|
7
17
|
const getKey = normalizeIteratee(iteratee);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keyBy.js","sourceRoot":"","sources":["../../src/Object/keyBy.ts"],"names":[],"mappings":"AAIA
|
|
1
|
+
{"version":3,"file":"keyBy.js","sourceRoot":"","sources":["../../src/Object/keyBy.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,KAAK,CACnB,UAAyC,EACzC,QAAsB;IAEtB,MAAM,MAAM,GAAG,iBAAiB,CAAC,QAAQ,CAAC,CAAC;IAC3C,MAAM,MAAM,GAA4B,EAAE,CAAC;IAE3C,IAAI,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;QAC9B,KAAK,MAAM,KAAK,IAAI,UAAU,EAAE,CAAC;YAC/B,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;YAC1B,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;QACtB,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,CAAC;QAC9C,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;QAC1B,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IACtB,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;GAEG;AACH,SAAS,iBAAiB,CAAI,QAAsB;IAClD,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,KAAgC,CAAC;IACrD,CAAC;IACD,IAAI,OAAO,QAAQ,KAAK,UAAU,EAAE,CAAC;QACnC,OAAO,QAAQ,CAAC;IAClB,CAAC;IACD,OAAO,CAAC,MAAS,EAAE,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAiB,CAAC;AACzD,CAAC"}
|
|
@@ -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());
|
package/module/Object/mapKeys.js
CHANGED
|
@@ -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());
|
|
@@ -20,7 +30,8 @@ export const mapKeys = (object, function_) => {
|
|
|
20
30
|
while (index < length) {
|
|
21
31
|
const key = keys[index];
|
|
22
32
|
const value = object[key];
|
|
23
|
-
|
|
33
|
+
const newKey = function_(value, key);
|
|
34
|
+
result[newKey] = value;
|
|
24
35
|
index += 1;
|
|
25
36
|
}
|
|
26
37
|
return result;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapKeys.js","sourceRoot":"","sources":["../../src/Object/mapKeys.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"mapKeys.js","sourceRoot":"","sources":["../../src/Object/mapKeys.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,CACrB,MAAS,EACT,SAAqD,EACzB,EAAE;IAC9B,MAAM,MAAM,GAA+B,EAAE,CAAC;IAC9C,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACjC,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;IAC3B,IAAI,KAAK,GAAG,CAAC,CAAC;IAEd,OAAO,KAAK,GAAG,MAAM,EAAE,CAAC;QACtB,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;QACxB,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAe,CAAC;QACxC,MAAM,MAAM,GAAG,SAAS,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QACrC,MAAM,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC;QACvB,KAAK,IAAI,CAAC,CAAC;IACb,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC"}
|
|
@@ -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);
|
|
@@ -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);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapValues.js","sourceRoot":"","sources":["../../src/Object/mapValues.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"mapValues.js","sourceRoot":"","sources":["../../src/Object/mapValues.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CACvB,MAAS,EACT,SAAgD,EAC5B,EAAE;IACtB,MAAM,MAAM,GAAG,EAAuB,CAAC;IACvC,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACjC,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;IAC3B,IAAI,KAAK,GAAG,CAAC,CAAC;IAEd,OAAO,KAAK,GAAG,MAAM,EAAE,CAAC;QACtB,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;QACxB,MAAM,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,MAAM,CAAC,GAAG,CAAe,EAAE,GAAG,CAAC,CAAC;QACxD,KAAK,IAAI,CAAC,CAAC;IACb,CAAC;IAED,OAAO,MAA4B,CAAC;AACtC,CAAC,CAAC"}
|
package/module/Object/merge.d.ts
CHANGED
|
@@ -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]>;
|
package/module/Object/merge.js
CHANGED
|
@@ -3,8 +3,24 @@
|
|
|
3
3
|
* @param target - The target object to merge into
|
|
4
4
|
* @param sources - The source objects to merge from
|
|
5
5
|
* @returns The merged object
|
|
6
|
+
*
|
|
7
|
+
* @remarks
|
|
8
|
+
* **Prototype pollution warning:** This function does not filter out
|
|
9
|
+
* prototype-polluting keys (`__proto__`, `constructor`, `prototype`).
|
|
10
|
+
* If processing user-controlled input, sanitize with the appropriate
|
|
11
|
+
* `removePrototype*` helper before calling this function:
|
|
12
|
+
* - `removePrototype` — shallow sanitization of a single object
|
|
13
|
+
* - `removePrototypeDeep` — recursive sanitization of a single object (for deeply nested data)
|
|
14
|
+
* - `removePrototypeMap` — shallow sanitization of an array of objects
|
|
15
|
+
* - `removePrototypeMapDeep` — recursive sanitization of an array of objects (for deeply nested data)
|
|
6
16
|
*/
|
|
7
17
|
export const merge = (target, ...sources) => {
|
|
8
|
-
|
|
18
|
+
const result = {};
|
|
19
|
+
for (const object of [target, ...sources]) {
|
|
20
|
+
for (const key of Object.keys(object)) {
|
|
21
|
+
result[key] = object[key];
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return result;
|
|
9
25
|
};
|
|
10
26
|
//# sourceMappingURL=merge.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"merge.js","sourceRoot":"","sources":["../../src/Object/merge.ts"],"names":[],"mappings":"AAEA
|
|
1
|
+
{"version":3,"file":"merge.js","sourceRoot":"","sources":["../../src/Object/merge.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,CAInB,MAAS,EACT,GAAG,OAAU,EACuB,EAAE;IACtC,MAAM,MAAM,GAA4B,EAAE,CAAC;IAC3C,KAAK,MAAM,MAAM,IAAI,CAAC,MAAM,EAAE,GAAG,OAAO,CAAC,EAAE,CAAC;QAC1C,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;YACtC,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;QAC5B,CAAC;IACH,CAAC;IACD,OAAO,MAA4C,CAAC;AACtD,CAAC,CAAC"}
|
|
@@ -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]>;
|
|
@@ -1,32 +1,46 @@
|
|
|
1
1
|
import { isPlainObject } from "../Object/isPlainObject";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export const mergeDeep = (target, ...sources) => {
|
|
9
|
-
if (sources.length === 0) {
|
|
2
|
+
// Performance: use an index parameter instead of Array.shift() to advance
|
|
3
|
+
// through sources. shift() is O(n) because it re-indexes every remaining
|
|
4
|
+
// element, making the overall merge O(n²) in the number of sources.
|
|
5
|
+
// An index makes each step O(1) and avoids mutating the sources array.
|
|
6
|
+
const mergeDeepInternal = (target, sources, depth, sourceIndex = 0) => {
|
|
7
|
+
if (sourceIndex >= sources.length) {
|
|
10
8
|
return target;
|
|
11
9
|
}
|
|
12
|
-
const source = sources
|
|
10
|
+
const source = sources[sourceIndex];
|
|
13
11
|
if (isPlainObject(target) && isPlainObject(source)) {
|
|
14
12
|
const result = { ...target };
|
|
15
13
|
for (const key in source) {
|
|
16
|
-
if (key === "__proto__" || key === "constructor" || key === "prototype") {
|
|
17
|
-
continue;
|
|
18
|
-
}
|
|
19
14
|
if (Object.hasOwn(source, key)) {
|
|
20
15
|
const sourceValue = source[key];
|
|
21
16
|
const targetValue = result[key];
|
|
22
17
|
result[key] =
|
|
23
18
|
isPlainObject(targetValue) && isPlainObject(sourceValue)
|
|
24
|
-
?
|
|
19
|
+
? mergeDeepInternal(targetValue, [sourceValue], depth + 1)
|
|
25
20
|
: sourceValue;
|
|
26
21
|
}
|
|
27
22
|
}
|
|
28
|
-
return
|
|
23
|
+
return mergeDeepInternal(result, sources, depth + 1, sourceIndex + 1);
|
|
29
24
|
}
|
|
30
|
-
return
|
|
25
|
+
return mergeDeepInternal(source, sources, depth + 1, sourceIndex + 1);
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Deeply merges multiple objects into a single object
|
|
29
|
+
* @param target - The target object to merge into
|
|
30
|
+
* @param sources - The source objects to merge from
|
|
31
|
+
* @returns The deeply merged object
|
|
32
|
+
*
|
|
33
|
+
* @remarks
|
|
34
|
+
* **Prototype pollution warning:** This function does not filter out
|
|
35
|
+
* prototype-polluting keys (`__proto__`, `constructor`, `prototype`).
|
|
36
|
+
* If processing user-controlled input, sanitize with the appropriate
|
|
37
|
+
* `removePrototype*` helper before calling this function:
|
|
38
|
+
* - `removePrototype` — shallow sanitization of a single object
|
|
39
|
+
* - `removePrototypeDeep` — recursive sanitization of a single object (for deeply nested data)
|
|
40
|
+
* - `removePrototypeMap` — shallow sanitization of an array of objects
|
|
41
|
+
* - `removePrototypeMapDeep` — recursive sanitization of an array of objects (for deeply nested data)
|
|
42
|
+
*/
|
|
43
|
+
export const mergeDeep = (target, ...sources) => {
|
|
44
|
+
return mergeDeepInternal(target, sources, 0);
|
|
31
45
|
};
|
|
32
46
|
//# sourceMappingURL=mergeDeep.js.map
|