@ls-stack/utils 3.40.0 → 3.41.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 +70 -57
- package/dist/arrayUtils.d.ts +70 -57
- package/dist/assertions.d.cts +128 -117
- package/dist/assertions.d.ts +128 -117
- package/dist/asyncQueue.cjs +117 -112
- package/dist/asyncQueue.d.cts +217 -215
- package/dist/asyncQueue.d.ts +217 -215
- package/dist/asyncQueue.js +117 -112
- package/dist/awaitDebounce.d.cts +26 -23
- package/dist/awaitDebounce.d.ts +26 -23
- package/dist/cache.cjs +2 -1
- package/dist/cache.d.cts +15 -9
- package/dist/cache.d.ts +15 -9
- package/dist/cache.js +2 -1
- package/dist/{chunk-GHAQOUA6.js → chunk-23KPGKDT.js} +22 -1
- package/dist/{chunk-ADM37GSC.js → chunk-7L4KCZJJ.js} +12 -10
- package/dist/{chunk-KW55OTUG.js → chunk-B3KFV2MH.js} +2 -2
- package/dist/chunk-DTE2QMWE.js +48 -0
- package/dist/concurrentCalls.d.cts +8 -4
- package/dist/concurrentCalls.d.ts +8 -4
- package/dist/concurrentCalls.js +1 -1
- package/dist/debounce.d.cts +12 -20
- package/dist/debounce.d.ts +12 -20
- package/dist/dedent.d.cts +31 -31
- package/dist/dedent.d.ts +31 -31
- package/dist/deepEqual.d.cts +10 -9
- package/dist/deepEqual.d.ts +10 -9
- package/dist/filterObjectOrArrayKeys.d.cts +44 -19
- package/dist/filterObjectOrArrayKeys.d.ts +44 -19
- package/dist/getAutoIncrementId.d.cts +25 -23
- package/dist/getAutoIncrementId.d.ts +25 -23
- package/dist/getCompositeKey.d.cts +2 -1
- package/dist/getCompositeKey.d.ts +2 -1
- package/dist/getValueStableKey.d.cts +4 -3
- package/dist/getValueStableKey.d.ts +4 -3
- package/dist/mutationUtils.d.cts +2 -2
- package/dist/mutationUtils.d.ts +2 -2
- package/dist/objUtils.cjs +51 -2
- package/dist/objUtils.d.cts +8 -3
- package/dist/objUtils.d.ts +8 -3
- package/dist/objUtils.js +11 -3
- package/dist/parallelAsyncCalls.cjs +2 -1
- package/dist/parallelAsyncCalls.d.cts +5 -4
- package/dist/parallelAsyncCalls.d.ts +5 -4
- package/dist/parallelAsyncCalls.js +2 -1
- package/dist/retryOnError.d.cts +23 -20
- package/dist/retryOnError.d.ts +23 -20
- package/dist/runShellCmd.d.cts +40 -40
- package/dist/runShellCmd.d.ts +40 -40
- package/dist/safeJson.d.cts +6 -2
- package/dist/safeJson.d.ts +6 -2
- package/dist/saferTyping.d.cts +21 -14
- package/dist/saferTyping.d.ts +21 -14
- package/dist/shallowEqual.d.cts +1 -1
- package/dist/shallowEqual.d.ts +1 -1
- package/dist/stringUtils.cjs +2 -2
- package/dist/stringUtils.d.cts +6 -7
- package/dist/stringUtils.d.ts +6 -7
- package/dist/stringUtils.js +1 -1
- package/dist/testUtils.cjs +11 -9
- package/dist/testUtils.d.cts +32 -14
- package/dist/testUtils.d.ts +32 -14
- package/dist/testUtils.js +4 -3
- package/dist/throttle.d.cts +57 -48
- package/dist/throttle.d.ts +57 -48
- package/dist/timers.d.cts +68 -63
- package/dist/timers.d.ts +68 -63
- package/dist/tsResult.d.cts +7 -6
- package/dist/tsResult.d.ts +7 -6
- package/dist/typeGuards.d.cts +65 -64
- package/dist/typeGuards.d.ts +65 -64
- package/dist/typeUtils.d.cts +18 -4
- package/dist/typeUtils.d.ts +18 -4
- package/dist/typedStrings.d.cts +68 -57
- package/dist/typedStrings.d.ts +68 -57
- package/dist/typingFnUtils.d.cts +12 -6
- package/dist/typingFnUtils.d.ts +12 -6
- package/dist/typingFnUtils.js +12 -35
- package/dist/typingTestUtils.cjs +7 -1
- package/dist/typingTestUtils.d.cts +52 -11
- package/dist/typingTestUtils.d.ts +52 -11
- package/dist/typingTestUtils.js +7 -1
- package/dist/typingUtils.d.cts +4 -1
- package/dist/typingUtils.d.ts +4 -1
- package/dist/yamlStringify.cjs +11 -9
- package/dist/yamlStringify.js +2 -2
- package/package.json +5 -1
- package/docs/README.md +0 -72
- package/docs/_media/modules.md +0 -58
- package/docs/arrayUtils/-internal-.md +0 -179
- package/docs/arrayUtils/README.md +0 -550
- package/docs/assertions/-internal-.md +0 -63
- package/docs/assertions/README.md +0 -565
- package/docs/asyncQueue/-internal-.md +0 -297
- package/docs/asyncQueue/README.md +0 -1485
- package/docs/awaitDebounce.md +0 -66
- package/docs/cache/-internal-.md +0 -168
- package/docs/cache/README.md +0 -360
- package/docs/castValues.md +0 -47
- package/docs/concurrentCalls/-internal-.md +0 -490
- package/docs/concurrentCalls/README.md +0 -299
- package/docs/consoleFmt.md +0 -115
- package/docs/conversions.md +0 -27
- package/docs/createThrottleController/-internal-.md +0 -73
- package/docs/createThrottleController/README.md +0 -31
- package/docs/debounce.md +0 -188
- package/docs/dedent/-internal-.md +0 -17
- package/docs/dedent/README.md +0 -204
- package/docs/deepEqual.md +0 -94
- package/docs/enhancedMap.md +0 -358
- package/docs/exhaustiveMatch/-internal-.md +0 -39
- package/docs/exhaustiveMatch/README.md +0 -146
- package/docs/filterObjectOrArrayKeys.md +0 -109
- package/docs/getAutoIncrementId.md +0 -93
- package/docs/getCompositeKey.md +0 -39
- package/docs/getValueStableKey.md +0 -57
- package/docs/hash.md +0 -31
- package/docs/interpolate/-internal-.md +0 -61
- package/docs/interpolate/README.md +0 -62
- package/docs/keepPrevIfUnchanged.md +0 -43
- package/docs/levenshtein.md +0 -93
- package/docs/main.md +0 -21
- package/docs/mathUtils.md +0 -137
- package/docs/modules.md +0 -58
- package/docs/mutationUtils.md +0 -44
- package/docs/objUtils.md +0 -237
- package/docs/parallelAsyncCalls/-internal-.md +0 -347
- package/docs/parallelAsyncCalls/README.md +0 -45
- package/docs/promiseUtils/-internal-.md +0 -69
- package/docs/promiseUtils/README.md +0 -31
- package/docs/retryOnError/-internal-.md +0 -111
- package/docs/retryOnError/README.md +0 -168
- package/docs/runShellCmd/-internal-.md +0 -111
- package/docs/runShellCmd/README.md +0 -201
- package/docs/safeJson.md +0 -51
- package/docs/saferTyping.md +0 -228
- package/docs/serializeXML.md +0 -100
- package/docs/shallowEqual.md +0 -33
- package/docs/sleep.md +0 -27
- package/docs/stringUtils/-internal-.md +0 -17
- package/docs/stringUtils/README.md +0 -270
- package/docs/testUtils.md +0 -382
- package/docs/throttle/-internal-.md +0 -47
- package/docs/throttle/README.md +0 -178
- package/docs/time.md +0 -274
- package/docs/timers.md +0 -256
- package/docs/tsResult/-internal-.md +0 -327
- package/docs/tsResult/README.md +0 -702
- package/docs/typeGuards.md +0 -399
- package/docs/typeUtils/-internal-.md +0 -99
- package/docs/typeUtils/README.md +0 -195
- package/docs/typeUtils.typesTest.md +0 -7
- package/docs/typedStrings.md +0 -458
- package/docs/typingFnUtils/-internal-.md +0 -43
- package/docs/typingFnUtils/README.md +0 -317
- package/docs/typingTestUtils.md +0 -172
- package/docs/typingUtils.md +0 -135
- package/docs/yamlStringify.md +0 -83
package/dist/retryOnError.d.cts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { ResultValidErrors, Result } from 't-result';
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* Configuration options for retryOnError function.
|
|
5
|
-
*/
|
|
3
|
+
/** Configuration options for retryOnError function. */
|
|
6
4
|
type RetryOptions = {
|
|
7
5
|
/** Delay between retries in milliseconds or function returning delay */
|
|
8
6
|
delayBetweenRetriesMs?: number | ((retry: number) => number);
|
|
9
|
-
/**
|
|
7
|
+
/**
|
|
8
|
+
* Function to determine if retry should happen, receives error and duration
|
|
9
|
+
* of last attempt
|
|
10
|
+
*/
|
|
10
11
|
retryCondition?: (error: Error, lastAttempt: {
|
|
11
12
|
duration: number;
|
|
12
13
|
retry: number;
|
|
@@ -24,22 +25,23 @@ type RetryOptions = {
|
|
|
24
25
|
/**
|
|
25
26
|
* Retries a function on error with configurable retry logic.
|
|
26
27
|
*
|
|
28
|
+
* @example
|
|
29
|
+
* await retryOnError(
|
|
30
|
+
* async (ctx) => {
|
|
31
|
+
* console.log(`Attempt ${ctx.retry + 1}`);
|
|
32
|
+
* return await fetchData();
|
|
33
|
+
* },
|
|
34
|
+
* 3,
|
|
35
|
+
* { delayBetweenRetriesMs: 1000 },
|
|
36
|
+
* );
|
|
37
|
+
*
|
|
27
38
|
* @param fn - Function to retry that receives context with retry count
|
|
28
39
|
* @param maxRetries - Maximum number of retries
|
|
29
40
|
* @param options - Configuration options
|
|
30
|
-
* @param retry -
|
|
31
|
-
* @param originalMaxRetries -
|
|
32
|
-
* @returns Promise resolving to the function result or rejecting with the final
|
|
33
|
-
*
|
|
34
|
-
* @example
|
|
35
|
-
* await retryOnError(
|
|
36
|
-
* async (ctx) => {
|
|
37
|
-
* console.log(`Attempt ${ctx.retry + 1}`);
|
|
38
|
-
* return await fetchData();
|
|
39
|
-
* },
|
|
40
|
-
* 3,
|
|
41
|
-
* { delayBetweenRetriesMs: 1000 }
|
|
42
|
-
* );
|
|
41
|
+
* @param retry - Internal use only
|
|
42
|
+
* @param originalMaxRetries - Internal use only
|
|
43
|
+
* @returns Promise resolving to the function result or rejecting with the final
|
|
44
|
+
* error
|
|
43
45
|
*/
|
|
44
46
|
declare function retryOnError<T>(fn: (ctx: {
|
|
45
47
|
/** Current retry count, (0 for first attempt) */
|
|
@@ -56,9 +58,10 @@ declare function retryOnError<T>(fn: (ctx: {
|
|
|
56
58
|
* @param options.debugId
|
|
57
59
|
* @param options.disableRetries
|
|
58
60
|
* @param options.onRetry
|
|
59
|
-
* @param __retry -
|
|
60
|
-
* @param __originalMaxRetries -
|
|
61
|
-
* @returns Promise resolving to the function result or rejecting with the final
|
|
61
|
+
* @param __retry - Internal use only
|
|
62
|
+
* @param __originalMaxRetries - Internal use only
|
|
63
|
+
* @returns Promise resolving to the function result or rejecting with the final
|
|
64
|
+
* error
|
|
62
65
|
*/
|
|
63
66
|
declare function retryResultOnError<T, E extends ResultValidErrors>(fn: (ctx: {
|
|
64
67
|
/** Current retry count, (0 for first attempt) */
|
package/dist/retryOnError.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { ResultValidErrors, Result } from 't-result';
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* Configuration options for retryOnError function.
|
|
5
|
-
*/
|
|
3
|
+
/** Configuration options for retryOnError function. */
|
|
6
4
|
type RetryOptions = {
|
|
7
5
|
/** Delay between retries in milliseconds or function returning delay */
|
|
8
6
|
delayBetweenRetriesMs?: number | ((retry: number) => number);
|
|
9
|
-
/**
|
|
7
|
+
/**
|
|
8
|
+
* Function to determine if retry should happen, receives error and duration
|
|
9
|
+
* of last attempt
|
|
10
|
+
*/
|
|
10
11
|
retryCondition?: (error: Error, lastAttempt: {
|
|
11
12
|
duration: number;
|
|
12
13
|
retry: number;
|
|
@@ -24,22 +25,23 @@ type RetryOptions = {
|
|
|
24
25
|
/**
|
|
25
26
|
* Retries a function on error with configurable retry logic.
|
|
26
27
|
*
|
|
28
|
+
* @example
|
|
29
|
+
* await retryOnError(
|
|
30
|
+
* async (ctx) => {
|
|
31
|
+
* console.log(`Attempt ${ctx.retry + 1}`);
|
|
32
|
+
* return await fetchData();
|
|
33
|
+
* },
|
|
34
|
+
* 3,
|
|
35
|
+
* { delayBetweenRetriesMs: 1000 },
|
|
36
|
+
* );
|
|
37
|
+
*
|
|
27
38
|
* @param fn - Function to retry that receives context with retry count
|
|
28
39
|
* @param maxRetries - Maximum number of retries
|
|
29
40
|
* @param options - Configuration options
|
|
30
|
-
* @param retry -
|
|
31
|
-
* @param originalMaxRetries -
|
|
32
|
-
* @returns Promise resolving to the function result or rejecting with the final
|
|
33
|
-
*
|
|
34
|
-
* @example
|
|
35
|
-
* await retryOnError(
|
|
36
|
-
* async (ctx) => {
|
|
37
|
-
* console.log(`Attempt ${ctx.retry + 1}`);
|
|
38
|
-
* return await fetchData();
|
|
39
|
-
* },
|
|
40
|
-
* 3,
|
|
41
|
-
* { delayBetweenRetriesMs: 1000 }
|
|
42
|
-
* );
|
|
41
|
+
* @param retry - Internal use only
|
|
42
|
+
* @param originalMaxRetries - Internal use only
|
|
43
|
+
* @returns Promise resolving to the function result or rejecting with the final
|
|
44
|
+
* error
|
|
43
45
|
*/
|
|
44
46
|
declare function retryOnError<T>(fn: (ctx: {
|
|
45
47
|
/** Current retry count, (0 for first attempt) */
|
|
@@ -56,9 +58,10 @@ declare function retryOnError<T>(fn: (ctx: {
|
|
|
56
58
|
* @param options.debugId
|
|
57
59
|
* @param options.disableRetries
|
|
58
60
|
* @param options.onRetry
|
|
59
|
-
* @param __retry -
|
|
60
|
-
* @param __originalMaxRetries -
|
|
61
|
-
* @returns Promise resolving to the function result or rejecting with the final
|
|
61
|
+
* @param __retry - Internal use only
|
|
62
|
+
* @param __originalMaxRetries - Internal use only
|
|
63
|
+
* @returns Promise resolving to the function result or rejecting with the final
|
|
64
|
+
* error
|
|
62
65
|
*/
|
|
63
66
|
declare function retryResultOnError<T, E extends ResultValidErrors>(fn: (ctx: {
|
|
64
67
|
/** Current retry count, (0 for first attempt) */
|
package/dist/runShellCmd.d.cts
CHANGED
|
@@ -13,6 +13,14 @@ type RunCmdOptions = {
|
|
|
13
13
|
noCiColorForce?: boolean;
|
|
14
14
|
};
|
|
15
15
|
/**
|
|
16
|
+
* @deprecated This utility has been moved to @ls-stack/node-utils. Please
|
|
17
|
+
* update your imports:
|
|
18
|
+
*
|
|
19
|
+
* // Old (deprecated)
|
|
20
|
+
* import { runCmd } from '@ls-stack/utils/runShellCmd';
|
|
21
|
+
*
|
|
22
|
+
* // New (preferred)
|
|
23
|
+
* import { runCmd } from '@ls-stack/node-utils/runShellCmd';
|
|
16
24
|
* @param label
|
|
17
25
|
* @param command
|
|
18
26
|
* @param root0
|
|
@@ -21,69 +29,61 @@ type RunCmdOptions = {
|
|
|
21
29
|
* @param root0.throwOnError
|
|
22
30
|
* @param root0.cwd
|
|
23
31
|
* @param root0.noCiColorForce
|
|
24
|
-
* @deprecated This utility has been moved to @ls-stack/node-utils. Please update your imports:
|
|
25
|
-
* ```
|
|
26
|
-
* // Old (deprecated)
|
|
27
|
-
* import { runCmd } from '@ls-stack/utils/runShellCmd';
|
|
28
|
-
*
|
|
29
|
-
* // New (preferred)
|
|
30
|
-
* import { runCmd } from '@ls-stack/node-utils/runShellCmd';
|
|
31
|
-
* ```
|
|
32
32
|
*/
|
|
33
33
|
declare function runCmd(label: string | null, command: string | string[], { mock, silent, throwOnError, cwd, noCiColorForce, }?: RunCmdOptions): Promise<CmdResult>;
|
|
34
34
|
/**
|
|
35
|
+
* @deprecated This utility has been moved to @ls-stack/node-utils. Please
|
|
36
|
+
* update your imports:
|
|
37
|
+
*
|
|
38
|
+
* // Old (deprecated)
|
|
39
|
+
* import { concurrentCmd } from '@ls-stack/utils/runShellCmd';
|
|
40
|
+
*
|
|
41
|
+
* // New (preferred)
|
|
42
|
+
* import { concurrentCmd } from '@ls-stack/node-utils/runShellCmd';
|
|
35
43
|
* @param label
|
|
36
44
|
* @param cmd
|
|
37
45
|
* @param onResult
|
|
38
|
-
* @deprecated This utility has been moved to @ls-stack/node-utils. Please update your imports:
|
|
39
|
-
* ```
|
|
40
|
-
* // Old (deprecated)
|
|
41
|
-
* import { concurrentCmd } from '@ls-stack/utils/runShellCmd';
|
|
42
|
-
*
|
|
43
|
-
* // New (preferred)
|
|
44
|
-
* import { concurrentCmd } from '@ls-stack/node-utils/runShellCmd';
|
|
45
|
-
* ```
|
|
46
46
|
*/
|
|
47
47
|
declare function concurrentCmd(label: string, cmd: string | string[], onResult: (result: CmdResult) => void): Promise<() => void>;
|
|
48
48
|
/**
|
|
49
|
+
* @deprecated This utility has been moved to @ls-stack/node-utils. Please
|
|
50
|
+
* update your imports:
|
|
51
|
+
*
|
|
52
|
+
* // Old (deprecated)
|
|
53
|
+
* import { runCmdUnwrap } from '@ls-stack/utils/runShellCmd';
|
|
54
|
+
*
|
|
55
|
+
* // New (preferred)
|
|
56
|
+
* import { runCmdUnwrap } from '@ls-stack/node-utils/runShellCmd';
|
|
49
57
|
* @param label
|
|
50
58
|
* @param command
|
|
51
59
|
* @param root0
|
|
52
60
|
* @param root0.silent
|
|
53
|
-
* @deprecated This utility has been moved to @ls-stack/node-utils. Please update your imports:
|
|
54
|
-
* ```
|
|
55
|
-
* // Old (deprecated)
|
|
56
|
-
* import { runCmdUnwrap } from '@ls-stack/utils/runShellCmd';
|
|
57
|
-
*
|
|
58
|
-
* // New (preferred)
|
|
59
|
-
* import { runCmdUnwrap } from '@ls-stack/node-utils/runShellCmd';
|
|
60
|
-
* ```
|
|
61
61
|
*/
|
|
62
62
|
declare function runCmdUnwrap(label: string | null, command: string | string[], { silent, }?: {
|
|
63
63
|
silent?: boolean | 'timeOnly';
|
|
64
64
|
}): Promise<string>;
|
|
65
65
|
/**
|
|
66
|
-
* @
|
|
67
|
-
*
|
|
68
|
-
* ```
|
|
69
|
-
* // Old (deprecated)
|
|
70
|
-
* import { runCmdSilent } from '@ls-stack/utils/runShellCmd';
|
|
66
|
+
* @deprecated This utility has been moved to @ls-stack/node-utils. Please
|
|
67
|
+
* update your imports:
|
|
71
68
|
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
69
|
+
* // Old (deprecated)
|
|
70
|
+
* import { runCmdSilent } from '@ls-stack/utils/runShellCmd';
|
|
71
|
+
*
|
|
72
|
+
* // New (preferred)
|
|
73
|
+
* import { runCmdSilent } from '@ls-stack/node-utils/runShellCmd';
|
|
74
|
+
* @param command
|
|
75
75
|
*/
|
|
76
76
|
declare function runCmdSilent(command: string | string[]): Promise<CmdResult>;
|
|
77
77
|
/**
|
|
78
|
-
* @
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
78
|
+
* @deprecated This utility has been moved to @ls-stack/node-utils. Please
|
|
79
|
+
* update your imports:
|
|
80
|
+
*
|
|
81
|
+
* // Old (deprecated)
|
|
82
|
+
* import { runCmdSilentUnwrap } from '@ls-stack/utils/runShellCmd';
|
|
83
83
|
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
*
|
|
84
|
+
* // New (preferred)
|
|
85
|
+
* import { runCmdSilentUnwrap } from '@ls-stack/node-utils/runShellCmd';
|
|
86
|
+
* @param command
|
|
87
87
|
*/
|
|
88
88
|
declare function runCmdSilentUnwrap(command: string | string[]): Promise<string>;
|
|
89
89
|
|
package/dist/runShellCmd.d.ts
CHANGED
|
@@ -13,6 +13,14 @@ type RunCmdOptions = {
|
|
|
13
13
|
noCiColorForce?: boolean;
|
|
14
14
|
};
|
|
15
15
|
/**
|
|
16
|
+
* @deprecated This utility has been moved to @ls-stack/node-utils. Please
|
|
17
|
+
* update your imports:
|
|
18
|
+
*
|
|
19
|
+
* // Old (deprecated)
|
|
20
|
+
* import { runCmd } from '@ls-stack/utils/runShellCmd';
|
|
21
|
+
*
|
|
22
|
+
* // New (preferred)
|
|
23
|
+
* import { runCmd } from '@ls-stack/node-utils/runShellCmd';
|
|
16
24
|
* @param label
|
|
17
25
|
* @param command
|
|
18
26
|
* @param root0
|
|
@@ -21,69 +29,61 @@ type RunCmdOptions = {
|
|
|
21
29
|
* @param root0.throwOnError
|
|
22
30
|
* @param root0.cwd
|
|
23
31
|
* @param root0.noCiColorForce
|
|
24
|
-
* @deprecated This utility has been moved to @ls-stack/node-utils. Please update your imports:
|
|
25
|
-
* ```
|
|
26
|
-
* // Old (deprecated)
|
|
27
|
-
* import { runCmd } from '@ls-stack/utils/runShellCmd';
|
|
28
|
-
*
|
|
29
|
-
* // New (preferred)
|
|
30
|
-
* import { runCmd } from '@ls-stack/node-utils/runShellCmd';
|
|
31
|
-
* ```
|
|
32
32
|
*/
|
|
33
33
|
declare function runCmd(label: string | null, command: string | string[], { mock, silent, throwOnError, cwd, noCiColorForce, }?: RunCmdOptions): Promise<CmdResult>;
|
|
34
34
|
/**
|
|
35
|
+
* @deprecated This utility has been moved to @ls-stack/node-utils. Please
|
|
36
|
+
* update your imports:
|
|
37
|
+
*
|
|
38
|
+
* // Old (deprecated)
|
|
39
|
+
* import { concurrentCmd } from '@ls-stack/utils/runShellCmd';
|
|
40
|
+
*
|
|
41
|
+
* // New (preferred)
|
|
42
|
+
* import { concurrentCmd } from '@ls-stack/node-utils/runShellCmd';
|
|
35
43
|
* @param label
|
|
36
44
|
* @param cmd
|
|
37
45
|
* @param onResult
|
|
38
|
-
* @deprecated This utility has been moved to @ls-stack/node-utils. Please update your imports:
|
|
39
|
-
* ```
|
|
40
|
-
* // Old (deprecated)
|
|
41
|
-
* import { concurrentCmd } from '@ls-stack/utils/runShellCmd';
|
|
42
|
-
*
|
|
43
|
-
* // New (preferred)
|
|
44
|
-
* import { concurrentCmd } from '@ls-stack/node-utils/runShellCmd';
|
|
45
|
-
* ```
|
|
46
46
|
*/
|
|
47
47
|
declare function concurrentCmd(label: string, cmd: string | string[], onResult: (result: CmdResult) => void): Promise<() => void>;
|
|
48
48
|
/**
|
|
49
|
+
* @deprecated This utility has been moved to @ls-stack/node-utils. Please
|
|
50
|
+
* update your imports:
|
|
51
|
+
*
|
|
52
|
+
* // Old (deprecated)
|
|
53
|
+
* import { runCmdUnwrap } from '@ls-stack/utils/runShellCmd';
|
|
54
|
+
*
|
|
55
|
+
* // New (preferred)
|
|
56
|
+
* import { runCmdUnwrap } from '@ls-stack/node-utils/runShellCmd';
|
|
49
57
|
* @param label
|
|
50
58
|
* @param command
|
|
51
59
|
* @param root0
|
|
52
60
|
* @param root0.silent
|
|
53
|
-
* @deprecated This utility has been moved to @ls-stack/node-utils. Please update your imports:
|
|
54
|
-
* ```
|
|
55
|
-
* // Old (deprecated)
|
|
56
|
-
* import { runCmdUnwrap } from '@ls-stack/utils/runShellCmd';
|
|
57
|
-
*
|
|
58
|
-
* // New (preferred)
|
|
59
|
-
* import { runCmdUnwrap } from '@ls-stack/node-utils/runShellCmd';
|
|
60
|
-
* ```
|
|
61
61
|
*/
|
|
62
62
|
declare function runCmdUnwrap(label: string | null, command: string | string[], { silent, }?: {
|
|
63
63
|
silent?: boolean | 'timeOnly';
|
|
64
64
|
}): Promise<string>;
|
|
65
65
|
/**
|
|
66
|
-
* @
|
|
67
|
-
*
|
|
68
|
-
* ```
|
|
69
|
-
* // Old (deprecated)
|
|
70
|
-
* import { runCmdSilent } from '@ls-stack/utils/runShellCmd';
|
|
66
|
+
* @deprecated This utility has been moved to @ls-stack/node-utils. Please
|
|
67
|
+
* update your imports:
|
|
71
68
|
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
69
|
+
* // Old (deprecated)
|
|
70
|
+
* import { runCmdSilent } from '@ls-stack/utils/runShellCmd';
|
|
71
|
+
*
|
|
72
|
+
* // New (preferred)
|
|
73
|
+
* import { runCmdSilent } from '@ls-stack/node-utils/runShellCmd';
|
|
74
|
+
* @param command
|
|
75
75
|
*/
|
|
76
76
|
declare function runCmdSilent(command: string | string[]): Promise<CmdResult>;
|
|
77
77
|
/**
|
|
78
|
-
* @
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
78
|
+
* @deprecated This utility has been moved to @ls-stack/node-utils. Please
|
|
79
|
+
* update your imports:
|
|
80
|
+
*
|
|
81
|
+
* // Old (deprecated)
|
|
82
|
+
* import { runCmdSilentUnwrap } from '@ls-stack/utils/runShellCmd';
|
|
83
83
|
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
*
|
|
84
|
+
* // New (preferred)
|
|
85
|
+
* import { runCmdSilentUnwrap } from '@ls-stack/node-utils/runShellCmd';
|
|
86
|
+
* @param command
|
|
87
87
|
*/
|
|
88
88
|
declare function runCmdSilentUnwrap(command: string | string[]): Promise<string>;
|
|
89
89
|
|
package/dist/safeJson.d.cts
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* JSON.stringify can throw if the value is circular or contains functions, this
|
|
2
|
+
* JSON.stringify can throw if the value is circular or contains functions, this
|
|
3
|
+
* function catches those errors and returns undefined
|
|
4
|
+
*
|
|
3
5
|
* @param value
|
|
4
6
|
*/
|
|
5
7
|
declare function safeJsonStringify(value: unknown): string | undefined;
|
|
6
8
|
/**
|
|
7
|
-
* JSON.parse can throw if the value is not valid JSON, this function catches
|
|
9
|
+
* JSON.parse can throw if the value is not valid JSON, this function catches
|
|
10
|
+
* those errors and returns undefined
|
|
11
|
+
*
|
|
8
12
|
* @param value
|
|
9
13
|
*/
|
|
10
14
|
declare function safeJsonParse(value: string): unknown;
|
package/dist/safeJson.d.ts
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* JSON.stringify can throw if the value is circular or contains functions, this
|
|
2
|
+
* JSON.stringify can throw if the value is circular or contains functions, this
|
|
3
|
+
* function catches those errors and returns undefined
|
|
4
|
+
*
|
|
3
5
|
* @param value
|
|
4
6
|
*/
|
|
5
7
|
declare function safeJsonStringify(value: unknown): string | undefined;
|
|
6
8
|
/**
|
|
7
|
-
* JSON.parse can throw if the value is not valid JSON, this function catches
|
|
9
|
+
* JSON.parse can throw if the value is not valid JSON, this function catches
|
|
10
|
+
* those errors and returns undefined
|
|
11
|
+
*
|
|
8
12
|
* @param value
|
|
9
13
|
*/
|
|
10
14
|
declare function safeJsonParse(value: string): unknown;
|
package/dist/saferTyping.d.cts
CHANGED
|
@@ -1,39 +1,46 @@
|
|
|
1
|
-
/** Use this only when you have 100% of certainty that this will not break the types */
|
|
2
|
-
type __LEGIT_ANY__ = any;
|
|
3
|
-
type __LEGIT_ANY_FUNCTION__ = (...params: any) => __LEGIT_ANY__;
|
|
4
1
|
/**
|
|
5
|
-
*
|
|
2
|
+
* Use this only when you have 100% of certainty that this will not break the
|
|
3
|
+
* types
|
|
6
4
|
*/
|
|
5
|
+
type __LEGIT_ANY__ = any;
|
|
6
|
+
type __LEGIT_ANY_FUNCTION__ = (...params: any) => __LEGIT_ANY__;
|
|
7
|
+
/** An empty object type, equivalent to `{}` but with safer typing */
|
|
7
8
|
type EmptyObject = Record<string, never>;
|
|
8
9
|
/**
|
|
9
|
-
* Cast a value to `any` type. Use this when you have legit usage of `any`
|
|
10
|
+
* Cast a value to `any` type. Use this when you have legit usage of `any`
|
|
11
|
+
* casting.
|
|
10
12
|
*
|
|
13
|
+
* @template V (optional) - When used enforces that the casted value is
|
|
14
|
+
* assignable to the type V, use it for safer casts
|
|
11
15
|
* @param value
|
|
12
|
-
* @template V (optional) - When used enforces that the casted value is assignable to the type V, use it for safer casts
|
|
13
16
|
*/
|
|
14
17
|
declare function __LEGIT_ANY_CAST__<V = unknown>(value: V): __LEGIT_ANY__;
|
|
15
18
|
/**
|
|
16
|
-
* Cast a value to a specific type T. Use this when you have legit usage of type
|
|
19
|
+
* Cast a value to a specific type T. Use this when you have legit usage of type
|
|
20
|
+
* assertion.
|
|
17
21
|
*
|
|
18
|
-
* @param value
|
|
19
22
|
* @template T - The type to cast to
|
|
20
|
-
* @template V (optional) - When used enforces that the casted value is
|
|
23
|
+
* @template V (optional) - When used enforces that the casted value is
|
|
24
|
+
* assignable to the type V, use it for safer casts
|
|
25
|
+
* @param value
|
|
21
26
|
*/
|
|
22
27
|
declare function __LEGIT_CAST__<T, V = unknown>(value: V): T;
|
|
23
28
|
/**
|
|
24
|
-
* Refine a value to a specific type T. Use this when you have legit usage of
|
|
29
|
+
* Refine a value to a specific type T. Use this when you have legit usage of
|
|
30
|
+
* type assertion.
|
|
25
31
|
*
|
|
26
|
-
* @param value
|
|
27
32
|
* @template T - The type to cast to
|
|
28
|
-
* @template V (optional) - When used enforces that the casted value is
|
|
33
|
+
* @template V (optional) - When used enforces that the casted value is
|
|
34
|
+
* assignable to the type V, use it for safer casts
|
|
35
|
+
* @param value
|
|
29
36
|
*/
|
|
30
37
|
declare function __REFINE_CAST__<T>(value: T): <R extends T>() => R;
|
|
31
38
|
declare function __FIX_THIS_CASTING__<T>(value: unknown): T;
|
|
32
39
|
type __FIX_THIS_TYPING__ = any;
|
|
33
40
|
declare function __FIX_THIS_TYPING__(value: unknown): __LEGIT_ANY__;
|
|
34
41
|
/**
|
|
35
|
-
* Any type that is not a primitive (number, string, boolean, null, undefined,
|
|
36
|
-
* Equivalent to `object` type
|
|
42
|
+
* Any type that is not a primitive (number, string, boolean, null, undefined,
|
|
43
|
+
* symbol, bigint, ...) Equivalent to `object` type
|
|
37
44
|
*/
|
|
38
45
|
type AnyNonPrimitiveValue = object;
|
|
39
46
|
|
package/dist/saferTyping.d.ts
CHANGED
|
@@ -1,39 +1,46 @@
|
|
|
1
|
-
/** Use this only when you have 100% of certainty that this will not break the types */
|
|
2
|
-
type __LEGIT_ANY__ = any;
|
|
3
|
-
type __LEGIT_ANY_FUNCTION__ = (...params: any) => __LEGIT_ANY__;
|
|
4
1
|
/**
|
|
5
|
-
*
|
|
2
|
+
* Use this only when you have 100% of certainty that this will not break the
|
|
3
|
+
* types
|
|
6
4
|
*/
|
|
5
|
+
type __LEGIT_ANY__ = any;
|
|
6
|
+
type __LEGIT_ANY_FUNCTION__ = (...params: any) => __LEGIT_ANY__;
|
|
7
|
+
/** An empty object type, equivalent to `{}` but with safer typing */
|
|
7
8
|
type EmptyObject = Record<string, never>;
|
|
8
9
|
/**
|
|
9
|
-
* Cast a value to `any` type. Use this when you have legit usage of `any`
|
|
10
|
+
* Cast a value to `any` type. Use this when you have legit usage of `any`
|
|
11
|
+
* casting.
|
|
10
12
|
*
|
|
13
|
+
* @template V (optional) - When used enforces that the casted value is
|
|
14
|
+
* assignable to the type V, use it for safer casts
|
|
11
15
|
* @param value
|
|
12
|
-
* @template V (optional) - When used enforces that the casted value is assignable to the type V, use it for safer casts
|
|
13
16
|
*/
|
|
14
17
|
declare function __LEGIT_ANY_CAST__<V = unknown>(value: V): __LEGIT_ANY__;
|
|
15
18
|
/**
|
|
16
|
-
* Cast a value to a specific type T. Use this when you have legit usage of type
|
|
19
|
+
* Cast a value to a specific type T. Use this when you have legit usage of type
|
|
20
|
+
* assertion.
|
|
17
21
|
*
|
|
18
|
-
* @param value
|
|
19
22
|
* @template T - The type to cast to
|
|
20
|
-
* @template V (optional) - When used enforces that the casted value is
|
|
23
|
+
* @template V (optional) - When used enforces that the casted value is
|
|
24
|
+
* assignable to the type V, use it for safer casts
|
|
25
|
+
* @param value
|
|
21
26
|
*/
|
|
22
27
|
declare function __LEGIT_CAST__<T, V = unknown>(value: V): T;
|
|
23
28
|
/**
|
|
24
|
-
* Refine a value to a specific type T. Use this when you have legit usage of
|
|
29
|
+
* Refine a value to a specific type T. Use this when you have legit usage of
|
|
30
|
+
* type assertion.
|
|
25
31
|
*
|
|
26
|
-
* @param value
|
|
27
32
|
* @template T - The type to cast to
|
|
28
|
-
* @template V (optional) - When used enforces that the casted value is
|
|
33
|
+
* @template V (optional) - When used enforces that the casted value is
|
|
34
|
+
* assignable to the type V, use it for safer casts
|
|
35
|
+
* @param value
|
|
29
36
|
*/
|
|
30
37
|
declare function __REFINE_CAST__<T>(value: T): <R extends T>() => R;
|
|
31
38
|
declare function __FIX_THIS_CASTING__<T>(value: unknown): T;
|
|
32
39
|
type __FIX_THIS_TYPING__ = any;
|
|
33
40
|
declare function __FIX_THIS_TYPING__(value: unknown): __LEGIT_ANY__;
|
|
34
41
|
/**
|
|
35
|
-
* Any type that is not a primitive (number, string, boolean, null, undefined,
|
|
36
|
-
* Equivalent to `object` type
|
|
42
|
+
* Any type that is not a primitive (number, string, boolean, null, undefined,
|
|
43
|
+
* symbol, bigint, ...) Equivalent to `object` type
|
|
37
44
|
*/
|
|
38
45
|
type AnyNonPrimitiveValue = object;
|
|
39
46
|
|
package/dist/shallowEqual.d.cts
CHANGED
package/dist/shallowEqual.d.ts
CHANGED
package/dist/stringUtils.cjs
CHANGED
|
@@ -67,10 +67,10 @@ function convertToCamelCase(str) {
|
|
|
67
67
|
return pascalCase.charAt(0).toLowerCase() + pascalCase.slice(1);
|
|
68
68
|
}
|
|
69
69
|
function convertToSentenceCase(str) {
|
|
70
|
-
return str.split(/[\s_-]+/).map((word) => word.toLowerCase()).join(" ").replace(/^\w/, (char) => char.toUpperCase());
|
|
70
|
+
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());
|
|
71
71
|
}
|
|
72
72
|
function convertToTitleCase(str) {
|
|
73
|
-
return str.split(/[\s_-]+/).map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join(" ");
|
|
73
|
+
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(" ");
|
|
74
74
|
}
|
|
75
75
|
function truncateString(str, length, ellipsis = "\u2026") {
|
|
76
76
|
if (str.length <= length) return str;
|
package/dist/stringUtils.d.cts
CHANGED
|
@@ -2,16 +2,15 @@ type Arg = string | false | undefined | null;
|
|
|
2
2
|
/**
|
|
3
3
|
* A util to create more legible conditional concatenated strings
|
|
4
4
|
*
|
|
5
|
-
* @param args
|
|
6
5
|
* @example
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
6
|
+
* joinStrings('a', 'b', 'c'); // 'abc'
|
|
7
|
+
* joinStrings('a', false, 'c'); // 'ac'
|
|
8
|
+
* joinStrings('a', addBString ? 'b' : null, 'c'); // 'ac' if addBString is false, 'abc' if addBString is true
|
|
9
|
+
*
|
|
10
|
+
* @param args
|
|
10
11
|
*/
|
|
11
12
|
declare function concatStrings(...args: (Arg | Arg[])[]): string;
|
|
12
|
-
/**
|
|
13
|
-
* @deprecated Use {@link concatStrings} instead
|
|
14
|
-
*/
|
|
13
|
+
/** @deprecated Use {@link concatStrings} instead */
|
|
15
14
|
declare const joinStrings: typeof concatStrings;
|
|
16
15
|
declare function formatNum(num: number, maxDecimalsOrOptions?: number | Intl.NumberFormatOptions): string;
|
|
17
16
|
declare function isSnakeCase(str: string): boolean;
|
package/dist/stringUtils.d.ts
CHANGED
|
@@ -2,16 +2,15 @@ type Arg = string | false | undefined | null;
|
|
|
2
2
|
/**
|
|
3
3
|
* A util to create more legible conditional concatenated strings
|
|
4
4
|
*
|
|
5
|
-
* @param args
|
|
6
5
|
* @example
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
6
|
+
* joinStrings('a', 'b', 'c'); // 'abc'
|
|
7
|
+
* joinStrings('a', false, 'c'); // 'ac'
|
|
8
|
+
* joinStrings('a', addBString ? 'b' : null, 'c'); // 'ac' if addBString is false, 'abc' if addBString is true
|
|
9
|
+
*
|
|
10
|
+
* @param args
|
|
10
11
|
*/
|
|
11
12
|
declare function concatStrings(...args: (Arg | Arg[])[]): string;
|
|
12
|
-
/**
|
|
13
|
-
* @deprecated Use {@link concatStrings} instead
|
|
14
|
-
*/
|
|
13
|
+
/** @deprecated Use {@link concatStrings} instead */
|
|
15
14
|
declare const joinStrings: typeof concatStrings;
|
|
16
15
|
declare function formatNum(num: number, maxDecimalsOrOptions?: number | Intl.NumberFormatOptions): string;
|
|
17
16
|
declare function isSnakeCase(str: string): boolean;
|
package/dist/stringUtils.js
CHANGED
package/dist/testUtils.cjs
CHANGED
|
@@ -788,14 +788,12 @@ function stringifyValue(value, indent, maxLineLength, showUndefined, maxDepth, d
|
|
|
788
788
|
const entries = Object.entries(value).filter(
|
|
789
789
|
([, val]) => val !== void 0 || showUndefined
|
|
790
790
|
);
|
|
791
|
-
const isSimpleObject = entries.every(
|
|
792
|
-
(
|
|
793
|
-
|
|
794
|
-
return !val.includes("'") && !val.includes('"') && !val.includes("\\");
|
|
795
|
-
}
|
|
796
|
-
return typeof val === "number" || typeof val === "boolean" || val === null || val === void 0;
|
|
791
|
+
const isSimpleObject = entries.every(([, val]) => {
|
|
792
|
+
if (typeof val === "string") {
|
|
793
|
+
return !val.includes("'") && !val.includes('"') && !val.includes("\\");
|
|
797
794
|
}
|
|
798
|
-
|
|
795
|
+
return typeof val === "number" || typeof val === "boolean" || val === null || val === void 0;
|
|
796
|
+
});
|
|
799
797
|
const shouldCollapse = isArrayItem ? entries.length > 1 : entries.length > 0;
|
|
800
798
|
if (isSimpleObject && shouldCollapse) {
|
|
801
799
|
let line = "{ ";
|
|
@@ -848,7 +846,9 @@ function stringifyValue(value, indent, maxLineLength, showUndefined, maxDepth, d
|
|
|
848
846
|
false
|
|
849
847
|
);
|
|
850
848
|
const willBeCollapsed = isObject(objVal) && (Object.keys(objVal).length === 0 || collapseObjects && depth + 1 > 0 && (() => {
|
|
851
|
-
const filteredEntries = Object.entries(objVal).filter(
|
|
849
|
+
const filteredEntries = Object.entries(objVal).filter(
|
|
850
|
+
([, val]) => val !== void 0 || showUndefined
|
|
851
|
+
);
|
|
852
852
|
const shouldCollapseThis = isArrayItem ? filteredEntries.length > 1 : filteredEntries.length > 0;
|
|
853
853
|
return shouldCollapseThis && filteredEntries.every(([, val]) => {
|
|
854
854
|
if (typeof val === "string") {
|
|
@@ -858,7 +858,9 @@ function stringifyValue(value, indent, maxLineLength, showUndefined, maxDepth, d
|
|
|
858
858
|
});
|
|
859
859
|
})());
|
|
860
860
|
const prevWasCollapsed = prevValue && isObject(prevValue) && (Object.keys(prevValue).length === 0 || collapseObjects && depth + 1 > 0 && (() => {
|
|
861
|
-
const filteredEntries = Object.entries(prevValue).filter(
|
|
861
|
+
const filteredEntries = Object.entries(prevValue).filter(
|
|
862
|
+
([, val]) => val !== void 0 || showUndefined
|
|
863
|
+
);
|
|
862
864
|
const shouldCollapseThis = isArrayItem ? filteredEntries.length > 1 : filteredEntries.length > 0;
|
|
863
865
|
return shouldCollapseThis && filteredEntries.every(([, val]) => {
|
|
864
866
|
if (typeof val === "string") {
|