@ls-stack/utils 3.65.0 → 3.66.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/dist/{arrayUtils.d.cts → arrayUtils.d.mts} +24 -23
- package/dist/arrayUtils.mjs +249 -0
- package/dist/assertions-qMxfVhSu.mjs +207 -0
- package/dist/{assertions.d.ts → assertions.d.mts} +4 -3
- package/dist/assertions.mjs +3 -0
- package/dist/asyncQueue.d.mts +497 -0
- package/dist/asyncQueue.mjs +757 -0
- package/dist/{awaitDebounce.d.cts → awaitDebounce.d.mts} +11 -6
- package/dist/awaitDebounce.mjs +54 -0
- package/dist/{cache.d.ts → cache.d.mts} +76 -68
- package/dist/cache.mjs +355 -0
- package/dist/castValues-DfICShCc.mjs +19 -0
- package/dist/{castValues.d.cts → castValues.d.mts} +3 -2
- package/dist/castValues.mjs +3 -0
- package/dist/{concurrentCalls.d.ts → concurrentCalls.d.mts} +74 -65
- package/dist/concurrentCalls.mjs +295 -0
- package/dist/consoleFmt.d.mts +55 -0
- package/dist/consoleFmt.mjs +63 -0
- package/dist/conversions-DTmwEMIu.mjs +12 -0
- package/dist/conversions.d.mts +4 -0
- package/dist/conversions.mjs +3 -0
- package/dist/createThrottleController.d.mts +18 -0
- package/dist/createThrottleController.mjs +40 -0
- package/dist/debounce.d.mts +47 -0
- package/dist/debounce.mjs +117 -0
- package/dist/dedent.d.mts +74 -0
- package/dist/dedent.mjs +80 -0
- package/dist/deepEqual-C7EZEixx.mjs +78 -0
- package/dist/{deepEqual.d.cts → deepEqual.d.mts} +3 -2
- package/dist/deepEqual.mjs +3 -0
- package/dist/{deepReplaceValues.d.cts → deepReplaceValues.d.mts} +4 -3
- package/dist/deepReplaceValues.mjs +61 -0
- package/dist/diffParser.d.mts +63 -0
- package/dist/diffParser.mjs +410 -0
- package/dist/enhancedMap.d.mts +21 -0
- package/dist/enhancedMap.mjs +69 -0
- package/dist/exhaustiveMatch.d.mts +10 -0
- package/dist/exhaustiveMatch.mjs +48 -0
- package/dist/{filterObjectOrArrayKeys.d.cts → filterObjectOrArrayKeys.d.mts} +15 -8
- package/dist/filterObjectOrArrayKeys.mjs +497 -0
- package/dist/{getAutoIncrementId.d.cts → getAutoIncrementId.d.mts} +9 -5
- package/dist/getAutoIncrementId.mjs +53 -0
- package/dist/{getCompositeKey.d.cts → getCompositeKey.d.mts} +3 -2
- package/dist/getCompositeKey.mjs +50 -0
- package/dist/{getValueStableKey.d.cts → getValueStableKey.d.mts} +5 -3
- package/dist/getValueStableKey.mjs +17 -0
- package/dist/{hash.d.cts → hash.d.mts} +3 -2
- package/dist/hash.mjs +28 -0
- package/dist/interpolate.d.mts +17 -0
- package/dist/interpolate.mjs +28 -0
- package/dist/{iteratorUtils.d.cts → iteratorUtils.d.mts} +5 -4
- package/dist/iteratorUtils.mjs +39 -0
- package/dist/keepPrevIfUnchanged.d.mts +12 -0
- package/dist/keepPrevIfUnchanged.mjs +9 -0
- package/dist/keyedMap.d.mts +76 -0
- package/dist/keyedMap.mjs +139 -0
- package/dist/keyedSet.d.mts +77 -0
- package/dist/keyedSet.mjs +129 -0
- package/dist/{levenshtein.d.cts → levenshtein.d.mts} +3 -2
- package/dist/levenshtein.mjs +121 -0
- package/dist/main.d.mts +4 -0
- package/dist/main.mjs +7 -0
- package/dist/matchPath.d.mts +50 -0
- package/dist/matchPath.mjs +81 -0
- package/dist/mathUtils-BDP1lM_z.mjs +81 -0
- package/dist/{mathUtils.d.cts → mathUtils.d.mts} +3 -2
- package/dist/mathUtils.mjs +3 -0
- package/dist/{mutationUtils.d.cts → mutationUtils.d.mts} +6 -5
- package/dist/mutationUtils.mjs +44 -0
- package/dist/{objUtils.d.ts → objUtils.d.mts} +8 -6
- package/dist/objUtils.mjs +115 -0
- package/dist/parallelAsyncCalls.d.mts +83 -0
- package/dist/parallelAsyncCalls.mjs +121 -0
- package/dist/partialEqual.d.mts +139 -0
- package/dist/partialEqual.mjs +1055 -0
- package/dist/promiseUtils.d.mts +9 -0
- package/dist/promiseUtils.mjs +17 -0
- package/dist/regexUtils.d.mts +18 -0
- package/dist/regexUtils.mjs +34 -0
- package/dist/{retryOnError.d.cts → retryOnError.d.mts} +38 -37
- package/dist/retryOnError.mjs +91 -0
- package/dist/{runShellCmd.d.ts → runShellCmd.d.mts} +24 -15
- package/dist/runShellCmd.mjs +151 -0
- package/dist/{safeJson.d.cts → safeJson.d.mts} +3 -2
- package/dist/safeJson.mjs +30 -0
- package/dist/{saferTyping.d.cts → saferTyping.d.mts} +4 -3
- package/dist/saferTyping.mjs +45 -0
- package/dist/serializeXML.d.mts +23 -0
- package/dist/serializeXML.mjs +74 -0
- package/dist/{shallowEqual.d.cts → shallowEqual.d.mts} +3 -2
- package/dist/shallowEqual.mjs +54 -0
- package/dist/sleep.d.mts +4 -0
- package/dist/sleep.mjs +7 -0
- package/dist/stringUtils-DjhWOiYn.mjs +113 -0
- package/dist/{stringUtils.d.cts → stringUtils.d.mts} +3 -2
- package/dist/stringUtils.mjs +3 -0
- package/dist/{testUtils.d.ts → testUtils.d.mts} +83 -52
- package/dist/testUtils.mjs +310 -0
- package/dist/{throttle.d.ts → throttle.d.mts} +18 -17
- package/dist/throttle.mjs +102 -0
- package/dist/time-sr2lhQRw.mjs +67 -0
- package/dist/{time.d.ts → time.d.mts} +8 -7
- package/dist/time.mjs +3 -0
- package/dist/{timers.d.cts → timers.d.mts} +22 -13
- package/dist/timers.mjs +220 -0
- package/dist/{tsResult.d.cts → tsResult.d.mts} +52 -48
- package/dist/tsResult.mjs +142 -0
- package/dist/typeGuards-B1mzA-Rz.mjs +128 -0
- package/dist/{typeGuards.d.cts → typeGuards.d.mts} +3 -2
- package/dist/typeGuards.mjs +3 -0
- package/dist/{typeUtils.d.ts → typeUtils.d.mts} +13 -34
- package/dist/typeUtils.mjs +1 -0
- package/dist/{typedStrings.d.cts → typedStrings.d.mts} +5 -4
- package/dist/typedStrings.mjs +131 -0
- package/dist/typingFnUtils-Bb8drgKF.mjs +101 -0
- package/dist/{typingFnUtils.d.cts → typingFnUtils.d.mts} +13 -22
- package/dist/typingFnUtils.mjs +3 -0
- package/dist/{typingTestUtils.d.cts → typingTestUtils.d.mts} +11 -15
- package/dist/typingTestUtils.mjs +80 -0
- package/dist/typingUtils.d.mts +20 -0
- package/dist/typingUtils.mjs +1 -0
- package/dist/yamlStringify.d.mts +17 -0
- package/dist/yamlStringify.mjs +189 -0
- package/package.json +65 -242
- package/dist/arrayUtils.cjs +0 -229
- package/dist/arrayUtils.d.ts +0 -171
- package/dist/arrayUtils.js +0 -42
- package/dist/assertions.cjs +0 -107
- package/dist/assertions.d.cts +0 -192
- package/dist/assertions.js +0 -25
- package/dist/asyncQueue.cjs +0 -672
- package/dist/asyncQueue.d.cts +0 -488
- package/dist/asyncQueue.d.ts +0 -488
- package/dist/asyncQueue.js +0 -631
- package/dist/awaitDebounce.cjs +0 -106
- package/dist/awaitDebounce.d.ts +0 -41
- package/dist/awaitDebounce.js +0 -28
- package/dist/cache.cjs +0 -367
- package/dist/cache.d.cts +0 -228
- package/dist/cache.js +0 -19
- package/dist/castValues.cjs +0 -50
- package/dist/castValues.d.ts +0 -4
- package/dist/castValues.js +0 -8
- package/dist/chunk-5DZT3Z5Z.js +0 -8
- package/dist/chunk-6FBIEPWU.js +0 -96
- package/dist/chunk-6FIBVC2P.js +0 -56
- package/dist/chunk-7CQPOM5I.js +0 -100
- package/dist/chunk-B6DNOZCP.js +0 -369
- package/dist/chunk-BM4PYVOX.js +0 -109
- package/dist/chunk-C2SVCIWE.js +0 -57
- package/dist/chunk-CCUPDGSZ.js +0 -132
- package/dist/chunk-DBOWTYR4.js +0 -49
- package/dist/chunk-DFXNVEH6.js +0 -14
- package/dist/chunk-DX2524CZ.js +0 -314
- package/dist/chunk-GMJTLFM6.js +0 -60
- package/dist/chunk-IATIXMCE.js +0 -20
- package/dist/chunk-II4R3VVX.js +0 -25
- package/dist/chunk-JF2MDHOJ.js +0 -40
- package/dist/chunk-JQFUKJU5.js +0 -71
- package/dist/chunk-MI4UE2PQ.js +0 -561
- package/dist/chunk-PUKVXYYL.js +0 -52
- package/dist/chunk-QQS7I7ZL.js +0 -16
- package/dist/chunk-VAAMRG4K.js +0 -20
- package/dist/chunk-WFQJUJTC.js +0 -182
- package/dist/chunk-ZXIKIA5B.js +0 -178
- package/dist/concurrentCalls.cjs +0 -406
- package/dist/concurrentCalls.d.cts +0 -116
- package/dist/concurrentCalls.js +0 -346
- package/dist/consoleFmt.cjs +0 -85
- package/dist/consoleFmt.d.cts +0 -54
- package/dist/consoleFmt.d.ts +0 -54
- package/dist/consoleFmt.js +0 -60
- package/dist/conversions.cjs +0 -44
- package/dist/conversions.d.cts +0 -3
- package/dist/conversions.d.ts +0 -3
- package/dist/conversions.js +0 -6
- package/dist/createThrottleController.cjs +0 -193
- package/dist/createThrottleController.d.cts +0 -13
- package/dist/createThrottleController.d.ts +0 -13
- package/dist/createThrottleController.js +0 -61
- package/dist/debounce.cjs +0 -157
- package/dist/debounce.d.cts +0 -46
- package/dist/debounce.d.ts +0 -46
- package/dist/debounce.js +0 -8
- package/dist/dedent.cjs +0 -104
- package/dist/dedent.d.cts +0 -73
- package/dist/dedent.d.ts +0 -73
- package/dist/dedent.js +0 -79
- package/dist/deepEqual.cjs +0 -96
- package/dist/deepEqual.d.ts +0 -21
- package/dist/deepEqual.js +0 -8
- package/dist/deepReplaceValues.cjs +0 -87
- package/dist/deepReplaceValues.d.ts +0 -27
- package/dist/deepReplaceValues.js +0 -7
- package/dist/enhancedMap.cjs +0 -131
- package/dist/enhancedMap.d.cts +0 -20
- package/dist/enhancedMap.d.ts +0 -20
- package/dist/enhancedMap.js +0 -10
- package/dist/exhaustiveMatch.cjs +0 -66
- package/dist/exhaustiveMatch.d.cts +0 -9
- package/dist/exhaustiveMatch.d.ts +0 -9
- package/dist/exhaustiveMatch.js +0 -40
- package/dist/filterObjectOrArrayKeys.cjs +0 -619
- package/dist/filterObjectOrArrayKeys.d.ts +0 -88
- package/dist/filterObjectOrArrayKeys.js +0 -9
- package/dist/getAutoIncrementId.cjs +0 -44
- package/dist/getAutoIncrementId.d.ts +0 -46
- package/dist/getAutoIncrementId.js +0 -18
- package/dist/getCompositeKey.cjs +0 -86
- package/dist/getCompositeKey.d.ts +0 -11
- package/dist/getCompositeKey.js +0 -8
- package/dist/getValueStableKey.cjs +0 -89
- package/dist/getValueStableKey.d.ts +0 -15
- package/dist/getValueStableKey.js +0 -11
- package/dist/hash.cjs +0 -57
- package/dist/hash.d.ts +0 -7
- package/dist/hash.js +0 -32
- package/dist/interpolate.cjs +0 -88
- package/dist/interpolate.d.cts +0 -11
- package/dist/interpolate.d.ts +0 -11
- package/dist/interpolate.js +0 -46
- package/dist/iteratorUtils.cjs +0 -73
- package/dist/iteratorUtils.d.ts +0 -10
- package/dist/iteratorUtils.js +0 -44
- package/dist/keepPrevIfUnchanged.cjs +0 -102
- package/dist/keepPrevIfUnchanged.d.cts +0 -7
- package/dist/keepPrevIfUnchanged.d.ts +0 -7
- package/dist/keepPrevIfUnchanged.js +0 -7
- package/dist/keyedMap.cjs +0 -224
- package/dist/keyedMap.d.cts +0 -75
- package/dist/keyedMap.d.ts +0 -75
- package/dist/keyedMap.js +0 -145
- package/dist/keyedSet.cjs +0 -205
- package/dist/keyedSet.d.cts +0 -76
- package/dist/keyedSet.d.ts +0 -76
- package/dist/keyedSet.js +0 -126
- package/dist/levenshtein.cjs +0 -180
- package/dist/levenshtein.d.ts +0 -5
- package/dist/levenshtein.js +0 -153
- package/dist/main.cjs +0 -32
- package/dist/main.d.cts +0 -3
- package/dist/main.d.ts +0 -3
- package/dist/main.js +0 -7
- package/dist/matchPath.cjs +0 -155
- package/dist/matchPath.d.cts +0 -53
- package/dist/matchPath.d.ts +0 -53
- package/dist/matchPath.js +0 -108
- package/dist/mathUtils.cjs +0 -81
- package/dist/mathUtils.d.ts +0 -54
- package/dist/mathUtils.js +0 -22
- package/dist/mutationUtils.cjs +0 -153
- package/dist/mutationUtils.d.ts +0 -15
- package/dist/mutationUtils.js +0 -55
- package/dist/objUtils.cjs +0 -242
- package/dist/objUtils.d.cts +0 -28
- package/dist/objUtils.js +0 -38
- package/dist/parallelAsyncCalls.cjs +0 -162
- package/dist/parallelAsyncCalls.d.cts +0 -82
- package/dist/parallelAsyncCalls.d.ts +0 -82
- package/dist/parallelAsyncCalls.js +0 -126
- package/dist/partialEqual.cjs +0 -1196
- package/dist/partialEqual.d.cts +0 -141
- package/dist/partialEqual.d.ts +0 -141
- package/dist/partialEqual.js +0 -1168
- package/dist/promiseUtils.cjs +0 -38
- package/dist/promiseUtils.d.cts +0 -8
- package/dist/promiseUtils.d.ts +0 -8
- package/dist/promiseUtils.js +0 -6
- package/dist/regexUtils.cjs +0 -60
- package/dist/regexUtils.d.cts +0 -17
- package/dist/regexUtils.d.ts +0 -17
- package/dist/regexUtils.js +0 -33
- package/dist/retryOnError.cjs +0 -130
- package/dist/retryOnError.d.ts +0 -83
- package/dist/retryOnError.js +0 -101
- package/dist/runShellCmd.cjs +0 -127
- package/dist/runShellCmd.d.cts +0 -90
- package/dist/runShellCmd.js +0 -98
- package/dist/safeJson.cjs +0 -45
- package/dist/safeJson.d.ts +0 -16
- package/dist/safeJson.js +0 -8
- package/dist/saferTyping.cjs +0 -52
- package/dist/saferTyping.d.ts +0 -47
- package/dist/saferTyping.js +0 -23
- package/dist/serializeXML.cjs +0 -154
- package/dist/serializeXML.d.cts +0 -22
- package/dist/serializeXML.d.ts +0 -22
- package/dist/serializeXML.js +0 -116
- package/dist/shallowEqual.cjs +0 -88
- package/dist/shallowEqual.d.ts +0 -4
- package/dist/shallowEqual.js +0 -63
- package/dist/sleep.cjs +0 -32
- package/dist/sleep.d.cts +0 -3
- package/dist/sleep.d.ts +0 -3
- package/dist/sleep.js +0 -6
- package/dist/stringUtils.cjs +0 -155
- package/dist/stringUtils.d.ts +0 -55
- package/dist/stringUtils.js +0 -50
- package/dist/testUtils.cjs +0 -1490
- package/dist/testUtils.d.cts +0 -133
- package/dist/testUtils.js +0 -359
- package/dist/throttle.cjs +0 -282
- package/dist/throttle.d.cts +0 -98
- package/dist/throttle.js +0 -38
- package/dist/time.cjs +0 -152
- package/dist/time.d.cts +0 -25
- package/dist/time.js +0 -38
- package/dist/timers.cjs +0 -194
- package/dist/timers.d.ts +0 -121
- package/dist/timers.js +0 -156
- package/dist/tsResult.cjs +0 -226
- package/dist/tsResult.d.ts +0 -114
- package/dist/tsResult.js +0 -180
- package/dist/typeGuards.cjs +0 -70
- package/dist/typeGuards.d.ts +0 -111
- package/dist/typeGuards.js +0 -18
- package/dist/typeUtils.cjs +0 -18
- package/dist/typeUtils.d.cts +0 -61
- package/dist/typeUtils.js +0 -0
- package/dist/typedStrings.cjs +0 -90
- package/dist/typedStrings.d.ts +0 -163
- package/dist/typedStrings.js +0 -57
- package/dist/typingFnUtils.cjs +0 -96
- package/dist/typingFnUtils.d.ts +0 -100
- package/dist/typingFnUtils.js +0 -30
- package/dist/typingTestUtils.cjs +0 -52
- package/dist/typingTestUtils.d.ts +0 -79
- package/dist/typingTestUtils.js +0 -27
- package/dist/typingUtils.cjs +0 -18
- package/dist/typingUtils.d.cts +0 -35
- package/dist/typingUtils.d.ts +0 -35
- package/dist/typingUtils.js +0 -0
- package/dist/yamlStringify.cjs +0 -423
- package/dist/yamlStringify.d.cts +0 -10
- package/dist/yamlStringify.d.ts +0 -10
- package/dist/yamlStringify.js +0 -9
package/dist/chunk-MI4UE2PQ.js
DELETED
|
@@ -1,561 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
sortBy
|
|
3
|
-
} from "./chunk-WFQJUJTC.js";
|
|
4
|
-
import {
|
|
5
|
-
isPlainObject
|
|
6
|
-
} from "./chunk-JF2MDHOJ.js";
|
|
7
|
-
|
|
8
|
-
// src/filterObjectOrArrayKeys.ts
|
|
9
|
-
var ID_PROP_REGEXP = /^(id_|key_|id-|key-)|(_id|_key|-id|-key)$/i;
|
|
10
|
-
function filterObjectOrArrayKeys(objOrArray, {
|
|
11
|
-
filterKeys,
|
|
12
|
-
rejectKeys,
|
|
13
|
-
rejectEmptyObjectsInArray = true,
|
|
14
|
-
sortKeys = "simpleValuesFirst",
|
|
15
|
-
sortPatterns
|
|
16
|
-
}) {
|
|
17
|
-
function getNestedValue(obj, path) {
|
|
18
|
-
const parts = path.split(".");
|
|
19
|
-
let current = obj;
|
|
20
|
-
for (const part of parts) {
|
|
21
|
-
if (current == null || typeof current !== "object") {
|
|
22
|
-
return void 0;
|
|
23
|
-
}
|
|
24
|
-
current = current[part];
|
|
25
|
-
}
|
|
26
|
-
return current;
|
|
27
|
-
}
|
|
28
|
-
function evaluateCondition(item, condition) {
|
|
29
|
-
const value = getNestedValue(item, condition.property);
|
|
30
|
-
let valueStr = String(value);
|
|
31
|
-
if (condition.caseInsensitive) {
|
|
32
|
-
valueStr = valueStr.toLowerCase();
|
|
33
|
-
}
|
|
34
|
-
const processValue = (v) => condition.caseInsensitive ? v.toLowerCase() : v;
|
|
35
|
-
switch (condition.operator) {
|
|
36
|
-
case "=":
|
|
37
|
-
return condition.values.some((v) => valueStr === processValue(v));
|
|
38
|
-
case "!=":
|
|
39
|
-
return condition.values.every((v) => valueStr !== processValue(v));
|
|
40
|
-
case "*=":
|
|
41
|
-
return condition.values.some((v) => valueStr.includes(processValue(v)));
|
|
42
|
-
case "!*=":
|
|
43
|
-
return condition.values.every(
|
|
44
|
-
(v) => !valueStr.includes(processValue(v))
|
|
45
|
-
);
|
|
46
|
-
case "^=":
|
|
47
|
-
return condition.values.some(
|
|
48
|
-
(v) => valueStr.startsWith(processValue(v))
|
|
49
|
-
);
|
|
50
|
-
case "!^=":
|
|
51
|
-
return condition.values.every(
|
|
52
|
-
(v) => !valueStr.startsWith(processValue(v))
|
|
53
|
-
);
|
|
54
|
-
case "$=":
|
|
55
|
-
return condition.values.some((v) => valueStr.endsWith(processValue(v)));
|
|
56
|
-
case "!$=":
|
|
57
|
-
return condition.values.every(
|
|
58
|
-
(v) => !valueStr.endsWith(processValue(v))
|
|
59
|
-
);
|
|
60
|
-
default:
|
|
61
|
-
return false;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
const toArray = (v) => v === void 0 ? [] : Array.isArray(v) ? v : [v];
|
|
65
|
-
const filterPatternsRaw = toArray(filterKeys);
|
|
66
|
-
const rejectPatternsRaw = toArray(rejectKeys);
|
|
67
|
-
const hasFilters = filterPatternsRaw.length > 0;
|
|
68
|
-
const hasRejects = rejectPatternsRaw.length > 0;
|
|
69
|
-
const expandedFilterPatterns = filterPatternsRaw.flatMap(expandPatterns);
|
|
70
|
-
const expandedRejectPatterns = rejectPatternsRaw.flatMap(expandPatterns);
|
|
71
|
-
const { filterOnlyPatterns, combinedPatterns } = separateFilterPatterns(
|
|
72
|
-
expandedFilterPatterns
|
|
73
|
-
);
|
|
74
|
-
const filterPatterns = filterOnlyPatterns.map(parsePattern);
|
|
75
|
-
const rejectPatterns = expandedRejectPatterns.map(parsePattern);
|
|
76
|
-
const sortPatternsRaw = toArray(sortPatterns);
|
|
77
|
-
const expandedSortPatterns = sortPatternsRaw.flatMap(expandPatterns);
|
|
78
|
-
const sortPatternsParsed = expandedSortPatterns.map(parsePattern);
|
|
79
|
-
let dataToProcess = objOrArray;
|
|
80
|
-
if (combinedPatterns.length > 0) {
|
|
81
|
-
const groupedByFilter = /* @__PURE__ */ new Map();
|
|
82
|
-
for (const { filterPart, fieldPart } of combinedPatterns) {
|
|
83
|
-
if (!groupedByFilter.has(filterPart)) {
|
|
84
|
-
groupedByFilter.set(filterPart, []);
|
|
85
|
-
}
|
|
86
|
-
groupedByFilter.get(filterPart).push(fieldPart);
|
|
87
|
-
}
|
|
88
|
-
const combinedResult = Array.isArray(objOrArray) ? [] : {};
|
|
89
|
-
for (const [filterPart, fieldParts] of groupedByFilter) {
|
|
90
|
-
const filteredResult = filterObjectOrArrayKeys(objOrArray, {
|
|
91
|
-
filterKeys: [filterPart],
|
|
92
|
-
rejectKeys,
|
|
93
|
-
rejectEmptyObjectsInArray
|
|
94
|
-
});
|
|
95
|
-
const fieldSelectedResult = filterObjectOrArrayKeys(filteredResult, {
|
|
96
|
-
filterKeys: fieldParts,
|
|
97
|
-
rejectEmptyObjectsInArray
|
|
98
|
-
});
|
|
99
|
-
if (Array.isArray(combinedResult) && Array.isArray(fieldSelectedResult)) {
|
|
100
|
-
combinedResult.push(...fieldSelectedResult);
|
|
101
|
-
} else if (!Array.isArray(combinedResult) && !Array.isArray(fieldSelectedResult)) {
|
|
102
|
-
Object.assign(combinedResult, fieldSelectedResult);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
if (filterOnlyPatterns.length === 0) {
|
|
106
|
-
return combinedResult;
|
|
107
|
-
}
|
|
108
|
-
dataToProcess = combinedResult;
|
|
109
|
-
}
|
|
110
|
-
function matchPath(path, pattern, value) {
|
|
111
|
-
function rec(pi, pti) {
|
|
112
|
-
if (pti >= pattern.length) return pi === path.length;
|
|
113
|
-
const pt = pattern[pti];
|
|
114
|
-
if (pt.type === "WILDCARD_ANY") {
|
|
115
|
-
if (rec(pi, pti + 1)) return true;
|
|
116
|
-
if (pi < path.length) return rec(pi + 1, pti);
|
|
117
|
-
return false;
|
|
118
|
-
}
|
|
119
|
-
if (pt.type === "WILDCARD_ONE") {
|
|
120
|
-
let j = pi;
|
|
121
|
-
let sawKey = false;
|
|
122
|
-
while (j < path.length) {
|
|
123
|
-
if (path[j].type === "KEY") sawKey = true;
|
|
124
|
-
if (sawKey && rec(j, pti + 1)) return true;
|
|
125
|
-
j += 1;
|
|
126
|
-
}
|
|
127
|
-
return false;
|
|
128
|
-
}
|
|
129
|
-
if (pi >= path.length) return false;
|
|
130
|
-
const ct = path[pi];
|
|
131
|
-
switch (pt.type) {
|
|
132
|
-
case "KEY":
|
|
133
|
-
if (ct.type === "KEY" && ct.name === pt.name)
|
|
134
|
-
return rec(pi + 1, pti + 1);
|
|
135
|
-
if (ct.type === "INDEX") return rec(pi + 1, pti);
|
|
136
|
-
return false;
|
|
137
|
-
case "INDEX":
|
|
138
|
-
if (ct.type === "INDEX" && ct.index === pt.index)
|
|
139
|
-
return rec(pi + 1, pti + 1);
|
|
140
|
-
return false;
|
|
141
|
-
case "INDEX_ANY":
|
|
142
|
-
if (ct.type === "INDEX") return rec(pi + 1, pti + 1);
|
|
143
|
-
return false;
|
|
144
|
-
case "INDEX_RANGE":
|
|
145
|
-
if (ct.type === "INDEX") {
|
|
146
|
-
const okLower = ct.index >= pt.start;
|
|
147
|
-
const okUpper = pt.end === null ? true : ct.index <= pt.end;
|
|
148
|
-
if (okLower && okUpper) return rec(pi + 1, pti + 1);
|
|
149
|
-
}
|
|
150
|
-
return false;
|
|
151
|
-
case "INDEX_FILTER":
|
|
152
|
-
if (ct.type === "INDEX" && value !== void 0) {
|
|
153
|
-
const results = pt.conditions.map(
|
|
154
|
-
(cond) => evaluateCondition(value, cond)
|
|
155
|
-
);
|
|
156
|
-
const matches = pt.logic === "AND" ? results.every((r) => r) : results.some((r) => r);
|
|
157
|
-
if (matches) return rec(pi + 1, pti + 1);
|
|
158
|
-
}
|
|
159
|
-
return false;
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
return rec(0, 0);
|
|
163
|
-
}
|
|
164
|
-
const matchesAnyFilter = (path, value) => filterPatterns.some((p) => matchPath(path, p, value));
|
|
165
|
-
const matchesAnyReject = (path, value) => rejectPatterns.some((p) => matchPath(path, p, value));
|
|
166
|
-
function getSortPriority(path) {
|
|
167
|
-
for (let i = 0; i < sortPatternsParsed.length; i++) {
|
|
168
|
-
if (matchPath(path, sortPatternsParsed[i])) {
|
|
169
|
-
return i;
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
return sortPatternsParsed.length;
|
|
173
|
-
}
|
|
174
|
-
function applySortKeys(keys, obj, sortOrder) {
|
|
175
|
-
if (sortOrder === "asc") {
|
|
176
|
-
return [...keys].sort();
|
|
177
|
-
}
|
|
178
|
-
if (sortOrder === "desc") {
|
|
179
|
-
return [...keys].sort().reverse();
|
|
180
|
-
}
|
|
181
|
-
return sortBy(
|
|
182
|
-
sortBy(keys, (k) => k),
|
|
183
|
-
(key) => {
|
|
184
|
-
const value = obj[key];
|
|
185
|
-
if (value !== void 0 && value !== null) {
|
|
186
|
-
if (Array.isArray(value) && value.length === 0) return 0;
|
|
187
|
-
if (isPlainObject(value)) {
|
|
188
|
-
const objLength = Object.keys(value).length;
|
|
189
|
-
return 1.99 + objLength * -1e-3;
|
|
190
|
-
}
|
|
191
|
-
if (Array.isArray(value)) {
|
|
192
|
-
const allItemsArePrimitives = value.every(
|
|
193
|
-
(item) => typeof item === "string" || typeof item === "number" || typeof item === "boolean" || item === null || item === void 0
|
|
194
|
-
);
|
|
195
|
-
if (allItemsArePrimitives) {
|
|
196
|
-
return 1.9 + value.length * -1e-3;
|
|
197
|
-
} else {
|
|
198
|
-
return 1.5 + value.length * -0.01;
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
if (key === "id" || key === "key") return 5;
|
|
202
|
-
if (ID_PROP_REGEXP.test(key)) return 4.5;
|
|
203
|
-
if (typeof value === "boolean") return 4;
|
|
204
|
-
if (typeof value === "number") return 3.5;
|
|
205
|
-
if (typeof value === "string" && value.length < 20) return 3;
|
|
206
|
-
return 2;
|
|
207
|
-
}
|
|
208
|
-
return 0;
|
|
209
|
-
},
|
|
210
|
-
"desc"
|
|
211
|
-
);
|
|
212
|
-
}
|
|
213
|
-
function sortKeysWithPatterns(keys_, obj, currentPath) {
|
|
214
|
-
if (!sortKeys && sortPatternsParsed.length === 0) {
|
|
215
|
-
return keys_;
|
|
216
|
-
}
|
|
217
|
-
let keysToSort = keys_;
|
|
218
|
-
if (sortKeys) {
|
|
219
|
-
keysToSort = applySortKeys(keysToSort, obj, sortKeys);
|
|
220
|
-
}
|
|
221
|
-
const sortedKeys = [...keysToSort].sort((a, b) => {
|
|
222
|
-
const pathA = currentPath.concat({ type: "KEY", name: a });
|
|
223
|
-
const pathB = currentPath.concat({ type: "KEY", name: b });
|
|
224
|
-
const priorityA = getSortPriority(pathA);
|
|
225
|
-
const priorityB = getSortPriority(pathB);
|
|
226
|
-
if (priorityA !== priorityB) {
|
|
227
|
-
return priorityA - priorityB;
|
|
228
|
-
}
|
|
229
|
-
if (sortKeys === "desc") {
|
|
230
|
-
return b.localeCompare(a);
|
|
231
|
-
}
|
|
232
|
-
if (sortKeys === "asc") {
|
|
233
|
-
return a.localeCompare(b);
|
|
234
|
-
}
|
|
235
|
-
return 0;
|
|
236
|
-
});
|
|
237
|
-
return sortedKeys;
|
|
238
|
-
}
|
|
239
|
-
const build = (value, path, allowedByFilter, stack2, isRoot, parentIsArray) => {
|
|
240
|
-
if (Array.isArray(value)) {
|
|
241
|
-
if (stack2.has(value)) {
|
|
242
|
-
throw new TypeError("Circular references are not supported");
|
|
243
|
-
}
|
|
244
|
-
stack2.add(value);
|
|
245
|
-
const out = [];
|
|
246
|
-
const includeAllChildren = allowedByFilter || !hasFilters;
|
|
247
|
-
for (let index = 0; index < value.length; index += 1) {
|
|
248
|
-
const childPath = path.concat({ type: "INDEX", index });
|
|
249
|
-
const child = value[index];
|
|
250
|
-
if (hasRejects && matchesAnyReject(childPath, child)) continue;
|
|
251
|
-
const directInclude = hasFilters ? matchesAnyFilter(childPath, child) : true;
|
|
252
|
-
const childAllowed = includeAllChildren || directInclude;
|
|
253
|
-
if (isPlainObject(child) || Array.isArray(child)) {
|
|
254
|
-
const builtChild = build(
|
|
255
|
-
child,
|
|
256
|
-
childPath,
|
|
257
|
-
childAllowed,
|
|
258
|
-
stack2,
|
|
259
|
-
false,
|
|
260
|
-
true
|
|
261
|
-
);
|
|
262
|
-
if (builtChild !== void 0) {
|
|
263
|
-
out.push(builtChild);
|
|
264
|
-
}
|
|
265
|
-
} else {
|
|
266
|
-
if (childAllowed) {
|
|
267
|
-
out.push(child);
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
stack2.delete(value);
|
|
272
|
-
const filteredOut = rejectEmptyObjectsInArray ? out.filter(
|
|
273
|
-
(item) => !(isPlainObject(item) && Object.keys(item).length === 0)
|
|
274
|
-
) : out;
|
|
275
|
-
if (filteredOut.length === 0 && !allowedByFilter && !isRoot)
|
|
276
|
-
return void 0;
|
|
277
|
-
return filteredOut;
|
|
278
|
-
}
|
|
279
|
-
if (isPlainObject(value)) {
|
|
280
|
-
if (stack2.has(value)) {
|
|
281
|
-
throw new TypeError("Circular references are not supported");
|
|
282
|
-
}
|
|
283
|
-
stack2.add(value);
|
|
284
|
-
const result = {};
|
|
285
|
-
const includeAllChildren = allowedByFilter || !hasFilters;
|
|
286
|
-
const sortedKeys = sortKeysWithPatterns(Object.keys(value), value, path);
|
|
287
|
-
for (const key of sortedKeys) {
|
|
288
|
-
const childPath = path.concat({ type: "KEY", name: key });
|
|
289
|
-
if (hasRejects && matchesAnyReject(childPath)) continue;
|
|
290
|
-
const val = value[key];
|
|
291
|
-
const directInclude = hasFilters ? matchesAnyFilter(childPath) : true;
|
|
292
|
-
const childAllowed = includeAllChildren || directInclude;
|
|
293
|
-
if (isPlainObject(val) || Array.isArray(val)) {
|
|
294
|
-
const builtChild = build(
|
|
295
|
-
val,
|
|
296
|
-
childPath,
|
|
297
|
-
childAllowed,
|
|
298
|
-
stack2,
|
|
299
|
-
false,
|
|
300
|
-
false
|
|
301
|
-
);
|
|
302
|
-
if (builtChild === void 0) {
|
|
303
|
-
continue;
|
|
304
|
-
}
|
|
305
|
-
if (Array.isArray(builtChild) && builtChild.length === 0 && !childAllowed) {
|
|
306
|
-
continue;
|
|
307
|
-
}
|
|
308
|
-
if (isPlainObject(builtChild) && Object.keys(builtChild).length === 0 && !childAllowed) {
|
|
309
|
-
continue;
|
|
310
|
-
}
|
|
311
|
-
result[key] = builtChild;
|
|
312
|
-
} else {
|
|
313
|
-
if (childAllowed) {
|
|
314
|
-
result[key] = val;
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
stack2.delete(value);
|
|
319
|
-
if (Object.keys(result).length === 0 && !allowedByFilter && !isRoot) {
|
|
320
|
-
if (parentIsArray && !rejectEmptyObjectsInArray) {
|
|
321
|
-
return {};
|
|
322
|
-
}
|
|
323
|
-
return void 0;
|
|
324
|
-
}
|
|
325
|
-
return result;
|
|
326
|
-
}
|
|
327
|
-
return allowedByFilter || !hasFilters ? value : void 0;
|
|
328
|
-
};
|
|
329
|
-
const startPath = [];
|
|
330
|
-
const initialAllowed = !hasFilters;
|
|
331
|
-
const stack = /* @__PURE__ */ new WeakSet();
|
|
332
|
-
const built = build(
|
|
333
|
-
dataToProcess,
|
|
334
|
-
startPath,
|
|
335
|
-
initialAllowed,
|
|
336
|
-
stack,
|
|
337
|
-
true,
|
|
338
|
-
false
|
|
339
|
-
);
|
|
340
|
-
if (built === void 0) return Array.isArray(dataToProcess) ? [] : {};
|
|
341
|
-
return built;
|
|
342
|
-
}
|
|
343
|
-
function parseFilterConditions(filterContent) {
|
|
344
|
-
const conditions = [];
|
|
345
|
-
let logic = "AND";
|
|
346
|
-
const caseInsensitive = filterContent.startsWith("i");
|
|
347
|
-
const content = caseInsensitive ? filterContent.slice(1) : filterContent;
|
|
348
|
-
const hasAnd = content.includes("&&");
|
|
349
|
-
const hasOr = content.includes(" || ");
|
|
350
|
-
if (hasAnd && hasOr) {
|
|
351
|
-
throw new Error(
|
|
352
|
-
"Mixing && and || operators in the same filter is not supported. Use separate filter patterns instead."
|
|
353
|
-
);
|
|
354
|
-
}
|
|
355
|
-
const andGroups = content.split("&&").map((s) => s.trim());
|
|
356
|
-
for (const andGroup of andGroups) {
|
|
357
|
-
if (andGroup.includes(" || ")) {
|
|
358
|
-
logic = "OR";
|
|
359
|
-
const orConditions = andGroup.split(" || ").map((s) => s.trim());
|
|
360
|
-
for (const orCondition of orConditions) {
|
|
361
|
-
const parsed = parseSingleCondition(orCondition, caseInsensitive);
|
|
362
|
-
if (parsed) {
|
|
363
|
-
conditions.push(parsed);
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
} else {
|
|
367
|
-
const parsed = parseSingleCondition(andGroup, caseInsensitive);
|
|
368
|
-
if (parsed) {
|
|
369
|
-
conditions.push(parsed);
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
if (conditions.length === 0) {
|
|
374
|
-
return null;
|
|
375
|
-
}
|
|
376
|
-
return {
|
|
377
|
-
type: "INDEX_FILTER",
|
|
378
|
-
conditions,
|
|
379
|
-
logic
|
|
380
|
-
};
|
|
381
|
-
}
|
|
382
|
-
function parseSingleCondition(condition, caseInsensitive = false) {
|
|
383
|
-
const cleanCondition = condition.startsWith("%") ? condition.slice(1) : condition;
|
|
384
|
-
let operator = null;
|
|
385
|
-
let operatorIndex = -1;
|
|
386
|
-
let operatorLength = 0;
|
|
387
|
-
const operators = [
|
|
388
|
-
["!*=", "!*="],
|
|
389
|
-
["!^=", "!^="],
|
|
390
|
-
["!$=", "!$="],
|
|
391
|
-
["!=", "!="],
|
|
392
|
-
["*=", "*="],
|
|
393
|
-
["^=", "^="],
|
|
394
|
-
["$=", "$="],
|
|
395
|
-
["=", "="]
|
|
396
|
-
];
|
|
397
|
-
for (const [op, opType] of operators) {
|
|
398
|
-
const index = cleanCondition.indexOf(op);
|
|
399
|
-
if (index !== -1) {
|
|
400
|
-
operator = opType;
|
|
401
|
-
operatorIndex = index;
|
|
402
|
-
operatorLength = op.length;
|
|
403
|
-
break;
|
|
404
|
-
}
|
|
405
|
-
}
|
|
406
|
-
if (operator === null || operatorIndex === -1) {
|
|
407
|
-
return null;
|
|
408
|
-
}
|
|
409
|
-
const property = cleanCondition.slice(0, operatorIndex).trim();
|
|
410
|
-
const valueStr = cleanCondition.slice(operatorIndex + operatorLength).trim();
|
|
411
|
-
const values = [];
|
|
412
|
-
if (valueStr.includes(" | ")) {
|
|
413
|
-
const parts = valueStr.split(" | ");
|
|
414
|
-
for (const part of parts) {
|
|
415
|
-
const trimmed = part.trim();
|
|
416
|
-
const value = trimmed.startsWith('"') && trimmed.endsWith('"') ? trimmed.slice(1, -1) : trimmed;
|
|
417
|
-
values.push(value);
|
|
418
|
-
}
|
|
419
|
-
} else {
|
|
420
|
-
const trimmed = valueStr.trim();
|
|
421
|
-
const value = trimmed.startsWith('"') && trimmed.endsWith('"') ? trimmed.slice(1, -1) : trimmed;
|
|
422
|
-
values.push(value);
|
|
423
|
-
}
|
|
424
|
-
return {
|
|
425
|
-
property,
|
|
426
|
-
operator,
|
|
427
|
-
values,
|
|
428
|
-
caseInsensitive
|
|
429
|
-
};
|
|
430
|
-
}
|
|
431
|
-
function separateFilterPatterns(patterns) {
|
|
432
|
-
const filterOnlyPatterns = [];
|
|
433
|
-
const combinedPatterns = [];
|
|
434
|
-
for (const pattern of patterns) {
|
|
435
|
-
const filterMatch = pattern.match(/^(.+\[[i%][^[\]]*\])\.(.+)$/);
|
|
436
|
-
if (filterMatch?.[1] && filterMatch[2]) {
|
|
437
|
-
const filterPart = filterMatch[1];
|
|
438
|
-
const fieldPart = filterMatch[2];
|
|
439
|
-
const baseArrayPath = filterPart.replace(/\[[i%][^[\]]*\]/, "[*]");
|
|
440
|
-
combinedPatterns.push({
|
|
441
|
-
filterPart,
|
|
442
|
-
fieldPart: `${baseArrayPath}.${fieldPart}`
|
|
443
|
-
});
|
|
444
|
-
} else {
|
|
445
|
-
filterOnlyPatterns.push(pattern);
|
|
446
|
-
}
|
|
447
|
-
}
|
|
448
|
-
return { filterOnlyPatterns, combinedPatterns };
|
|
449
|
-
}
|
|
450
|
-
function expandPatterns(pattern) {
|
|
451
|
-
function expandSingle(str) {
|
|
452
|
-
const start = str.indexOf("(");
|
|
453
|
-
if (start === -1) {
|
|
454
|
-
return [str];
|
|
455
|
-
}
|
|
456
|
-
const end = str.indexOf(")", start);
|
|
457
|
-
if (end === -1) {
|
|
458
|
-
return [str];
|
|
459
|
-
}
|
|
460
|
-
const before = str.slice(0, start);
|
|
461
|
-
const inside = str.slice(start + 1, end);
|
|
462
|
-
const after = str.slice(end + 1);
|
|
463
|
-
if (!inside.includes("|")) {
|
|
464
|
-
return expandSingle(before + inside + after);
|
|
465
|
-
}
|
|
466
|
-
const options = inside.split("|").filter((option) => option.trim().length > 0);
|
|
467
|
-
const results = [];
|
|
468
|
-
for (const option of options) {
|
|
469
|
-
const newStr = before + option + after;
|
|
470
|
-
results.push(...expandSingle(newStr));
|
|
471
|
-
}
|
|
472
|
-
return results;
|
|
473
|
-
}
|
|
474
|
-
return expandSingle(pattern);
|
|
475
|
-
}
|
|
476
|
-
function parsePattern(pattern) {
|
|
477
|
-
const tokens = [];
|
|
478
|
-
let i = 0;
|
|
479
|
-
const n = pattern.length;
|
|
480
|
-
const pushKey = (name) => {
|
|
481
|
-
if (name.length === 0) return;
|
|
482
|
-
tokens.push({ type: "KEY", name });
|
|
483
|
-
};
|
|
484
|
-
while (i < n) {
|
|
485
|
-
const ch = pattern[i];
|
|
486
|
-
if (ch === ".") {
|
|
487
|
-
i += 1;
|
|
488
|
-
continue;
|
|
489
|
-
}
|
|
490
|
-
if (ch === "[") {
|
|
491
|
-
const end = pattern.indexOf("]", i + 1);
|
|
492
|
-
const inside = end === -1 ? pattern.slice(i + 1) : pattern.slice(i + 1, end);
|
|
493
|
-
if (inside.startsWith("%") || inside.startsWith("i%")) {
|
|
494
|
-
let filterContent;
|
|
495
|
-
if (inside.startsWith("i%")) {
|
|
496
|
-
filterContent = `i${inside.slice(2)}`;
|
|
497
|
-
} else if (inside.startsWith("%")) {
|
|
498
|
-
filterContent = inside.slice(1);
|
|
499
|
-
} else {
|
|
500
|
-
filterContent = inside;
|
|
501
|
-
}
|
|
502
|
-
const filterToken = parseFilterConditions(filterContent);
|
|
503
|
-
if (filterToken) {
|
|
504
|
-
tokens.push(filterToken);
|
|
505
|
-
}
|
|
506
|
-
} else if (inside === "*") {
|
|
507
|
-
tokens.push({ type: "INDEX_ANY" });
|
|
508
|
-
} else if (inside.includes("-")) {
|
|
509
|
-
const parts = inside.split("-");
|
|
510
|
-
const startStr = parts[0] ?? "";
|
|
511
|
-
const endStr = parts[1] ?? "";
|
|
512
|
-
const start = parseInt(startStr, 10);
|
|
513
|
-
const endNum = endStr === "*" ? null : parseInt(endStr, 10);
|
|
514
|
-
tokens.push({
|
|
515
|
-
type: "INDEX_RANGE",
|
|
516
|
-
start,
|
|
517
|
-
end: endNum === null || Number.isFinite(endNum) ? endNum : null
|
|
518
|
-
});
|
|
519
|
-
} else if (inside.length > 0) {
|
|
520
|
-
const idx = parseInt(inside, 10);
|
|
521
|
-
tokens.push({ type: "INDEX", index: idx });
|
|
522
|
-
}
|
|
523
|
-
i = end === -1 ? n : end + 1;
|
|
524
|
-
continue;
|
|
525
|
-
}
|
|
526
|
-
if (ch === "*") {
|
|
527
|
-
if (pattern[i + 1] === "*") {
|
|
528
|
-
tokens.push({ type: "WILDCARD_ANY" });
|
|
529
|
-
i += 2;
|
|
530
|
-
let j2 = i;
|
|
531
|
-
while (j2 < n) {
|
|
532
|
-
const c = pattern[j2];
|
|
533
|
-
if (c === "." || c === "[") break;
|
|
534
|
-
j2 += 1;
|
|
535
|
-
}
|
|
536
|
-
if (j2 > i) {
|
|
537
|
-
pushKey(pattern.slice(i, j2));
|
|
538
|
-
i = j2;
|
|
539
|
-
}
|
|
540
|
-
continue;
|
|
541
|
-
} else {
|
|
542
|
-
tokens.push({ type: "WILDCARD_ONE" });
|
|
543
|
-
i += 1;
|
|
544
|
-
continue;
|
|
545
|
-
}
|
|
546
|
-
}
|
|
547
|
-
let j = i;
|
|
548
|
-
while (j < n) {
|
|
549
|
-
const c = pattern[j];
|
|
550
|
-
if (c === "." || c === "[") break;
|
|
551
|
-
j += 1;
|
|
552
|
-
}
|
|
553
|
-
pushKey(pattern.slice(i, j));
|
|
554
|
-
i = j;
|
|
555
|
-
}
|
|
556
|
-
return tokens;
|
|
557
|
-
}
|
|
558
|
-
|
|
559
|
-
export {
|
|
560
|
-
filterObjectOrArrayKeys
|
|
561
|
-
};
|
package/dist/chunk-PUKVXYYL.js
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
isPlainObject
|
|
3
|
-
} from "./chunk-JF2MDHOJ.js";
|
|
4
|
-
|
|
5
|
-
// src/deepReplaceValues.ts
|
|
6
|
-
function applyValueReplacements(value, replaceValues, visited, currentPath) {
|
|
7
|
-
function processValue(val, path) {
|
|
8
|
-
const replacement = replaceValues(val, path);
|
|
9
|
-
if (replacement !== false) {
|
|
10
|
-
return replacement.newValue;
|
|
11
|
-
}
|
|
12
|
-
if (Array.isArray(val)) {
|
|
13
|
-
if (visited.has(val)) {
|
|
14
|
-
throw new Error("Circular reference detected in array");
|
|
15
|
-
}
|
|
16
|
-
visited.add(val);
|
|
17
|
-
try {
|
|
18
|
-
return val.map((item, index) => {
|
|
19
|
-
const itemPath = path ? `${path}[${index}]` : `[${index}]`;
|
|
20
|
-
return processValue(item, itemPath);
|
|
21
|
-
});
|
|
22
|
-
} finally {
|
|
23
|
-
visited.delete(val);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
if (isPlainObject(val)) {
|
|
27
|
-
if (visited.has(val)) {
|
|
28
|
-
throw new Error("Circular reference detected in object");
|
|
29
|
-
}
|
|
30
|
-
visited.add(val);
|
|
31
|
-
try {
|
|
32
|
-
const result = {};
|
|
33
|
-
for (const [key, itemValue] of Object.entries(val)) {
|
|
34
|
-
const itemPath = path ? `${path}.${key}` : key;
|
|
35
|
-
result[key] = processValue(itemValue, itemPath);
|
|
36
|
-
}
|
|
37
|
-
return result;
|
|
38
|
-
} finally {
|
|
39
|
-
visited.delete(val);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
return val;
|
|
43
|
-
}
|
|
44
|
-
return processValue(value, currentPath);
|
|
45
|
-
}
|
|
46
|
-
function deepReplaceValues(value, replaceValues) {
|
|
47
|
-
return applyValueReplacements(value, replaceValues, /* @__PURE__ */ new Set(), "");
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export {
|
|
51
|
-
deepReplaceValues
|
|
52
|
-
};
|
package/dist/chunk-QQS7I7ZL.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
deepEqual
|
|
3
|
-
} from "./chunk-JQFUKJU5.js";
|
|
4
|
-
|
|
5
|
-
// src/keepPrevIfUnchanged.ts
|
|
6
|
-
function keepPrevIfUnchanged({
|
|
7
|
-
prev,
|
|
8
|
-
newValue,
|
|
9
|
-
equalityFn = deepEqual
|
|
10
|
-
}) {
|
|
11
|
-
return equalityFn(prev, newValue) ? prev : newValue;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export {
|
|
15
|
-
keepPrevIfUnchanged
|
|
16
|
-
};
|
package/dist/chunk-VAAMRG4K.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
// src/safeJson.ts
|
|
2
|
-
function safeJsonStringify(value) {
|
|
3
|
-
try {
|
|
4
|
-
return JSON.stringify(value);
|
|
5
|
-
} catch (_) {
|
|
6
|
-
return void 0;
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
function safeJsonParse(value) {
|
|
10
|
-
try {
|
|
11
|
-
return JSON.parse(value);
|
|
12
|
-
} catch (_) {
|
|
13
|
-
return void 0;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export {
|
|
18
|
-
safeJsonStringify,
|
|
19
|
-
safeJsonParse
|
|
20
|
-
};
|