@ls-stack/utils 3.65.0 → 3.67.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 +79 -0
- package/dist/diffParser.mjs +424 -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-B6DNOZCP.js
DELETED
|
@@ -1,369 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
bytesToHumanReadable
|
|
3
|
-
} from "./chunk-IATIXMCE.js";
|
|
4
|
-
import {
|
|
5
|
-
truncateString
|
|
6
|
-
} from "./chunk-BM4PYVOX.js";
|
|
7
|
-
import {
|
|
8
|
-
isObject,
|
|
9
|
-
isPlainObject
|
|
10
|
-
} from "./chunk-JF2MDHOJ.js";
|
|
11
|
-
|
|
12
|
-
// src/yamlStringify.ts
|
|
13
|
-
function yamlStringify(obj, {
|
|
14
|
-
maxLineLength = 100,
|
|
15
|
-
showUndefined,
|
|
16
|
-
maxDepth = 50,
|
|
17
|
-
collapseObjects = false,
|
|
18
|
-
addRootObjSpaces = "beforeAndAfter"
|
|
19
|
-
} = {}) {
|
|
20
|
-
if (isObject(obj) || Array.isArray(obj) || typeof obj === "function") {
|
|
21
|
-
return `${stringifyValue(obj, "", maxLineLength, !!showUndefined, maxDepth, 0, collapseObjects, addRootObjSpaces, false)}
|
|
22
|
-
`;
|
|
23
|
-
}
|
|
24
|
-
return JSON.stringify(obj) || "undefined";
|
|
25
|
-
}
|
|
26
|
-
function stringifyValue(value, indent, maxLineLength, showUndefined, maxDepth, depth, collapseObjects, addObjSpaces, isArrayItem) {
|
|
27
|
-
let result = "";
|
|
28
|
-
const childIndent = `${indent} `;
|
|
29
|
-
if (isPlainObject(value)) {
|
|
30
|
-
if (Object.keys(value).length === 0) {
|
|
31
|
-
return "{}";
|
|
32
|
-
}
|
|
33
|
-
if (collapseObjects && depth > 0) {
|
|
34
|
-
const entries = Object.entries(value).filter(
|
|
35
|
-
([, val]) => val !== void 0 || showUndefined
|
|
36
|
-
);
|
|
37
|
-
const isSimpleObject = entries.every(([, val]) => {
|
|
38
|
-
if (typeof val === "string") {
|
|
39
|
-
return !val.includes("'") && !val.includes('"') && !val.includes("\\");
|
|
40
|
-
}
|
|
41
|
-
return typeof val === "number" || typeof val === "boolean" || val === null || val === void 0;
|
|
42
|
-
});
|
|
43
|
-
const shouldCollapse = isArrayItem ? entries.length > 1 : entries.length > 0;
|
|
44
|
-
if (isSimpleObject && shouldCollapse) {
|
|
45
|
-
let line = "{ ";
|
|
46
|
-
line += entries.map(([key, val]) => {
|
|
47
|
-
let valueStr;
|
|
48
|
-
if (typeof val === "string") {
|
|
49
|
-
if (val.includes("'") && !val.includes('"')) {
|
|
50
|
-
valueStr = `"${val}"`;
|
|
51
|
-
} else if (val.includes('"') && !val.includes("'")) {
|
|
52
|
-
valueStr = `'${val}'`;
|
|
53
|
-
} else if (val.includes("'") && val.includes('"')) {
|
|
54
|
-
valueStr = `"${val.replace(/"/g, '\\"')}"`;
|
|
55
|
-
} else {
|
|
56
|
-
valueStr = `'${val}'`;
|
|
57
|
-
}
|
|
58
|
-
} else {
|
|
59
|
-
valueStr = String(val);
|
|
60
|
-
}
|
|
61
|
-
return `${key}: ${valueStr}`;
|
|
62
|
-
}).join(", ");
|
|
63
|
-
line += " }";
|
|
64
|
-
if (line.length <= maxLineLength) {
|
|
65
|
-
return line;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
let prevValue;
|
|
70
|
-
let afterSpaceWasAdded = false;
|
|
71
|
-
for (let [key, objVal] of Object.entries(value)) {
|
|
72
|
-
if (objVal === void 0 && !showUndefined) {
|
|
73
|
-
continue;
|
|
74
|
-
}
|
|
75
|
-
if (depth > maxDepth) {
|
|
76
|
-
objVal = `{max depth reached}`;
|
|
77
|
-
}
|
|
78
|
-
const normalizedValue2 = normalizeValue(objVal);
|
|
79
|
-
if (normalizedValue2 !== null) {
|
|
80
|
-
objVal = normalizedValue2[1];
|
|
81
|
-
key = `${key}{${normalizedValue2[0]}}`;
|
|
82
|
-
}
|
|
83
|
-
const valueString = stringifyValue(
|
|
84
|
-
objVal,
|
|
85
|
-
childIndent,
|
|
86
|
-
maxLineLength,
|
|
87
|
-
showUndefined,
|
|
88
|
-
maxDepth,
|
|
89
|
-
depth + 1,
|
|
90
|
-
collapseObjects,
|
|
91
|
-
addObjSpaces,
|
|
92
|
-
false
|
|
93
|
-
);
|
|
94
|
-
const willBeCollapsed = isObject(objVal) && (Object.keys(objVal).length === 0 || collapseObjects && depth + 1 > 0 && (() => {
|
|
95
|
-
const filteredEntries = Object.entries(objVal).filter(
|
|
96
|
-
([, val]) => val !== void 0 || showUndefined
|
|
97
|
-
);
|
|
98
|
-
const shouldCollapseThis = isArrayItem ? filteredEntries.length > 1 : filteredEntries.length > 0;
|
|
99
|
-
return shouldCollapseThis && filteredEntries.every(([, val]) => {
|
|
100
|
-
if (typeof val === "string") {
|
|
101
|
-
return !val.includes("'") && !val.includes('"') && !val.includes("\\");
|
|
102
|
-
}
|
|
103
|
-
return typeof val === "number" || typeof val === "boolean" || val === null || val === void 0;
|
|
104
|
-
});
|
|
105
|
-
})());
|
|
106
|
-
const prevWasCollapsed = prevValue && isObject(prevValue) && (Object.keys(prevValue).length === 0 || collapseObjects && depth + 1 > 0 && (() => {
|
|
107
|
-
const filteredEntries = Object.entries(prevValue).filter(
|
|
108
|
-
([, val]) => val !== void 0 || showUndefined
|
|
109
|
-
);
|
|
110
|
-
const shouldCollapseThis = isArrayItem ? filteredEntries.length > 1 : filteredEntries.length > 0;
|
|
111
|
-
return shouldCollapseThis && filteredEntries.every(([, val]) => {
|
|
112
|
-
if (typeof val === "string") {
|
|
113
|
-
return !val.includes("'") && !val.includes('"') && !val.includes("\\");
|
|
114
|
-
}
|
|
115
|
-
return typeof val === "number" || typeof val === "boolean" || val === null || val === void 0;
|
|
116
|
-
});
|
|
117
|
-
})());
|
|
118
|
-
if (!afterSpaceWasAdded && indent === "" && isObject(objVal) && !willBeCollapsed && prevValue && !prevWasCollapsed && (addObjSpaces === "before" || addObjSpaces === "beforeAndAfter")) {
|
|
119
|
-
result += "\n";
|
|
120
|
-
}
|
|
121
|
-
if (Array.isArray(objVal)) {
|
|
122
|
-
const arrayIsSingleLine = valueString.split("\n").length === 1;
|
|
123
|
-
if (arrayIsSingleLine && !valueString.trim().startsWith("-")) {
|
|
124
|
-
result += `${indent}${key}: `;
|
|
125
|
-
} else {
|
|
126
|
-
result += `${indent}${key}:
|
|
127
|
-
`;
|
|
128
|
-
}
|
|
129
|
-
} else if (isObject(objVal)) {
|
|
130
|
-
const isCollapsedObject = valueString.startsWith("{") && !valueString.includes("\n");
|
|
131
|
-
if (Object.keys(objVal).length === 0 || isCollapsedObject) {
|
|
132
|
-
result += `${indent}${key}: `;
|
|
133
|
-
} else {
|
|
134
|
-
result += `${indent}${key}:
|
|
135
|
-
`;
|
|
136
|
-
}
|
|
137
|
-
} else {
|
|
138
|
-
result += `${indent}${key}: `;
|
|
139
|
-
}
|
|
140
|
-
result += valueString;
|
|
141
|
-
result += "\n";
|
|
142
|
-
if (indent === "") {
|
|
143
|
-
const isCollapsedObject = valueString.startsWith("{") && !valueString.includes("\n") && valueString.length > 2;
|
|
144
|
-
if (isObject(objVal) && !isCollapsedObject) {
|
|
145
|
-
if (addObjSpaces === "after" || addObjSpaces === "beforeAndAfter") {
|
|
146
|
-
result += "\n";
|
|
147
|
-
afterSpaceWasAdded = true;
|
|
148
|
-
} else {
|
|
149
|
-
afterSpaceWasAdded = false;
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
prevValue = objVal;
|
|
154
|
-
}
|
|
155
|
-
return result.trimEnd();
|
|
156
|
-
}
|
|
157
|
-
if (Array.isArray(value)) {
|
|
158
|
-
let arrayWasAdded = false;
|
|
159
|
-
if (value.length === 0 || value.every(
|
|
160
|
-
(item) => typeof item === "string" || typeof item === "number" || typeof item === "boolean" || item === null || item === void 0
|
|
161
|
-
)) {
|
|
162
|
-
let line = "";
|
|
163
|
-
line += `[`;
|
|
164
|
-
line += value.map((item) => {
|
|
165
|
-
let valueToUse = item;
|
|
166
|
-
if (depth > maxDepth) {
|
|
167
|
-
valueToUse = `{max depth reached}`;
|
|
168
|
-
}
|
|
169
|
-
if (typeof valueToUse === "string" && valueToUse.includes("\n")) {
|
|
170
|
-
valueToUse = valueToUse.replace(/\n/g, "\\n");
|
|
171
|
-
}
|
|
172
|
-
return stringifyValue(
|
|
173
|
-
valueToUse,
|
|
174
|
-
"",
|
|
175
|
-
maxLineLength,
|
|
176
|
-
showUndefined,
|
|
177
|
-
maxDepth,
|
|
178
|
-
depth + 1,
|
|
179
|
-
collapseObjects,
|
|
180
|
-
addObjSpaces,
|
|
181
|
-
true
|
|
182
|
-
);
|
|
183
|
-
}).join(", ");
|
|
184
|
-
line += "]";
|
|
185
|
-
if (line.length <= maxLineLength) {
|
|
186
|
-
result += line;
|
|
187
|
-
arrayWasAdded = true;
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
if (!arrayWasAdded) {
|
|
191
|
-
for (let item of value) {
|
|
192
|
-
if (depth > maxDepth) {
|
|
193
|
-
item = `{max depth reached}`;
|
|
194
|
-
}
|
|
195
|
-
result += `${indent}- `;
|
|
196
|
-
if (Array.isArray(item) || isObject(item)) {
|
|
197
|
-
let arrayString = stringifyValue(
|
|
198
|
-
item,
|
|
199
|
-
childIndent,
|
|
200
|
-
maxLineLength,
|
|
201
|
-
showUndefined,
|
|
202
|
-
maxDepth,
|
|
203
|
-
depth + 1,
|
|
204
|
-
collapseObjects,
|
|
205
|
-
addObjSpaces,
|
|
206
|
-
true
|
|
207
|
-
);
|
|
208
|
-
arrayString = arrayString.trimStart();
|
|
209
|
-
result += arrayString;
|
|
210
|
-
} else {
|
|
211
|
-
result += stringifyValue(
|
|
212
|
-
item,
|
|
213
|
-
childIndent,
|
|
214
|
-
maxLineLength,
|
|
215
|
-
showUndefined,
|
|
216
|
-
maxDepth,
|
|
217
|
-
depth + 1,
|
|
218
|
-
collapseObjects,
|
|
219
|
-
addObjSpaces,
|
|
220
|
-
true
|
|
221
|
-
);
|
|
222
|
-
}
|
|
223
|
-
result += "\n";
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
return result.trimEnd();
|
|
227
|
-
}
|
|
228
|
-
if (typeof value === "string") {
|
|
229
|
-
if (value.includes("\n")) {
|
|
230
|
-
const lines = value.split("\n");
|
|
231
|
-
for (const [i, line] of lines.entries()) {
|
|
232
|
-
if (i === 0) {
|
|
233
|
-
if (value.endsWith("\n")) {
|
|
234
|
-
result += `|`;
|
|
235
|
-
} else {
|
|
236
|
-
result += `|-`;
|
|
237
|
-
}
|
|
238
|
-
result += `
|
|
239
|
-
${indent}${line}
|
|
240
|
-
`;
|
|
241
|
-
} else {
|
|
242
|
-
result += `${indent}${line}
|
|
243
|
-
`;
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
} else {
|
|
247
|
-
if (value.includes("'") && !value.includes('"')) {
|
|
248
|
-
result += `"${value}"`;
|
|
249
|
-
} else if (value.includes('"') && !value.includes("'")) {
|
|
250
|
-
result += `'${value}'`;
|
|
251
|
-
} else if (value.includes("'") && value.includes('"')) {
|
|
252
|
-
result += `"${value.replace(/"/g, '\\"')}"`;
|
|
253
|
-
} else {
|
|
254
|
-
result += `'${value}'`;
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
return result.trimEnd();
|
|
258
|
-
}
|
|
259
|
-
if (typeof value === "number" || typeof value === "boolean" || value === null || value === void 0) {
|
|
260
|
-
return String(value).trimEnd();
|
|
261
|
-
}
|
|
262
|
-
const normalizedValue = normalizeValue(value);
|
|
263
|
-
if (normalizedValue !== null) {
|
|
264
|
-
return stringifyValue(
|
|
265
|
-
{
|
|
266
|
-
[`${normalizedValue[0]}#`]: normalizedValue[1]
|
|
267
|
-
},
|
|
268
|
-
indent,
|
|
269
|
-
maxLineLength,
|
|
270
|
-
showUndefined,
|
|
271
|
-
maxDepth,
|
|
272
|
-
depth + 1,
|
|
273
|
-
collapseObjects,
|
|
274
|
-
addObjSpaces,
|
|
275
|
-
false
|
|
276
|
-
);
|
|
277
|
-
}
|
|
278
|
-
return JSON.stringify(value);
|
|
279
|
-
}
|
|
280
|
-
function normalizeValue(value) {
|
|
281
|
-
if (value === null || isPlainObject(value) || Array.isArray(value)) {
|
|
282
|
-
return null;
|
|
283
|
-
}
|
|
284
|
-
if (value instanceof Map) {
|
|
285
|
-
const mapEntries = Array.from(value.entries());
|
|
286
|
-
let mapValue;
|
|
287
|
-
if (mapEntries.every(([key]) => typeof key === "string")) {
|
|
288
|
-
const mapObjValue = {};
|
|
289
|
-
for (const [key, val] of mapEntries) {
|
|
290
|
-
mapObjValue[key] = val;
|
|
291
|
-
}
|
|
292
|
-
mapValue = mapObjValue;
|
|
293
|
-
} else {
|
|
294
|
-
mapValue = mapEntries.map(([key, val]) => ({
|
|
295
|
-
key,
|
|
296
|
-
value: val
|
|
297
|
-
}));
|
|
298
|
-
}
|
|
299
|
-
return ["Map", mapValue];
|
|
300
|
-
}
|
|
301
|
-
if (value instanceof Set) {
|
|
302
|
-
const setValue = Array.from(value);
|
|
303
|
-
return ["Set", setValue];
|
|
304
|
-
}
|
|
305
|
-
if (value instanceof Date) {
|
|
306
|
-
return ["Date", value.toISOString()];
|
|
307
|
-
}
|
|
308
|
-
if (value instanceof RegExp) {
|
|
309
|
-
return ["RegExp", value.toString()];
|
|
310
|
-
}
|
|
311
|
-
if (value instanceof Error) {
|
|
312
|
-
return [
|
|
313
|
-
"Error",
|
|
314
|
-
{
|
|
315
|
-
message: value.message,
|
|
316
|
-
name: value.name,
|
|
317
|
-
stack: value.stack
|
|
318
|
-
}
|
|
319
|
-
];
|
|
320
|
-
}
|
|
321
|
-
if (value instanceof File) {
|
|
322
|
-
return [
|
|
323
|
-
"File",
|
|
324
|
-
{
|
|
325
|
-
name: value.name,
|
|
326
|
-
type: value.type,
|
|
327
|
-
lastModified: new Date(value.lastModified).toISOString(),
|
|
328
|
-
size: bytesToHumanReadable(value.size)
|
|
329
|
-
}
|
|
330
|
-
];
|
|
331
|
-
}
|
|
332
|
-
if (typeof value === "object") {
|
|
333
|
-
if ("toJSON" in value && typeof value.toJSON === "function") {
|
|
334
|
-
return [value.constructor.name, value.toJSON()];
|
|
335
|
-
}
|
|
336
|
-
if ("toString" in value && typeof value.toString === "function") {
|
|
337
|
-
const stringValue = value.toString();
|
|
338
|
-
if (stringValue.toString() !== "[object Object]") {
|
|
339
|
-
return [value.constructor.name, stringValue];
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
const objectValue = { ...value };
|
|
343
|
-
const displayValue = {};
|
|
344
|
-
let addedKeys = 0;
|
|
345
|
-
for (const [key, item] of Object.entries(objectValue)) {
|
|
346
|
-
if (addedKeys > 4) {
|
|
347
|
-
displayValue["...and more properties"] = Object.keys(objectValue).length - 4;
|
|
348
|
-
break;
|
|
349
|
-
}
|
|
350
|
-
if (typeof item === "string" || typeof item === "number" || typeof item === "boolean" || item === null || item === void 0) {
|
|
351
|
-
displayValue[key] = item;
|
|
352
|
-
addedKeys++;
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
return [String(value.constructor.name), displayValue];
|
|
356
|
-
}
|
|
357
|
-
if (typeof value === "function") {
|
|
358
|
-
const functionString = value.toString();
|
|
359
|
-
return [
|
|
360
|
-
`Function`,
|
|
361
|
-
functionString.includes("\n") ? truncateString(functionString.split("\n").join(""), 40) : functionString
|
|
362
|
-
];
|
|
363
|
-
}
|
|
364
|
-
return null;
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
export {
|
|
368
|
-
yamlStringify
|
|
369
|
-
};
|
package/dist/chunk-BM4PYVOX.js
DELETED
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
// src/stringUtils.ts
|
|
2
|
-
function concatStrings(...args) {
|
|
3
|
-
const strings = [];
|
|
4
|
-
for (let i = 0; i < args.length; i++) {
|
|
5
|
-
const arg = args[i];
|
|
6
|
-
if (!arg) continue;
|
|
7
|
-
if (Array.isArray(arg)) {
|
|
8
|
-
strings.push(concatStrings(...arg));
|
|
9
|
-
continue;
|
|
10
|
-
}
|
|
11
|
-
strings.push(arg);
|
|
12
|
-
}
|
|
13
|
-
return strings.join("");
|
|
14
|
-
}
|
|
15
|
-
var joinStrings = concatStrings;
|
|
16
|
-
function formatNum(num, maxDecimalsOrOptions = 2) {
|
|
17
|
-
const options = typeof maxDecimalsOrOptions === "number" ? {
|
|
18
|
-
maximumFractionDigits: maxDecimalsOrOptions
|
|
19
|
-
} : maxDecimalsOrOptions;
|
|
20
|
-
return num.toLocaleString("en-US", options);
|
|
21
|
-
}
|
|
22
|
-
function isSnakeCase(str) {
|
|
23
|
-
return /^[a-z0-9_]+$/.test(str);
|
|
24
|
-
}
|
|
25
|
-
function isKebabCase(str) {
|
|
26
|
-
return /^[a-z0-9]+(-[a-z0-9]+)*$/.test(str);
|
|
27
|
-
}
|
|
28
|
-
function isPascalCase(str) {
|
|
29
|
-
return /^[A-Z][a-zA-Z0-9]*$/.test(str);
|
|
30
|
-
}
|
|
31
|
-
function isCamelCase(str) {
|
|
32
|
-
return /^[a-z][a-zA-Z0-9]*$/.test(str);
|
|
33
|
-
}
|
|
34
|
-
function isTitleCase(str) {
|
|
35
|
-
return /^[A-Z][a-z0-9]*( ([A-Z][a-z0-9]*|[0-9]+))*$/.test(str);
|
|
36
|
-
}
|
|
37
|
-
function isSentenceCase(str) {
|
|
38
|
-
return /^[A-Z][a-z0-9]*( [a-z0-9]+)*$/.test(str);
|
|
39
|
-
}
|
|
40
|
-
function isConstantCase(str) {
|
|
41
|
-
return /^[A-Z_][A-Z0-9_]*$/.test(str);
|
|
42
|
-
}
|
|
43
|
-
function isDotCase(str) {
|
|
44
|
-
return /^[a-z0-9]+(\.[a-z0-9]+)*$/.test(str);
|
|
45
|
-
}
|
|
46
|
-
function isPathCase(str) {
|
|
47
|
-
return /^[a-z0-9]+(\/[a-z0-9]+)*$/.test(str);
|
|
48
|
-
}
|
|
49
|
-
function convertToKebabCase(str) {
|
|
50
|
-
return convertToSnakeCase(str).replace(/_/g, "-");
|
|
51
|
-
}
|
|
52
|
-
function convertToSnakeCase(str) {
|
|
53
|
-
return str.replace(/[\s\-.]+/g, "_").replace(/([a-z0-9])([A-Z])/g, "$1_$2").replace(/([A-Z])([A-Z][a-z])/g, "$1_$2").toLowerCase().replace(/[^a-z0-9_]/g, "").replace(/^_+|_+$/g, "").replace(/_+/g, "_");
|
|
54
|
-
}
|
|
55
|
-
function convertToPascalCase(str) {
|
|
56
|
-
return str.split(/[\s_-]+/).map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join("");
|
|
57
|
-
}
|
|
58
|
-
function convertToCamelCase(str) {
|
|
59
|
-
const pascalCase = convertToPascalCase(str);
|
|
60
|
-
return pascalCase.charAt(0).toLowerCase() + pascalCase.slice(1);
|
|
61
|
-
}
|
|
62
|
-
function convertToSentenceCase(str) {
|
|
63
|
-
return str.replace(/[\s\-.]+/g, " ").replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/([A-Z])([A-Z][a-z])/g, "$1 $2").split(/[\s_-]+/).map((word) => word.toLowerCase()).join(" ").replace(/^\w/, (char) => char.toUpperCase());
|
|
64
|
-
}
|
|
65
|
-
function convertToTitleCase(str) {
|
|
66
|
-
return str.replace(/[\s\-.]+/g, " ").replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/([A-Z])([A-Z][a-z])/g, "$1 $2").split(/[\s_-]+/).map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join(" ");
|
|
67
|
-
}
|
|
68
|
-
function convertToConstantCase(str) {
|
|
69
|
-
return convertToSnakeCase(str).toUpperCase();
|
|
70
|
-
}
|
|
71
|
-
function convertToDotCase(str) {
|
|
72
|
-
return convertToSnakeCase(str).replace(/_/g, ".");
|
|
73
|
-
}
|
|
74
|
-
function convertToPathCase(str) {
|
|
75
|
-
return convertToSnakeCase(str).replace(/_/g, "/");
|
|
76
|
-
}
|
|
77
|
-
function truncateString(str, length, ellipsis = "\u2026") {
|
|
78
|
-
if (str.length <= length) return str;
|
|
79
|
-
return str.slice(0, length - 1) + ellipsis;
|
|
80
|
-
}
|
|
81
|
-
function removeANSIColors(str) {
|
|
82
|
-
return str.replace(/\u001b\[\d+m/g, "");
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
export {
|
|
86
|
-
concatStrings,
|
|
87
|
-
joinStrings,
|
|
88
|
-
formatNum,
|
|
89
|
-
isSnakeCase,
|
|
90
|
-
isKebabCase,
|
|
91
|
-
isPascalCase,
|
|
92
|
-
isCamelCase,
|
|
93
|
-
isTitleCase,
|
|
94
|
-
isSentenceCase,
|
|
95
|
-
isConstantCase,
|
|
96
|
-
isDotCase,
|
|
97
|
-
isPathCase,
|
|
98
|
-
convertToKebabCase,
|
|
99
|
-
convertToSnakeCase,
|
|
100
|
-
convertToPascalCase,
|
|
101
|
-
convertToCamelCase,
|
|
102
|
-
convertToSentenceCase,
|
|
103
|
-
convertToTitleCase,
|
|
104
|
-
convertToConstantCase,
|
|
105
|
-
convertToDotCase,
|
|
106
|
-
convertToPathCase,
|
|
107
|
-
truncateString,
|
|
108
|
-
removeANSIColors
|
|
109
|
-
};
|
package/dist/chunk-C2SVCIWE.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
isFunction,
|
|
3
|
-
isObject,
|
|
4
|
-
isPlainObject,
|
|
5
|
-
isPromise
|
|
6
|
-
} from "./chunk-JF2MDHOJ.js";
|
|
7
|
-
|
|
8
|
-
// src/assertions.ts
|
|
9
|
-
var undefErrMsg = "not undefined assertion failed";
|
|
10
|
-
var nullishErrMsg = "not nullish assertion failed";
|
|
11
|
-
function notUndefined(value, error = undefErrMsg) {
|
|
12
|
-
if (value === void 0) {
|
|
13
|
-
throw typeof error === "function" ? error() : new Error(error);
|
|
14
|
-
}
|
|
15
|
-
return value;
|
|
16
|
-
}
|
|
17
|
-
function notNullish(value, error = nullishErrMsg) {
|
|
18
|
-
if (value === void 0 || value === null) {
|
|
19
|
-
throw typeof error === "function" ? error() : new Error(error);
|
|
20
|
-
}
|
|
21
|
-
return value;
|
|
22
|
-
}
|
|
23
|
-
function assertIsNotNullish(value, error = nullishErrMsg) {
|
|
24
|
-
if (value === void 0 || value === null) {
|
|
25
|
-
throw typeof error === "function" ? error() : new Error(error);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
function assertIsNotUndefined(value, error = undefErrMsg) {
|
|
29
|
-
if (value === void 0) {
|
|
30
|
-
throw typeof error === "function" ? error() : new Error(error);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
function invariant(condition, error = "Invariant violation") {
|
|
34
|
-
if (!condition) {
|
|
35
|
-
throw typeof error === "function" ? error() : new Error(`Invariant violation: ${error}`);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
function exhaustiveCheck(narrowedType) {
|
|
39
|
-
return new Error("This should never happen");
|
|
40
|
-
}
|
|
41
|
-
var isFunction2 = isFunction;
|
|
42
|
-
var isObject2 = isObject;
|
|
43
|
-
var isPlainObject2 = isPlainObject;
|
|
44
|
-
var isPromise2 = isPromise;
|
|
45
|
-
|
|
46
|
-
export {
|
|
47
|
-
notUndefined,
|
|
48
|
-
notNullish,
|
|
49
|
-
assertIsNotNullish,
|
|
50
|
-
assertIsNotUndefined,
|
|
51
|
-
invariant,
|
|
52
|
-
exhaustiveCheck,
|
|
53
|
-
isFunction2 as isFunction,
|
|
54
|
-
isObject2 as isObject,
|
|
55
|
-
isPlainObject2 as isPlainObject,
|
|
56
|
-
isPromise2 as isPromise
|
|
57
|
-
};
|
package/dist/chunk-CCUPDGSZ.js
DELETED
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
// src/debounce.ts
|
|
2
|
-
function debounce(func, wait, options) {
|
|
3
|
-
let currentCallback = func;
|
|
4
|
-
let waitMs = wait;
|
|
5
|
-
let currentOptions = options;
|
|
6
|
-
let lastArgs;
|
|
7
|
-
let lastThis;
|
|
8
|
-
let maxWait;
|
|
9
|
-
let result;
|
|
10
|
-
let timerId;
|
|
11
|
-
let lastCallTime;
|
|
12
|
-
let lastInvokeTime = 0;
|
|
13
|
-
let leading = false;
|
|
14
|
-
let maxing = false;
|
|
15
|
-
let trailing = true;
|
|
16
|
-
function applyOptions() {
|
|
17
|
-
const opts = currentOptions;
|
|
18
|
-
leading = !!opts?.leading;
|
|
19
|
-
trailing = opts && "trailing" in opts ? !!opts.trailing : true;
|
|
20
|
-
maxing = !!(opts && "maxWait" in opts);
|
|
21
|
-
maxWait = maxing ? Math.max(opts?.maxWait ?? 0, waitMs) : void 0;
|
|
22
|
-
}
|
|
23
|
-
applyOptions();
|
|
24
|
-
function invokeFunc(time) {
|
|
25
|
-
const args = lastArgs;
|
|
26
|
-
const thisArg = lastThis;
|
|
27
|
-
lastArgs = lastThis = void 0;
|
|
28
|
-
lastInvokeTime = time;
|
|
29
|
-
result = currentCallback.apply(thisArg, args);
|
|
30
|
-
return result;
|
|
31
|
-
}
|
|
32
|
-
function leadingEdge(time) {
|
|
33
|
-
lastInvokeTime = time;
|
|
34
|
-
timerId = setTimeout(timerExpired, waitMs);
|
|
35
|
-
return leading ? invokeFunc(time) : result;
|
|
36
|
-
}
|
|
37
|
-
function remainingWait(time) {
|
|
38
|
-
const timeSinceLastCall = time - (lastCallTime ?? 0);
|
|
39
|
-
const timeSinceLastInvoke = time - lastInvokeTime;
|
|
40
|
-
const timeWaiting = waitMs - timeSinceLastCall;
|
|
41
|
-
return maxing ? Math.min(timeWaiting, (maxWait ?? 0) - timeSinceLastInvoke) : timeWaiting;
|
|
42
|
-
}
|
|
43
|
-
function shouldInvoke(time) {
|
|
44
|
-
const timeSinceLastCall = time - (lastCallTime ?? 0);
|
|
45
|
-
const timeSinceLastInvoke = time - lastInvokeTime;
|
|
46
|
-
return lastCallTime === void 0 || timeSinceLastCall >= waitMs || timeSinceLastCall < 0 || maxing && timeSinceLastInvoke >= (maxWait ?? 0);
|
|
47
|
-
}
|
|
48
|
-
function timerExpired() {
|
|
49
|
-
const time = Date.now();
|
|
50
|
-
if (shouldInvoke(time)) {
|
|
51
|
-
return trailingEdge(time);
|
|
52
|
-
}
|
|
53
|
-
timerId = setTimeout(timerExpired, remainingWait(time));
|
|
54
|
-
}
|
|
55
|
-
function trailingEdge(time) {
|
|
56
|
-
timerId = void 0;
|
|
57
|
-
if (trailing && lastArgs) {
|
|
58
|
-
return invokeFunc(time);
|
|
59
|
-
}
|
|
60
|
-
lastArgs = lastThis = void 0;
|
|
61
|
-
return result;
|
|
62
|
-
}
|
|
63
|
-
function cancel() {
|
|
64
|
-
if (timerId !== void 0) {
|
|
65
|
-
clearTimeout(timerId);
|
|
66
|
-
}
|
|
67
|
-
lastInvokeTime = 0;
|
|
68
|
-
lastArgs = lastCallTime = lastThis = timerId = void 0;
|
|
69
|
-
}
|
|
70
|
-
function flush() {
|
|
71
|
-
return timerId === void 0 ? result : trailingEdge(Date.now());
|
|
72
|
-
}
|
|
73
|
-
function pending() {
|
|
74
|
-
return timerId !== void 0;
|
|
75
|
-
}
|
|
76
|
-
function updateCb(callback) {
|
|
77
|
-
currentCallback = callback;
|
|
78
|
-
}
|
|
79
|
-
function updateParams(newWait, newOptions) {
|
|
80
|
-
waitMs = newWait;
|
|
81
|
-
if (newOptions !== void 0) {
|
|
82
|
-
currentOptions = newOptions;
|
|
83
|
-
}
|
|
84
|
-
applyOptions();
|
|
85
|
-
if (timerId !== void 0) {
|
|
86
|
-
const time = Date.now();
|
|
87
|
-
const shouldRun = shouldInvoke(time);
|
|
88
|
-
clearTimeout(timerId);
|
|
89
|
-
if (shouldRun) {
|
|
90
|
-
timerId = setTimeout(timerExpired, 0);
|
|
91
|
-
} else {
|
|
92
|
-
const delay = remainingWait(time);
|
|
93
|
-
timerId = setTimeout(timerExpired, delay > 0 ? delay : 0);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
function debounced() {
|
|
98
|
-
const time = Date.now();
|
|
99
|
-
const isInvoking = shouldInvoke(time);
|
|
100
|
-
lastArgs = arguments;
|
|
101
|
-
lastThis = this;
|
|
102
|
-
lastCallTime = time;
|
|
103
|
-
if (isInvoking) {
|
|
104
|
-
if (timerId === void 0) {
|
|
105
|
-
return leadingEdge(lastCallTime);
|
|
106
|
-
}
|
|
107
|
-
if (maxing) {
|
|
108
|
-
clearTimeout(timerId);
|
|
109
|
-
timerId = setTimeout(timerExpired, waitMs);
|
|
110
|
-
return invokeFunc(lastCallTime);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
if (timerId === void 0) {
|
|
114
|
-
timerId = setTimeout(timerExpired, waitMs);
|
|
115
|
-
}
|
|
116
|
-
return result;
|
|
117
|
-
}
|
|
118
|
-
debounced.cancel = cancel;
|
|
119
|
-
debounced.flush = flush;
|
|
120
|
-
debounced.pending = pending;
|
|
121
|
-
debounced.updateCb = updateCb;
|
|
122
|
-
debounced.updateParams = updateParams;
|
|
123
|
-
return debounced;
|
|
124
|
-
}
|
|
125
|
-
function isDebouncedFn(fn) {
|
|
126
|
-
return typeof fn === "function" && "cancel" in fn && typeof fn.cancel === "function" && "flush" in fn && typeof fn.flush === "function" && "pending" in fn && typeof fn.pending === "function" && "updateCb" in fn && typeof fn.updateCb === "function" && "updateParams" in fn && typeof fn.updateParams === "function";
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
export {
|
|
130
|
-
debounce,
|
|
131
|
-
isDebouncedFn
|
|
132
|
-
};
|