package-json-scripts-portability 0.0.1 → 0.0.3
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/README.md +59 -20
- package/dist/analyze-script.d.mts +34 -0
- package/dist/analyze-script.mjs +53 -0
- package/dist/command-checker.mjs +527 -0
- package/dist/command-usage.mjs +413 -0
- package/dist/commands.mjs +639 -0
- package/dist/context.mjs +25 -0
- package/dist/fixes.d.mts +9 -0
- package/dist/fixes.mjs +354 -0
- package/dist/index.d.mts +6 -118
- package/dist/index.mjs +4 -3787
- package/dist/line-break-checker.mjs +104 -0
- package/dist/messages.mjs +38 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/array/array-difference.mjs +11 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/array/array-includes.mjs +8 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/array/array-intersection.mjs +13 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/array/array-is-subset.mjs +16 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/array/arrayify.mjs +7 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/array/sorted-array-insertion-index-with.mjs +33 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/array/sorted-array-insertion-index.mjs +10 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/iterable/sliding-window.mjs +30 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/map/map-get-or-insert-computed.mjs +42 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/map/map-get-or-insert.mjs +40 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/math/clamp.mjs +7 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/path/to-forward-slashes.mjs +8 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/predicate/is-array.mjs +39 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/semver/is-semver-in-range.mjs +5 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/semver/parse-semver.mjs +26 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/set/set-has.mjs +8 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/string/substring-after-last.mjs +24 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/string/substring-after.mjs +24 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/string/substring-before.mjs +24 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/string/truncate.mjs +46 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/ts/all-union-members.mjs +45 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/types/maybe-readonly-array.d.mts +17 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/value/is-equal.mjs +37 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/@antfu/utils/dist/index.mjs +5 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/_internal/globalThis.mjs +5 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/_internal/isUnsafeProperty.mjs +18 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/_internal/setOwnValue.mjs +23 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/_internal/toPropertyKey.mjs +16 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/array/differenceBy.mjs +40 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/array/differenceWith.mjs +37 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/array/intersectionWith.mjs +43 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/array/isSubsetWith.mjs +36 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/bigint/clamp.mjs +15 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/_internal/baseToString.mjs +26 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/_internal/getSymbols.mjs +5 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/_internal/getTag.mjs +13 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/_internal/hasOwn.mjs +13 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/_internal/isDeepKey.mjs +39 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/_internal/isIndex.mjs +10 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/_internal/regexMultiByte.mjs +10 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/_internal/tags.mjs +28 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/_internal/toKey.mjs +15 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/array/sortedIndex.mjs +36 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/array/sortedIndexBy.mjs +54 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/array/sortedLastIndex.mjs +34 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/array/sortedLastIndexBy.mjs +21 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/function/identity.mjs +5 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/object/cloneDeep.mjs +52 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/object/cloneDeepWith.mjs +179 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/object/get.mjs +67 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/object/has.mjs +53 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/object/property.mjs +26 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/predicate/isArguments.mjs +26 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/predicate/isBuffer.mjs +24 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/predicate/isMatch.mjs +34 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/predicate/isMatchWith.mjs +163 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/predicate/isNaN.mjs +18 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/predicate/isNil.mjs +24 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/predicate/isNumber.mjs +24 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/predicate/isObject.mjs +28 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/predicate/isObjectLike.mjs +28 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/predicate/isSymbol.mjs +19 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/predicate/isTypedArray.mjs +21 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/predicate/matches.mjs +36 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/predicate/matchesProperty.mjs +47 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/string/truncate.mjs +78 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/util/eq.mjs +18 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/util/iteratee.mjs +46 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/util/toPath.mjs +75 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/util/toString.mjs +23 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/function/identity.mjs +24 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/function/noop.mjs +12 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/math/clamp.mjs +23 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/predicate/isBuffer.mjs +24 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/predicate/isEqual.mjs +21 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/predicate/isEqualWith.mjs +150 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/predicate/isNil.mjs +24 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/predicate/isNull.mjs +25 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/predicate/isPlainObject.mjs +50 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/predicate/isPrimitive.mjs +26 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/predicate/isSymbol.mjs +28 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/predicate/isTypedArray.mjs +20 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/predicate/isUndefined.mjs +25 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/remeda/dist/binarySearchCutoffIndex-Bu-OMJ0Z.mjs +26 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/remeda/dist/isArray.mjs +18 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/remeda/dist/sortedIndexWith.mjs +7 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/ts-extras/distribution/array-includes.mjs +5 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/ts-extras/distribution/set-has.mjs +5 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/verkit/dist/comparison-CmVirWIW.mjs +108 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/verkit/dist/range-C5wjdo9a.mjs +164 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/verkit/dist/set-BGFWKKE8.mjs +38 -0
- package/dist/platforms.d.mts +8 -0
- package/dist/platforms.mjs +26 -0
- package/dist/redirection-checker.mjs +169 -0
- package/dist/reporter.d.mts +32 -0
- package/dist/reporter.mjs +143 -0
- package/dist/runners.d.mts +21 -0
- package/dist/runners.mjs +199 -0
- package/dist/script-analyzer.mjs +853 -0
- package/dist/word-checker.mjs +573 -0
- package/dist/words.mjs +70 -0
- package/package.json +36 -30
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { cloneDeepWith } from "./cloneDeepWith.mjs";
|
|
2
|
+
// node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/object/cloneDeep.mjs
|
|
3
|
+
/**
|
|
4
|
+
* Creates a deep clone of the given object.
|
|
5
|
+
*
|
|
6
|
+
* @template T - The type of the object.
|
|
7
|
+
* @param obj - The object to clone.
|
|
8
|
+
* @returns A deep clone of the given object.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* // Clone a primitive value
|
|
12
|
+
* const num = 29;
|
|
13
|
+
* const clonedNum = clone(num);
|
|
14
|
+
* console.log(clonedNum); // 29
|
|
15
|
+
* console.log(clonedNum === num); // true
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* // Clone an array
|
|
19
|
+
* const arr = [1, 2, 3];
|
|
20
|
+
* const clonedArr = cloneDeep(arr);
|
|
21
|
+
* console.log(clonedArr); // [1, 2, 3]
|
|
22
|
+
* console.log(clonedArr === arr); // false
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* // Clone an array with nested objects
|
|
26
|
+
* const arr = [1, { a: 1 }, [1, 2, 3]];
|
|
27
|
+
* const clonedArr = cloneDeep(arr);
|
|
28
|
+
* arr[1].a = 2;
|
|
29
|
+
* console.log(arr); // [1, { a: 2 }, [1, 2, 3]]
|
|
30
|
+
* console.log(clonedArr); // [1, { a: 1 }, [1, 2, 3]]
|
|
31
|
+
* console.log(clonedArr === arr); // false
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* // Clone an object
|
|
35
|
+
* const obj = { a: 1, b: 'es-toolkit', c: [1, 2, 3] };
|
|
36
|
+
* const clonedObj = cloneDeep(obj);
|
|
37
|
+
* console.log(clonedObj); // { a: 1, b: 'es-toolkit', c: [1, 2, 3] }
|
|
38
|
+
* console.log(clonedObj === obj); // false
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* // Clone an object with nested objects
|
|
42
|
+
* const obj = { a: 1, b: { c: 1 } };
|
|
43
|
+
* const clonedObj = cloneDeep(obj);
|
|
44
|
+
* obj.b.c = 2;
|
|
45
|
+
* console.log(obj); // { a: 1, b: { c: 2 } }
|
|
46
|
+
* console.log(clonedObj); // { a: 1, b: { c: 1 } }
|
|
47
|
+
* console.log(clonedObj === obj); // false
|
|
48
|
+
*/
|
|
49
|
+
function cloneDeep(obj) {
|
|
50
|
+
return cloneDeepWith(obj);
|
|
51
|
+
}
|
|
52
|
+
export { cloneDeep };
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { setOwnValue } from "../../_internal/setOwnValue.mjs";
|
|
2
|
+
import { isPrimitive } from "../../predicate/isPrimitive.mjs";
|
|
3
|
+
import { getSymbols } from "../_internal/getSymbols.mjs";
|
|
4
|
+
import { getTag } from "../_internal/getTag.mjs";
|
|
5
|
+
import { argumentsTag, arrayBufferTag, arrayTag, booleanTag, dataViewTag, dateTag, float32ArrayTag, float64ArrayTag, int16ArrayTag, int32ArrayTag, int8ArrayTag, mapTag, numberTag, objectTag, regexpTag, setTag, stringTag, symbolTag, uint16ArrayTag, uint32ArrayTag, uint8ArrayTag, uint8ClampedArrayTag } from "../_internal/tags.mjs";
|
|
6
|
+
import { hasOwn } from "../_internal/hasOwn.mjs";
|
|
7
|
+
import { isBuffer } from "../predicate/isBuffer.mjs";
|
|
8
|
+
import { isTypedArray } from "../predicate/isTypedArray.mjs";
|
|
9
|
+
// node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/object/cloneDeepWith.mjs
|
|
10
|
+
/**
|
|
11
|
+
* Creates a deep clone of the given object using a customizer function.
|
|
12
|
+
*
|
|
13
|
+
* @template T - The type of the object.
|
|
14
|
+
* @param obj - The object to clone.
|
|
15
|
+
* @param [cloneValue] - A function to customize the cloning process.
|
|
16
|
+
* @returns A deep clone of the given object.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* // Clone a primitive value
|
|
20
|
+
* const num = 29;
|
|
21
|
+
* const clonedNum = cloneDeepWith(num);
|
|
22
|
+
* console.log(clonedNum); // 29
|
|
23
|
+
* console.log(clonedNum === num); // true
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* // Clone an object with a customizer
|
|
27
|
+
* const obj = { a: 1, b: 2 };
|
|
28
|
+
* const clonedObj = cloneDeepWith(obj, (value) => {
|
|
29
|
+
* if (typeof value === 'number') {
|
|
30
|
+
* return value * 2; // Double the number
|
|
31
|
+
* }
|
|
32
|
+
* });
|
|
33
|
+
* console.log(clonedObj); // { a: 2, b: 4 }
|
|
34
|
+
* console.log(clonedObj === obj); // false
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* // Clone an array with a customizer
|
|
38
|
+
* const arr = [1, 2, 3];
|
|
39
|
+
* const clonedArr = cloneDeepWith(arr, (value) => {
|
|
40
|
+
* if (typeof value === 'number') {
|
|
41
|
+
* return value + 1; // Increment each number
|
|
42
|
+
* }
|
|
43
|
+
* });
|
|
44
|
+
* console.log(clonedArr); // [2, 3, 4]
|
|
45
|
+
* console.log(clonedArr === arr); // false
|
|
46
|
+
*/
|
|
47
|
+
function cloneDeepWith(obj, customizer) {
|
|
48
|
+
return cloneDeepWithImpl(obj, void 0, obj, /* @__PURE__ */ new Map(), customizer);
|
|
49
|
+
}
|
|
50
|
+
function cloneDeepWithImpl(valueToClone, keyToClone, objectToClone, stack, customizer) {
|
|
51
|
+
if (customizer != null) {
|
|
52
|
+
const cloned = customizer(valueToClone, keyToClone, objectToClone, stack);
|
|
53
|
+
if (cloned !== void 0) return cloned;
|
|
54
|
+
}
|
|
55
|
+
if (isPrimitive(valueToClone)) return valueToClone;
|
|
56
|
+
if (stack.has(valueToClone)) return stack.get(valueToClone);
|
|
57
|
+
if (Array.isArray(valueToClone)) {
|
|
58
|
+
const result = new Array(valueToClone.length);
|
|
59
|
+
stack.set(valueToClone, result);
|
|
60
|
+
for (let i = 0; i < valueToClone.length; i++) result[i] = cloneDeepWithImpl(valueToClone[i], i, objectToClone, stack, customizer);
|
|
61
|
+
if (hasOwn(valueToClone, "index")) result.index = valueToClone.index;
|
|
62
|
+
if (hasOwn(valueToClone, "input")) result.input = valueToClone.input;
|
|
63
|
+
return result;
|
|
64
|
+
}
|
|
65
|
+
if (valueToClone instanceof Date) return new Date(valueToClone.getTime());
|
|
66
|
+
if (valueToClone instanceof RegExp) {
|
|
67
|
+
const result = new RegExp(valueToClone.source, valueToClone.flags);
|
|
68
|
+
result.lastIndex = valueToClone.lastIndex;
|
|
69
|
+
return result;
|
|
70
|
+
}
|
|
71
|
+
if (valueToClone instanceof Map) {
|
|
72
|
+
const result = /* @__PURE__ */ new Map();
|
|
73
|
+
stack.set(valueToClone, result);
|
|
74
|
+
valueToClone.forEach((value, key) => {
|
|
75
|
+
result.set(key, cloneDeepWithImpl(value, key, objectToClone, stack, customizer));
|
|
76
|
+
});
|
|
77
|
+
return result;
|
|
78
|
+
}
|
|
79
|
+
if (valueToClone instanceof Set) {
|
|
80
|
+
const result = /* @__PURE__ */ new Set();
|
|
81
|
+
stack.set(valueToClone, result);
|
|
82
|
+
valueToClone.forEach((value) => {
|
|
83
|
+
result.add(cloneDeepWithImpl(value, void 0, objectToClone, stack, customizer));
|
|
84
|
+
});
|
|
85
|
+
return result;
|
|
86
|
+
}
|
|
87
|
+
if (isBuffer(valueToClone)) return valueToClone.subarray();
|
|
88
|
+
if (isTypedArray(valueToClone)) {
|
|
89
|
+
const result = new (Object.getPrototypeOf(valueToClone)).constructor(valueToClone.length);
|
|
90
|
+
stack.set(valueToClone, result);
|
|
91
|
+
for (let i = 0; i < valueToClone.length; i++) result[i] = cloneDeepWithImpl(valueToClone[i], i, objectToClone, stack, customizer);
|
|
92
|
+
return result;
|
|
93
|
+
}
|
|
94
|
+
if (valueToClone instanceof ArrayBuffer || typeof SharedArrayBuffer !== "undefined" && valueToClone instanceof SharedArrayBuffer) return valueToClone.slice(0);
|
|
95
|
+
if (valueToClone instanceof DataView) {
|
|
96
|
+
const result = new DataView(valueToClone.buffer.slice(0), valueToClone.byteOffset, valueToClone.byteLength);
|
|
97
|
+
stack.set(valueToClone, result);
|
|
98
|
+
copyProperties(result, valueToClone, objectToClone, stack, customizer);
|
|
99
|
+
return result;
|
|
100
|
+
}
|
|
101
|
+
if (typeof File !== "undefined" && valueToClone instanceof File) {
|
|
102
|
+
const result = new File([valueToClone], valueToClone.name, { type: valueToClone.type });
|
|
103
|
+
stack.set(valueToClone, result);
|
|
104
|
+
copyProperties(result, valueToClone, objectToClone, stack, customizer);
|
|
105
|
+
return result;
|
|
106
|
+
}
|
|
107
|
+
if (typeof Blob !== "undefined" && valueToClone instanceof Blob) {
|
|
108
|
+
const result = new Blob([valueToClone], { type: valueToClone.type });
|
|
109
|
+
stack.set(valueToClone, result);
|
|
110
|
+
copyProperties(result, valueToClone, objectToClone, stack, customizer);
|
|
111
|
+
return result;
|
|
112
|
+
}
|
|
113
|
+
const tag = getTag(valueToClone);
|
|
114
|
+
if (tag === "[object Error]") {
|
|
115
|
+
if (valueToClone === objectToClone) return {};
|
|
116
|
+
return valueToClone;
|
|
117
|
+
}
|
|
118
|
+
switch (tag) {
|
|
119
|
+
case numberTag:
|
|
120
|
+
case stringTag:
|
|
121
|
+
case booleanTag: {
|
|
122
|
+
const result = new valueToClone.constructor(valueToClone.valueOf());
|
|
123
|
+
stack.set(valueToClone, result);
|
|
124
|
+
copyProperties(result, valueToClone, objectToClone, stack, customizer);
|
|
125
|
+
return result;
|
|
126
|
+
}
|
|
127
|
+
case argumentsTag: {
|
|
128
|
+
const result = {};
|
|
129
|
+
stack.set(valueToClone, result);
|
|
130
|
+
copyProperties(result, valueToClone, objectToClone, stack, customizer);
|
|
131
|
+
result.length = valueToClone.length;
|
|
132
|
+
result[Symbol.iterator] = valueToClone[Symbol.iterator];
|
|
133
|
+
return result;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
if (typeof valueToClone === "object" && isCloneableObject(tag)) {
|
|
137
|
+
const result = tag === "[object Object]" && typeof valueToClone.constructor !== "function" ? {} : Object.create(Object.getPrototypeOf(valueToClone));
|
|
138
|
+
stack.set(valueToClone, result);
|
|
139
|
+
copyProperties(result, valueToClone, objectToClone, stack, customizer);
|
|
140
|
+
return result;
|
|
141
|
+
}
|
|
142
|
+
return valueToClone;
|
|
143
|
+
}
|
|
144
|
+
function copyProperties(target, source, objectToClone, stack, customizer) {
|
|
145
|
+
const keys = [...Object.keys(source), ...getSymbols(source)];
|
|
146
|
+
for (let i = 0; i < keys.length; i++) {
|
|
147
|
+
const key = keys[i];
|
|
148
|
+
const descriptor = Object.getOwnPropertyDescriptor(target, key);
|
|
149
|
+
if (descriptor == null || descriptor.writable) setOwnValue(target, key, cloneDeepWithImpl(source[key], key, objectToClone, stack, customizer));
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
function isCloneableObject(tag) {
|
|
153
|
+
switch (tag) {
|
|
154
|
+
case argumentsTag:
|
|
155
|
+
case arrayTag:
|
|
156
|
+
case arrayBufferTag:
|
|
157
|
+
case dataViewTag:
|
|
158
|
+
case booleanTag:
|
|
159
|
+
case dateTag:
|
|
160
|
+
case float32ArrayTag:
|
|
161
|
+
case float64ArrayTag:
|
|
162
|
+
case int8ArrayTag:
|
|
163
|
+
case int16ArrayTag:
|
|
164
|
+
case int32ArrayTag:
|
|
165
|
+
case mapTag:
|
|
166
|
+
case numberTag:
|
|
167
|
+
case objectTag:
|
|
168
|
+
case regexpTag:
|
|
169
|
+
case setTag:
|
|
170
|
+
case stringTag:
|
|
171
|
+
case symbolTag:
|
|
172
|
+
case uint8ArrayTag:
|
|
173
|
+
case uint8ClampedArrayTag:
|
|
174
|
+
case uint16ArrayTag:
|
|
175
|
+
case uint32ArrayTag: return true;
|
|
176
|
+
default: return false;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
export { cloneDeepWith };
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { isUnsafeProperty } from "../../_internal/isUnsafeProperty.mjs";
|
|
2
|
+
import { hasOwn } from "../_internal/hasOwn.mjs";
|
|
3
|
+
import { isDeepKey } from "../_internal/isDeepKey.mjs";
|
|
4
|
+
import { toKey } from "../_internal/toKey.mjs";
|
|
5
|
+
import { toPath } from "../util/toPath.mjs";
|
|
6
|
+
// node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/object/get.mjs
|
|
7
|
+
/**
|
|
8
|
+
* Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.
|
|
9
|
+
*
|
|
10
|
+
* @param object - The object to query.
|
|
11
|
+
* @param path - The path of the property to get.
|
|
12
|
+
* @param [defaultValue] - The value returned if the resolved value is undefined.
|
|
13
|
+
* @returns Returns the resolved value.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* const object = { a: { b: { c: 1 } } };
|
|
17
|
+
* get(object, 'a.b.c');
|
|
18
|
+
* // => 1
|
|
19
|
+
*
|
|
20
|
+
* get(object, ['a', 'b', 'c']);
|
|
21
|
+
* // => 1
|
|
22
|
+
*
|
|
23
|
+
* get(object, 'a.b.d', 'default');
|
|
24
|
+
* // => 'default'
|
|
25
|
+
*/
|
|
26
|
+
function get(object, path, defaultValue) {
|
|
27
|
+
if (object == null) return defaultValue;
|
|
28
|
+
switch (typeof path) {
|
|
29
|
+
case "string": {
|
|
30
|
+
if (isUnsafeProperty(path)) return defaultValue;
|
|
31
|
+
const result = object[path];
|
|
32
|
+
if (result === void 0) {
|
|
33
|
+
if (isDeepKey(path) && !hasOwn(object, path)) return get(object, toPath(path), defaultValue);
|
|
34
|
+
else return defaultValue;
|
|
35
|
+
}
|
|
36
|
+
return result;
|
|
37
|
+
}
|
|
38
|
+
case "number":
|
|
39
|
+
case "symbol": {
|
|
40
|
+
if (typeof path === "number") path = toKey(path);
|
|
41
|
+
const result = object[path];
|
|
42
|
+
if (result === void 0) return defaultValue;
|
|
43
|
+
return result;
|
|
44
|
+
}
|
|
45
|
+
default: {
|
|
46
|
+
if (Array.isArray(path)) return getWithPath(object, path, defaultValue);
|
|
47
|
+
if (Object.is(path === null || path === void 0 ? void 0 : path.valueOf(), -0)) path = "-0";
|
|
48
|
+
else path = String(path);
|
|
49
|
+
if (isUnsafeProperty(path)) return defaultValue;
|
|
50
|
+
const result = object[path];
|
|
51
|
+
if (result === void 0) return defaultValue;
|
|
52
|
+
return result;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
function getWithPath(object, path, defaultValue) {
|
|
57
|
+
if (path.length === 0) return defaultValue;
|
|
58
|
+
let current = object;
|
|
59
|
+
for (let index = 0; index < path.length; index++) {
|
|
60
|
+
if (current == null) return defaultValue;
|
|
61
|
+
if (isUnsafeProperty(path[index])) return defaultValue;
|
|
62
|
+
current = current[path[index]];
|
|
63
|
+
}
|
|
64
|
+
if (current === void 0) return defaultValue;
|
|
65
|
+
return current;
|
|
66
|
+
}
|
|
67
|
+
export { get };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { hasOwn } from "../_internal/hasOwn.mjs";
|
|
2
|
+
import { isDeepKey } from "../_internal/isDeepKey.mjs";
|
|
3
|
+
import { toKey } from "../_internal/toKey.mjs";
|
|
4
|
+
import { toPath } from "../util/toPath.mjs";
|
|
5
|
+
import { isIndex } from "../_internal/isIndex.mjs";
|
|
6
|
+
import { isArguments } from "../predicate/isArguments.mjs";
|
|
7
|
+
// node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/object/has.mjs
|
|
8
|
+
/**
|
|
9
|
+
* Checks if a given path exists within an object.
|
|
10
|
+
*
|
|
11
|
+
* You can provide the path as a single property key, an array of property keys,
|
|
12
|
+
* or a string representing a deep path.
|
|
13
|
+
*
|
|
14
|
+
* If the path is an index and the object is an array or an arguments object, the function will verify
|
|
15
|
+
* if the index is valid and within the bounds of the array or arguments object, even if the array or
|
|
16
|
+
* arguments object is sparse (i.e., not all indexes are defined).
|
|
17
|
+
*
|
|
18
|
+
* @param object - The object to query.
|
|
19
|
+
* @param path - The path to check. This can be a single property key,
|
|
20
|
+
* an array of property keys, or a string representing a deep path.
|
|
21
|
+
* @returns Returns `true` if the path exists in the object, `false` otherwise.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
*
|
|
25
|
+
* const obj = { a: { b: { c: 3 } } };
|
|
26
|
+
*
|
|
27
|
+
* has(obj, 'a'); // true
|
|
28
|
+
* has(obj, ['a', 'b']); // true
|
|
29
|
+
* has(obj, ['a', 'b', 'c']); // true
|
|
30
|
+
* has(obj, 'a.b.c'); // true
|
|
31
|
+
* has(obj, 'a.b.d'); // false
|
|
32
|
+
* has(obj, ['a', 'b', 'c', 'd']); // false
|
|
33
|
+
* has([], 0); // false
|
|
34
|
+
* has([1, 2, 3], 2); // true
|
|
35
|
+
* has([1, 2, 3], 5); // false
|
|
36
|
+
*/
|
|
37
|
+
function has(object, path) {
|
|
38
|
+
let resolvedPath;
|
|
39
|
+
if (Array.isArray(path)) resolvedPath = path;
|
|
40
|
+
else if (typeof path === "string" && isDeepKey(path) && !(path in Object(object))) resolvedPath = toPath(path);
|
|
41
|
+
else resolvedPath = [path];
|
|
42
|
+
if (resolvedPath.length === 0) return false;
|
|
43
|
+
let current = object;
|
|
44
|
+
for (let i = 0; i < resolvedPath.length; i++) {
|
|
45
|
+
const key = toKey(resolvedPath[i]);
|
|
46
|
+
if (current == null || !hasOwn(current, key)) {
|
|
47
|
+
if (!((Array.isArray(current) || isArguments(current)) && isIndex(key) && Number(key) < current.length)) return false;
|
|
48
|
+
}
|
|
49
|
+
current = current[key];
|
|
50
|
+
}
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
export { has };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { get } from "./get.mjs";
|
|
2
|
+
// node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/object/property.mjs
|
|
3
|
+
/**
|
|
4
|
+
* Creates a function that returns the value at a given path of an object.
|
|
5
|
+
*
|
|
6
|
+
* @template T - The type of object.
|
|
7
|
+
* @template R - The type of the value to return.
|
|
8
|
+
* @param path - The path of the property to get.
|
|
9
|
+
* @returns Returns a new function that takes an object and returns the value at the specified path.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* const getObjectValue = property('a.b.c');
|
|
13
|
+
* const result = getObjectValue({ a: { b: { c: 3 } } });
|
|
14
|
+
* console.log(result); // => 3
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* const getObjectValue = property(['a', 'b', 'c']);
|
|
18
|
+
* const result = getObjectValue({ a: { b: { c: 3 } } });
|
|
19
|
+
* console.log(result); // => 3
|
|
20
|
+
*/
|
|
21
|
+
function property(path) {
|
|
22
|
+
return function(object) {
|
|
23
|
+
return get(object, path);
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export { property };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { getTag } from "../_internal/getTag.mjs";
|
|
2
|
+
// node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/predicate/isArguments.mjs
|
|
3
|
+
/**
|
|
4
|
+
* Checks if the given value is an arguments object.
|
|
5
|
+
*
|
|
6
|
+
* This function tests whether the provided value is an arguments object or not.
|
|
7
|
+
* It returns `true` if the value is an arguments object, and `false` otherwise.
|
|
8
|
+
*
|
|
9
|
+
* This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to an arguments object.
|
|
10
|
+
*
|
|
11
|
+
* @param value - The value to test if it is an arguments object.
|
|
12
|
+
* @returns `true` if the value is an arguments, `false` otherwise.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* const args = (function() { return arguments; })();
|
|
16
|
+
* const strictArgs = (function() { 'use strict'; return arguments; })();
|
|
17
|
+
* const value = [1, 2, 3];
|
|
18
|
+
*
|
|
19
|
+
* console.log(isArguments(args)); // true
|
|
20
|
+
* console.log(isArguments(strictArgs)); // true
|
|
21
|
+
* console.log(isArguments(value)); // false
|
|
22
|
+
*/
|
|
23
|
+
function isArguments(value) {
|
|
24
|
+
return value !== null && typeof value === "object" && getTag(value) === "[object Arguments]";
|
|
25
|
+
}
|
|
26
|
+
export { isArguments };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { isBuffer as isBuffer$1 } from "../../predicate/isBuffer.mjs";
|
|
2
|
+
// node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/predicate/isBuffer.mjs
|
|
3
|
+
/**
|
|
4
|
+
* Checks if the given value is a Buffer instance.
|
|
5
|
+
*
|
|
6
|
+
* This function tests whether the provided value is an instance of Buffer.
|
|
7
|
+
* It returns `true` if the value is a Buffer, and `false` otherwise.
|
|
8
|
+
*
|
|
9
|
+
* This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `Buffer`.
|
|
10
|
+
*
|
|
11
|
+
* @param x - The value to check if it is a Buffer.
|
|
12
|
+
* @returns Returns `true` if `x` is a Buffer, else `false`.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* const buffer = Buffer.from("test");
|
|
16
|
+
* console.log(isBuffer(buffer)); // true
|
|
17
|
+
*
|
|
18
|
+
* const notBuffer = "not a buffer";
|
|
19
|
+
* console.log(isBuffer(notBuffer)); // false
|
|
20
|
+
*/
|
|
21
|
+
function isBuffer(x) {
|
|
22
|
+
return isBuffer$1(x);
|
|
23
|
+
}
|
|
24
|
+
export { isBuffer };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { isMatchWith } from "./isMatchWith.mjs";
|
|
2
|
+
// node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/predicate/isMatch.mjs
|
|
3
|
+
/**
|
|
4
|
+
* Checks if the target matches the source by comparing their structures and values.
|
|
5
|
+
* This function supports deep comparison for objects, arrays, maps, and sets.
|
|
6
|
+
*
|
|
7
|
+
* @param target - The target value to match against.
|
|
8
|
+
* @param source - The source value to match with.
|
|
9
|
+
* @returns Returns `true` if the target matches the source, otherwise `false`.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* // Basic usage
|
|
13
|
+
* isMatch({ a: 1, b: 2 }, { a: 1 }); // true
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* // Matching arrays
|
|
17
|
+
* isMatch([1, 2, 3], [1, 2, 3]); // true
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* // Matching maps
|
|
21
|
+
* const targetMap = new Map([['key1', 'value1'], ['key2', 'value2']]);
|
|
22
|
+
* const sourceMap = new Map([['key1', 'value1']]);
|
|
23
|
+
* isMatch(targetMap, sourceMap); // true
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* // Matching sets
|
|
27
|
+
* const targetSet = new Set([1, 2, 3]);
|
|
28
|
+
* const sourceSet = new Set([1, 2]);
|
|
29
|
+
* isMatch(targetSet, sourceSet); // true
|
|
30
|
+
*/
|
|
31
|
+
function isMatch(target, source) {
|
|
32
|
+
return isMatchWith(target, source, () => void 0);
|
|
33
|
+
}
|
|
34
|
+
export { isMatch };
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { isPrimitive } from "../../predicate/isPrimitive.mjs";
|
|
2
|
+
import { getTag } from "../_internal/getTag.mjs";
|
|
3
|
+
import { eq } from "../util/eq.mjs";
|
|
4
|
+
import { isObject } from "./isObject.mjs";
|
|
5
|
+
// node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/predicate/isMatchWith.mjs
|
|
6
|
+
/**
|
|
7
|
+
* Performs a deep comparison between a target value and a source pattern to determine if they match,
|
|
8
|
+
* using a custom comparison function for fine-grained control over the matching logic.
|
|
9
|
+
*
|
|
10
|
+
* This function recursively traverses both values, calling the custom compare function for each
|
|
11
|
+
* property/element pair. If the compare function returns a boolean, that result is used directly.
|
|
12
|
+
* If it returns undefined, the default matching behavior continues recursively.
|
|
13
|
+
*
|
|
14
|
+
* The matching behavior varies by data type:
|
|
15
|
+
* - **Objects**: Matches if all properties in the source exist in the target and match
|
|
16
|
+
* - **Arrays**: Matches if all elements in the source array can be found in the target array (order-independent)
|
|
17
|
+
* - **Maps**: Matches if all key-value pairs in the source Map exist and match in the target Map
|
|
18
|
+
* - **Sets**: Matches if all elements in the source Set can be found in the target Set
|
|
19
|
+
* - **Functions**: Matches using strict equality, or object comparison if the function has properties
|
|
20
|
+
* - **Primitives**: Matches using strict equality
|
|
21
|
+
*
|
|
22
|
+
* Special cases:
|
|
23
|
+
* - Empty arrays, Maps, and Sets always match any target
|
|
24
|
+
* - An empty object matches any target at the top level, but at nested levels it only matches object targets
|
|
25
|
+
* - `null` and `undefined` source values have specific matching rules
|
|
26
|
+
* - Circular references are handled using an internal stack to prevent infinite recursion
|
|
27
|
+
*
|
|
28
|
+
* @param target - The value to be tested for matching
|
|
29
|
+
* @param source - The pattern/template to match against
|
|
30
|
+
* @param [compare] - Optional custom comparison function that receives:
|
|
31
|
+
* - `objValue` - The value from the target at the current path
|
|
32
|
+
* - `srcValue` - The value from the source at the current path
|
|
33
|
+
* - `key` - The property key or array index being compared
|
|
34
|
+
* - `object` - The parent object/array from the target
|
|
35
|
+
* - `source` - The parent object/array from the source
|
|
36
|
+
* - `stack` - Internal Map used for circular reference detection
|
|
37
|
+
* Should return `true` for a match, `false` for no match, or `undefined` to continue with default behavior
|
|
38
|
+
*
|
|
39
|
+
* @returns `true` if the target matches the source pattern, `false` otherwise
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* // Basic matching without custom comparator
|
|
43
|
+
* isMatchWith({ a: 1, b: 2 }, { a: 1 }); // true
|
|
44
|
+
* isMatchWith([1, 2, 3], [1, 3]); // true
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* // Custom comparison for case-insensitive string matching
|
|
48
|
+
* const caseInsensitiveCompare = (objVal, srcVal) => {
|
|
49
|
+
* if (typeof objVal === 'string' && typeof srcVal === 'string') {
|
|
50
|
+
* return objVal.toLowerCase() === srcVal.toLowerCase();
|
|
51
|
+
* }
|
|
52
|
+
* return undefined; // Use default behavior for non-strings
|
|
53
|
+
* };
|
|
54
|
+
*
|
|
55
|
+
* isMatchWith(
|
|
56
|
+
* { name: 'JOHN', age: 30 },
|
|
57
|
+
* { name: 'john' },
|
|
58
|
+
* caseInsensitiveCompare
|
|
59
|
+
* ); // true
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* // Custom comparison for range matching
|
|
63
|
+
* const rangeCompare = (objVal, srcVal, key) => {
|
|
64
|
+
* if (key === 'age' && typeof srcVal === 'object' && srcVal.min !== undefined) {
|
|
65
|
+
* return objVal >= srcVal.min && objVal <= srcVal.max;
|
|
66
|
+
* }
|
|
67
|
+
* return undefined;
|
|
68
|
+
* };
|
|
69
|
+
*
|
|
70
|
+
* isMatchWith(
|
|
71
|
+
* { name: 'John', age: 25 },
|
|
72
|
+
* { age: { min: 18, max: 30 } },
|
|
73
|
+
* rangeCompare
|
|
74
|
+
* ); // true
|
|
75
|
+
*/
|
|
76
|
+
function isMatchWith(target, source, compare) {
|
|
77
|
+
if (typeof compare !== "function") return isMatchWith(target, source, () => void 0);
|
|
78
|
+
return isMatchWithInternal(target, source, function doesMatch(objValue, srcValue, key, object, source, stack) {
|
|
79
|
+
const isEqual = compare(objValue, srcValue, key, object, source, stack);
|
|
80
|
+
if (isEqual !== void 0) return Boolean(isEqual);
|
|
81
|
+
return isMatchWithInternal(objValue, srcValue, doesMatch, stack, false);
|
|
82
|
+
}, /* @__PURE__ */ new Map(), true);
|
|
83
|
+
}
|
|
84
|
+
function isMatchWithInternal(target, source, compare, stack, isRoot = false) {
|
|
85
|
+
if (source === target) return true;
|
|
86
|
+
switch (typeof source) {
|
|
87
|
+
case "object": return isObjectMatch(target, source, compare, stack, isRoot);
|
|
88
|
+
case "function":
|
|
89
|
+
if (Object.keys(source).length > 0) return isMatchWithInternal(target, Object.assign({}, source), compare, stack, isRoot);
|
|
90
|
+
return eq(target, source);
|
|
91
|
+
default:
|
|
92
|
+
if (!isObject(target)) return eq(target, source);
|
|
93
|
+
if (isRoot) {
|
|
94
|
+
if (typeof source === "string") return source === "";
|
|
95
|
+
return true;
|
|
96
|
+
}
|
|
97
|
+
return eq(target, source);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
function isObjectMatch(target, source, compare, stack, isRoot = false) {
|
|
101
|
+
if (source == null) return true;
|
|
102
|
+
if (Array.isArray(source)) return isArrayMatch(target, source, compare, stack);
|
|
103
|
+
if (source instanceof Map) return isMapMatch(target, source, compare, stack);
|
|
104
|
+
if (source instanceof Set) return isSetMatch(target, source, compare, stack);
|
|
105
|
+
const keys = Object.keys(source);
|
|
106
|
+
if (target == null) return isRoot && keys.length === 0;
|
|
107
|
+
if (isRoot) {
|
|
108
|
+
if (isPrimitive(target)) target = Object(target);
|
|
109
|
+
} else {
|
|
110
|
+
if (getTag(source) === "[object Error]") return getTag(target) === "[object Error]" && target.name === source.name && target.message === source.message;
|
|
111
|
+
const tag = getTag(target);
|
|
112
|
+
if (tag !== "[object Object]" && tag !== "[object Arguments]") return false;
|
|
113
|
+
}
|
|
114
|
+
if (keys.length === 0) return true;
|
|
115
|
+
if (stack === null || stack === void 0 ? void 0 : stack.has(source)) return stack.get(source) === target;
|
|
116
|
+
stack === null || stack === void 0 || stack.set(source, target);
|
|
117
|
+
try {
|
|
118
|
+
for (let i = 0; i < keys.length; i++) {
|
|
119
|
+
const key = keys[i];
|
|
120
|
+
if (!(key in target)) return false;
|
|
121
|
+
if (source[key] === void 0 && target[key] !== void 0) return false;
|
|
122
|
+
if (source[key] === null && target[key] !== null) return false;
|
|
123
|
+
if (!compare(target[key], source[key], key, target, source, stack)) return false;
|
|
124
|
+
}
|
|
125
|
+
return true;
|
|
126
|
+
} finally {
|
|
127
|
+
stack === null || stack === void 0 || stack.delete(source);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
function isMapMatch(target, source, compare, stack) {
|
|
131
|
+
if (source.size === 0) return true;
|
|
132
|
+
if (!(target instanceof Map)) return false;
|
|
133
|
+
for (const [key, sourceValue] of source.entries()) if (compare(target.get(key), sourceValue, key, target, source, stack) === false) return false;
|
|
134
|
+
return true;
|
|
135
|
+
}
|
|
136
|
+
function isArrayMatch(target, source, compare, stack) {
|
|
137
|
+
if (source.length === 0) return true;
|
|
138
|
+
if (!Array.isArray(target)) return false;
|
|
139
|
+
const countedIndex = /* @__PURE__ */ new Set();
|
|
140
|
+
for (let i = 0; i < source.length; i++) {
|
|
141
|
+
const sourceItem = source[i];
|
|
142
|
+
let found = false;
|
|
143
|
+
for (let j = 0; j < target.length; j++) {
|
|
144
|
+
if (countedIndex.has(j)) continue;
|
|
145
|
+
const targetItem = target[j];
|
|
146
|
+
let matches = false;
|
|
147
|
+
if (compare(targetItem, sourceItem, i, target, source, stack)) matches = true;
|
|
148
|
+
if (matches) {
|
|
149
|
+
countedIndex.add(j);
|
|
150
|
+
found = true;
|
|
151
|
+
break;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
if (!found) return false;
|
|
155
|
+
}
|
|
156
|
+
return true;
|
|
157
|
+
}
|
|
158
|
+
function isSetMatch(target, source, compare, stack) {
|
|
159
|
+
if (source.size === 0) return true;
|
|
160
|
+
if (!(target instanceof Set)) return false;
|
|
161
|
+
return isArrayMatch([...target], [...source], compare, stack);
|
|
162
|
+
}
|
|
163
|
+
export { isMatchWith, isSetMatch };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { isNumber } from "./isNumber.mjs";
|
|
2
|
+
// node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/predicate/isNaN.mjs
|
|
3
|
+
/**
|
|
4
|
+
* Checks if the value is NaN.
|
|
5
|
+
*
|
|
6
|
+
* @param value - The value to check.
|
|
7
|
+
* @returns `true` if the value is NaN, `false` otherwise.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* isNaN(NaN); // true
|
|
11
|
+
* isNaN(0); // false
|
|
12
|
+
* isNaN('NaN'); // false
|
|
13
|
+
* isNaN(undefined); // false
|
|
14
|
+
*/
|
|
15
|
+
function isNaN(value) {
|
|
16
|
+
return isNumber(value) && Number.isNaN(Number(value));
|
|
17
|
+
}
|
|
18
|
+
export { isNaN };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/predicate/isNil.mjs
|
|
2
|
+
/**
|
|
3
|
+
* Checks if a given value is null or undefined.
|
|
4
|
+
*
|
|
5
|
+
* This function tests whether the provided value is either `null` or `undefined`.
|
|
6
|
+
* It returns `true` if the value is `null` or `undefined`, and `false` otherwise.
|
|
7
|
+
*
|
|
8
|
+
* This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `null` or `undefined`.
|
|
9
|
+
*
|
|
10
|
+
* @param x - The value to test for null or undefined.
|
|
11
|
+
* @returns `true` if the value is null or undefined, `false` otherwise.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* const value1 = null;
|
|
15
|
+
* const value2 = undefined;
|
|
16
|
+
* const value3 = 42;
|
|
17
|
+
* const result1 = isNil(value1); // true
|
|
18
|
+
* const result2 = isNil(value2); // true
|
|
19
|
+
* const result3 = isNil(value3); // false
|
|
20
|
+
*/
|
|
21
|
+
function isNil(x) {
|
|
22
|
+
return x == null;
|
|
23
|
+
}
|
|
24
|
+
export { isNil };
|