umt 2.14.0 → 2.16.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/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.map +1 -1
- package/module/Crypto/decodeBase58.js +1 -2
- 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/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 -9
- 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 +13 -2
- 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/pick.d.ts +10 -0
- package/module/Object/pick.js +10 -0
- package/module/Object/pick.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/zip.js +23 -17
- package/module/es5/Array/zipLongest.js +27 -14
- package/module/es5/Crypto/decodeBase58.js +1 -2
- package/module/es5/Crypto/encodeBase32.js +12 -6
- 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 -9
- 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 +11 -7
- 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/pick.d.ts +10 -0
- package/module/es5/Object/pick.js +10 -0
- 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 +19 -19
- package/module/es5/tsconfig.tsbuildinfo +0 -1
|
@@ -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
|
};
|
|
@@ -7,6 +7,16 @@
|
|
|
7
7
|
* @param {...K[]} keys - The property keys to extract.
|
|
8
8
|
* @returns {Pick<T, K>} A new object containing only the specified properties.
|
|
9
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)
|
|
19
|
+
*
|
|
10
20
|
* @example
|
|
11
21
|
* ```typescript
|
|
12
22
|
* const user = { id: 1, name: 'Alice', age: 30 };
|
|
@@ -13,6 +13,16 @@ exports.pick = void 0;
|
|
|
13
13
|
* @param {...K[]} keys - The property keys to extract.
|
|
14
14
|
* @returns {Pick<T, K>} A new object containing only the specified properties.
|
|
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
|
* const user = { id: 1, name: 'Alice', age: 30 };
|
|
@@ -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
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a new array of objects with prototype polluting properties removed
|
|
3
|
+
* from each item.
|
|
4
|
+
*
|
|
5
|
+
* @param objects - The objects to remove the prototype polluting properties
|
|
6
|
+
* from.
|
|
7
|
+
* @returns A new array with shallowly sanitized objects.
|
|
8
|
+
*/
|
|
9
|
+
export declare const removePrototypeMap: <T extends Record<string, unknown>>(objects: readonly T[]) => Omit<T, "__proto__" | "constructor" | "prototype">[];
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.removePrototypeMap = void 0;
|
|
7
|
+
var _removePrototype = require("../Object/removePrototype");
|
|
8
|
+
/**
|
|
9
|
+
* Creates a new array of objects with prototype polluting properties removed
|
|
10
|
+
* from each item.
|
|
11
|
+
*
|
|
12
|
+
* @param objects - The objects to remove the prototype polluting properties
|
|
13
|
+
* from.
|
|
14
|
+
* @returns A new array with shallowly sanitized objects.
|
|
15
|
+
*/
|
|
16
|
+
var removePrototypeMap = exports.removePrototypeMap = function removePrototypeMap(objects) {
|
|
17
|
+
return objects.map(function (object) {
|
|
18
|
+
return (0, _removePrototype.removePrototype)(object);
|
|
19
|
+
});
|
|
20
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a new array of objects with prototype polluting properties removed
|
|
3
|
+
* recursively from each item.
|
|
4
|
+
*
|
|
5
|
+
* @param objects - The objects to remove the prototype polluting properties
|
|
6
|
+
* from recursively.
|
|
7
|
+
* @returns A new array with deeply sanitized objects.
|
|
8
|
+
*/
|
|
9
|
+
export declare const removePrototypeMapDeep: <T extends Record<string, unknown>>(objects: readonly T[]) => T[];
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.removePrototypeMapDeep = void 0;
|
|
7
|
+
var _removePrototypeDeep = require("../Object/removePrototypeDeep");
|
|
8
|
+
/**
|
|
9
|
+
* Creates a new array of objects with prototype polluting properties removed
|
|
10
|
+
* recursively from each item.
|
|
11
|
+
*
|
|
12
|
+
* @param objects - The objects to remove the prototype polluting properties
|
|
13
|
+
* from recursively.
|
|
14
|
+
* @returns A new array with deeply sanitized objects.
|
|
15
|
+
*/
|
|
16
|
+
var removePrototypeMapDeep = exports.removePrototypeMapDeep = function removePrototypeMapDeep(objects) {
|
|
17
|
+
return objects.map(function (object) {
|
|
18
|
+
return (0, _removePrototypeDeep.removePrototypeDeep)(object);
|
|
19
|
+
});
|
|
20
|
+
};
|
|
@@ -5,14 +5,23 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.escapeHtml = void 0;
|
|
7
7
|
/**
|
|
8
|
-
* HTML entities map for escaping
|
|
8
|
+
* HTML entities map for escaping.
|
|
9
|
+
*
|
|
10
|
+
* Security: The backtick (`) is included because it can be used as an HTML
|
|
11
|
+
* attribute delimiter in older browsers (e.g. IE), enabling XSS via
|
|
12
|
+
* constructs like <img src=`javascript:alert(1)`>. The forward slash (/)
|
|
13
|
+
* is included per OWASP XSS prevention recommendations to mitigate tag-
|
|
14
|
+
* closing injection (e.g. "</script>") when user input is embedded inside
|
|
15
|
+
* HTML elements.
|
|
9
16
|
*/
|
|
10
17
|
var htmlEscapeMap = {
|
|
11
18
|
"&": "&",
|
|
12
19
|
"<": "<",
|
|
13
20
|
">": ">",
|
|
14
21
|
'"': """,
|
|
15
|
-
"'": "'"
|
|
22
|
+
"'": "'",
|
|
23
|
+
"`": "`",
|
|
24
|
+
"/": "/"
|
|
16
25
|
};
|
|
17
26
|
|
|
18
27
|
/**
|
|
@@ -21,7 +30,7 @@ var htmlEscapeMap = {
|
|
|
21
30
|
* @returns The escaped string
|
|
22
31
|
*/
|
|
23
32
|
var escapeHtml = exports.escapeHtml = function escapeHtml(string_) {
|
|
24
|
-
return string_.replaceAll(/["&'
|
|
33
|
+
return string_.replaceAll(/["&'/<>`]/g, function (match) {
|
|
25
34
|
return htmlEscapeMap[match];
|
|
26
35
|
});
|
|
27
36
|
};
|
|
@@ -61,7 +61,7 @@ function applyFormatter(value, formatterString, formatters) {
|
|
|
61
61
|
*/
|
|
62
62
|
function parseArguments(argumentsString) {
|
|
63
63
|
var arguments_ = [];
|
|
64
|
-
var
|
|
64
|
+
var chars = [];
|
|
65
65
|
var inQuotes = false;
|
|
66
66
|
var quoteChar = "";
|
|
67
67
|
var _iterator = _createForOfIteratorHelper(argumentsString),
|
|
@@ -80,12 +80,12 @@ function parseArguments(argumentsString) {
|
|
|
80
80
|
continue;
|
|
81
81
|
}
|
|
82
82
|
if (!inQuotes && _char === ",") {
|
|
83
|
-
var _trimmed =
|
|
83
|
+
var _trimmed = chars.join("").trim();
|
|
84
84
|
arguments_.push(_trimmed === "" ? " " : _trimmed);
|
|
85
|
-
|
|
85
|
+
chars.length = 0;
|
|
86
86
|
continue;
|
|
87
87
|
}
|
|
88
|
-
|
|
88
|
+
chars.push(_char);
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
// Handle last argument
|
|
@@ -94,7 +94,7 @@ function parseArguments(argumentsString) {
|
|
|
94
94
|
} finally {
|
|
95
95
|
_iterator.f();
|
|
96
96
|
}
|
|
97
|
-
var trimmed =
|
|
97
|
+
var trimmed = chars.join("").trim();
|
|
98
98
|
arguments_.push(trimmed === "" ? " " : trimmed);
|
|
99
99
|
return arguments_;
|
|
100
100
|
}
|
|
@@ -12,6 +12,9 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
|
|
|
12
12
|
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; } } }; }
|
|
13
13
|
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; } }
|
|
14
14
|
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; }
|
|
15
|
+
// Pre-compiled regex pattern for array index notation to avoid recompilation per path segment
|
|
16
|
+
var ARRAY_INDEX_PATTERN = /^(.+?)\[(-?\d+)]$/;
|
|
17
|
+
|
|
15
18
|
/**
|
|
16
19
|
* Retrieves a value from an object using a dot-notation path with array index support.
|
|
17
20
|
*
|
|
@@ -46,7 +49,7 @@ function getValue(object, path) {
|
|
|
46
49
|
try {
|
|
47
50
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
48
51
|
var part = _step.value;
|
|
49
|
-
var arrayMatch =
|
|
52
|
+
var arrayMatch = ARRAY_INDEX_PATTERN.exec(part);
|
|
50
53
|
if (arrayMatch) {
|
|
51
54
|
var _arrayMatch = _slicedToArray(arrayMatch, 3),
|
|
52
55
|
key = _arrayMatch[1],
|
|
@@ -11,52 +11,67 @@ exports.levenshteinDistance = void 0;
|
|
|
11
11
|
* @param string2 - Second string to compare
|
|
12
12
|
* @returns The Levenshtein distance
|
|
13
13
|
*/
|
|
14
|
-
var
|
|
14
|
+
var levenshteinDistance = exports.levenshteinDistance = function levenshteinDistance(string1, string2) {
|
|
15
15
|
if (string1 === string2) {
|
|
16
16
|
return 0;
|
|
17
17
|
}
|
|
18
|
-
var
|
|
19
|
-
var
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
var _short = string1;
|
|
19
|
+
var _long = string2;
|
|
20
|
+
var shortLength = _short.length;
|
|
21
|
+
var longLength = _long.length;
|
|
22
|
+
if (shortLength === 0) {
|
|
23
|
+
return longLength;
|
|
22
24
|
}
|
|
23
|
-
if (
|
|
24
|
-
return
|
|
25
|
+
if (longLength === 0) {
|
|
26
|
+
return shortLength;
|
|
25
27
|
}
|
|
26
28
|
|
|
27
|
-
// Ensure
|
|
28
|
-
if (
|
|
29
|
-
|
|
29
|
+
// Ensure short is the shorter string to minimize space complexity to O(min(N, M))
|
|
30
|
+
if (shortLength > longLength) {
|
|
31
|
+
_short = string2;
|
|
32
|
+
_long = string1;
|
|
33
|
+
shortLength = _short.length;
|
|
34
|
+
longLength = _long.length;
|
|
30
35
|
}
|
|
31
36
|
|
|
32
37
|
// Create a single row array to store distances
|
|
33
38
|
// We only need the current row and the previous diagonal value
|
|
34
39
|
var row = Array.from({
|
|
35
|
-
length:
|
|
40
|
+
length: shortLength + 1
|
|
36
41
|
});
|
|
37
42
|
|
|
38
|
-
// Initialize first row (0 to
|
|
39
|
-
for (var index = 0; index <=
|
|
43
|
+
// Initialize first row (0 to shortLength)
|
|
44
|
+
for (var index = 0; index <= shortLength; index++) {
|
|
40
45
|
row[index] = index;
|
|
41
46
|
}
|
|
42
47
|
|
|
43
|
-
// Iterate through each character of
|
|
44
|
-
for (var
|
|
45
|
-
var previousDiagonal = row[0];
|
|
46
|
-
row[0] =
|
|
48
|
+
// Iterate through each character of the longer string (rows)
|
|
49
|
+
for (var rowIndex = 1; rowIndex <= longLength; rowIndex++) {
|
|
50
|
+
var previousDiagonal = row[0];
|
|
51
|
+
row[0] = rowIndex;
|
|
47
52
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
var
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
//
|
|
56
|
-
|
|
57
|
-
|
|
53
|
+
// eslint-disable-next-line unicorn/prefer-code-point
|
|
54
|
+
var charCode = _long.charCodeAt(rowIndex - 1);
|
|
55
|
+
for (var colIndex = 1; colIndex <= shortLength; colIndex++) {
|
|
56
|
+
var temporary = row[colIndex];
|
|
57
|
+
// eslint-disable-next-line unicorn/prefer-code-point
|
|
58
|
+
var cost = _short.charCodeAt(colIndex - 1) === charCode ? 0 : 1;
|
|
59
|
+
|
|
60
|
+
// Inline min of three values instead of Math.min() call to avoid
|
|
61
|
+
// function-call overhead in this hot loop
|
|
62
|
+
var deletion = row[colIndex] + 1;
|
|
63
|
+
var insertion = row[colIndex - 1] + 1;
|
|
64
|
+
var substitution = previousDiagonal + cost;
|
|
65
|
+
var value = deletion;
|
|
66
|
+
if (insertion < value) {
|
|
67
|
+
value = insertion;
|
|
68
|
+
}
|
|
69
|
+
if (substitution < value) {
|
|
70
|
+
value = substitution;
|
|
71
|
+
}
|
|
72
|
+
row[colIndex] = value;
|
|
58
73
|
previousDiagonal = temporary;
|
|
59
74
|
}
|
|
60
75
|
}
|
|
61
|
-
return row[
|
|
76
|
+
return row[shortLength];
|
|
62
77
|
};
|
|
@@ -14,5 +14,12 @@ exports.slugify = void 0;
|
|
|
14
14
|
* slugify("Japanese: こんにちは"); // "japanese"
|
|
15
15
|
*/
|
|
16
16
|
var slugify = exports.slugify = function slugify(string_) {
|
|
17
|
-
return string_.normalize("NFD")
|
|
17
|
+
return string_.normalize("NFD")
|
|
18
|
+
// Strip combining diacritical marks (e.g. accents)
|
|
19
|
+
.replaceAll(/[\u0300-\u036F]/g, "").toLowerCase()
|
|
20
|
+
// Consolidate non-word chars, whitespace, and underscores into a single
|
|
21
|
+
// hyphen in one pass instead of three separate regex scans
|
|
22
|
+
.replaceAll(/[^\w-]+|_+/g, "-")
|
|
23
|
+
// Collapse consecutive hyphens and strip leading/trailing hyphens
|
|
24
|
+
.replaceAll(/-+/g, "-").replaceAll(/^-|-$/g, "");
|
|
18
25
|
};
|
|
@@ -18,8 +18,10 @@ exports.trimEndCharacters = void 0;
|
|
|
18
18
|
* ```
|
|
19
19
|
*/
|
|
20
20
|
var trimEndCharacters = exports.trimEndCharacters = function trimEndCharacters(string_, chars) {
|
|
21
|
+
// Use Set for O(1) character lookups instead of O(m) string.includes()
|
|
22
|
+
var charSet = new Set(chars);
|
|
21
23
|
var endIndex = string_.length - 1;
|
|
22
|
-
while (endIndex >= 0 &&
|
|
24
|
+
while (endIndex >= 0 && charSet.has(string_[endIndex])) {
|
|
23
25
|
endIndex--;
|
|
24
26
|
}
|
|
25
27
|
return string_.slice(0, endIndex + 1);
|
|
@@ -18,8 +18,10 @@ exports.trimStartCharacters = void 0;
|
|
|
18
18
|
* ```
|
|
19
19
|
*/
|
|
20
20
|
var trimStartCharacters = exports.trimStartCharacters = function trimStartCharacters(string_, chars) {
|
|
21
|
+
// Use Set for O(1) character lookups instead of O(m) string.includes()
|
|
22
|
+
var charSet = new Set(chars);
|
|
21
23
|
var startIndex = 0;
|
|
22
|
-
while (startIndex < string_.length &&
|
|
24
|
+
while (startIndex < string_.length && charSet.has(string_[startIndex])) {
|
|
23
25
|
startIndex++;
|
|
24
26
|
}
|
|
25
27
|
return string_.slice(startIndex);
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* @example
|
|
6
6
|
* ```typescript
|
|
7
7
|
* unescapeHtml("<script>alert("Hello");</script>");
|
|
8
|
-
* // Returns: "<script>alert("Hello");</script>"
|
|
8
|
+
* // Returns: "<script>alert(\"Hello\");</script>"
|
|
9
9
|
*
|
|
10
10
|
* unescapeHtml("Tom & Jerry");
|
|
11
11
|
* // Returns: "Tom & Jerry"
|