@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
|
@@ -3,36 +3,77 @@ type TestTypeNotEqual<X, Y> = true extends TestTypeIsEqual<X, Y> ? false : true;
|
|
|
3
3
|
declare function test(title: string, func: () => any): void;
|
|
4
4
|
declare function describe(title: string, func: () => any): void;
|
|
5
5
|
/**
|
|
6
|
-
* Helper function for type testing that ensures a type extends `true`.
|
|
7
|
-
*
|
|
6
|
+
* Helper function for type testing that ensures a type extends `true`. Used in
|
|
7
|
+
* combination with `TestTypeIsEqual` to verify type equality at compile time.
|
|
8
8
|
*
|
|
9
|
+
* @deprecated Use {@link expectTypesAreEqual} or {@link expectTypesAreNotEqual}
|
|
10
|
+
* instead
|
|
9
11
|
* @example
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
+
* expectType<TestTypeIsEqual<string, string>>(); // OK
|
|
13
|
+
* expectType<TestTypeIsEqual<string, number>>(); // Type error
|
|
12
14
|
*
|
|
13
15
|
* @template T Type that must extend `true`
|
|
14
16
|
* @returns An empty object cast to type T
|
|
15
17
|
*/
|
|
16
18
|
declare function expectType<T extends true>(): T;
|
|
17
19
|
/**
|
|
18
|
-
* Helper function for type testing that compares two types and expects a
|
|
19
|
-
* This function allows for more explicit type equality
|
|
20
|
+
* Helper function for type testing that compares two types and expects a
|
|
21
|
+
* specific result. This function allows for more explicit type equality
|
|
22
|
+
* assertions with a descriptive result.
|
|
23
|
+
*
|
|
24
|
+
* @deprecated Use {@link expectTypesAreEqual} or {@link expectTypesAreNotEqual}
|
|
25
|
+
* instead
|
|
26
|
+
* @example
|
|
27
|
+
* expectTypesAre<string, string>('equal'); // OK
|
|
28
|
+
* expectTypesAre<string, number>('notEqual'); // OK
|
|
29
|
+
* expectTypesAre<string, string>('notEqual'); // Type error
|
|
30
|
+
*
|
|
31
|
+
* @template X First type to compare
|
|
32
|
+
* @template Y Second type to compare
|
|
33
|
+
* @param result Expected comparison result: 'equal' if types are equal,
|
|
34
|
+
* 'notEqual' if they differ
|
|
35
|
+
*/
|
|
36
|
+
declare function expectTypesAre<X, Y>(result: TestTypeIsEqual<X, Y> extends true ? 'equal' : 'notEqual'): void;
|
|
37
|
+
/**
|
|
38
|
+
* Helper function for type testing that ensures two types are equal. If types
|
|
39
|
+
* are not equal, it will show a compile-time error with details about the
|
|
40
|
+
* mismatch.
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* expectTypesAreEqual<string, string>(); // OK
|
|
44
|
+
* expectTypesAreEqual<string, number>(); // Compile error with details
|
|
20
45
|
*
|
|
21
46
|
* @template X First type to compare
|
|
22
47
|
* @template Y Second type to compare
|
|
23
|
-
* @param result
|
|
48
|
+
* @param result Optional error parameter that appears only when types don't
|
|
49
|
+
* match
|
|
50
|
+
*/
|
|
51
|
+
declare function expectTypesAreEqual<X, Y>(...result: TestTypeIsEqual<X, Y> extends true ? [] : [
|
|
52
|
+
error: 'type assertion failed, types should be equal but',
|
|
53
|
+
typeOnLeft: X,
|
|
54
|
+
_: 'is not equal to',
|
|
55
|
+
typeOnRight: Y
|
|
56
|
+
]): void;
|
|
57
|
+
/**
|
|
58
|
+
* Helper function for type testing that ensures two types are not equal. If
|
|
59
|
+
* types are equal, it will show a compile-time error.
|
|
24
60
|
*
|
|
25
61
|
* @example
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
62
|
+
* expectTypesAreNotEqual<string, number>(); // OK
|
|
63
|
+
* expectTypesAreNotEqual<string, string>(); // Compile error
|
|
64
|
+
*
|
|
65
|
+
* @template X First type to compare
|
|
66
|
+
* @template Y Second type to compare
|
|
67
|
+
* @param result Optional error parameter that appears only when types match
|
|
29
68
|
*/
|
|
30
|
-
declare function
|
|
69
|
+
declare function expectTypesAreNotEqual<X, Y>(...result: TestTypeIsEqual<X, Y> extends false ? [] : ['error: type assertion failed, types should be NOT equal']): void;
|
|
31
70
|
declare const typingTest: {
|
|
32
71
|
test: typeof test;
|
|
33
72
|
describe: typeof describe;
|
|
34
73
|
expectType: typeof expectType;
|
|
35
74
|
expectTypesAre: typeof expectTypesAre;
|
|
75
|
+
expectTypesAreEqual: typeof expectTypesAreEqual;
|
|
76
|
+
expectTypesAreNotEqual: typeof expectTypesAreNotEqual;
|
|
36
77
|
};
|
|
37
78
|
|
|
38
79
|
export { type TestTypeIsEqual, type TestTypeNotEqual, typingTest };
|
|
@@ -3,36 +3,77 @@ type TestTypeNotEqual<X, Y> = true extends TestTypeIsEqual<X, Y> ? false : true;
|
|
|
3
3
|
declare function test(title: string, func: () => any): void;
|
|
4
4
|
declare function describe(title: string, func: () => any): void;
|
|
5
5
|
/**
|
|
6
|
-
* Helper function for type testing that ensures a type extends `true`.
|
|
7
|
-
*
|
|
6
|
+
* Helper function for type testing that ensures a type extends `true`. Used in
|
|
7
|
+
* combination with `TestTypeIsEqual` to verify type equality at compile time.
|
|
8
8
|
*
|
|
9
|
+
* @deprecated Use {@link expectTypesAreEqual} or {@link expectTypesAreNotEqual}
|
|
10
|
+
* instead
|
|
9
11
|
* @example
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
+
* expectType<TestTypeIsEqual<string, string>>(); // OK
|
|
13
|
+
* expectType<TestTypeIsEqual<string, number>>(); // Type error
|
|
12
14
|
*
|
|
13
15
|
* @template T Type that must extend `true`
|
|
14
16
|
* @returns An empty object cast to type T
|
|
15
17
|
*/
|
|
16
18
|
declare function expectType<T extends true>(): T;
|
|
17
19
|
/**
|
|
18
|
-
* Helper function for type testing that compares two types and expects a
|
|
19
|
-
* This function allows for more explicit type equality
|
|
20
|
+
* Helper function for type testing that compares two types and expects a
|
|
21
|
+
* specific result. This function allows for more explicit type equality
|
|
22
|
+
* assertions with a descriptive result.
|
|
23
|
+
*
|
|
24
|
+
* @deprecated Use {@link expectTypesAreEqual} or {@link expectTypesAreNotEqual}
|
|
25
|
+
* instead
|
|
26
|
+
* @example
|
|
27
|
+
* expectTypesAre<string, string>('equal'); // OK
|
|
28
|
+
* expectTypesAre<string, number>('notEqual'); // OK
|
|
29
|
+
* expectTypesAre<string, string>('notEqual'); // Type error
|
|
30
|
+
*
|
|
31
|
+
* @template X First type to compare
|
|
32
|
+
* @template Y Second type to compare
|
|
33
|
+
* @param result Expected comparison result: 'equal' if types are equal,
|
|
34
|
+
* 'notEqual' if they differ
|
|
35
|
+
*/
|
|
36
|
+
declare function expectTypesAre<X, Y>(result: TestTypeIsEqual<X, Y> extends true ? 'equal' : 'notEqual'): void;
|
|
37
|
+
/**
|
|
38
|
+
* Helper function for type testing that ensures two types are equal. If types
|
|
39
|
+
* are not equal, it will show a compile-time error with details about the
|
|
40
|
+
* mismatch.
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* expectTypesAreEqual<string, string>(); // OK
|
|
44
|
+
* expectTypesAreEqual<string, number>(); // Compile error with details
|
|
20
45
|
*
|
|
21
46
|
* @template X First type to compare
|
|
22
47
|
* @template Y Second type to compare
|
|
23
|
-
* @param result
|
|
48
|
+
* @param result Optional error parameter that appears only when types don't
|
|
49
|
+
* match
|
|
50
|
+
*/
|
|
51
|
+
declare function expectTypesAreEqual<X, Y>(...result: TestTypeIsEqual<X, Y> extends true ? [] : [
|
|
52
|
+
error: 'type assertion failed, types should be equal but',
|
|
53
|
+
typeOnLeft: X,
|
|
54
|
+
_: 'is not equal to',
|
|
55
|
+
typeOnRight: Y
|
|
56
|
+
]): void;
|
|
57
|
+
/**
|
|
58
|
+
* Helper function for type testing that ensures two types are not equal. If
|
|
59
|
+
* types are equal, it will show a compile-time error.
|
|
24
60
|
*
|
|
25
61
|
* @example
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
62
|
+
* expectTypesAreNotEqual<string, number>(); // OK
|
|
63
|
+
* expectTypesAreNotEqual<string, string>(); // Compile error
|
|
64
|
+
*
|
|
65
|
+
* @template X First type to compare
|
|
66
|
+
* @template Y Second type to compare
|
|
67
|
+
* @param result Optional error parameter that appears only when types match
|
|
29
68
|
*/
|
|
30
|
-
declare function
|
|
69
|
+
declare function expectTypesAreNotEqual<X, Y>(...result: TestTypeIsEqual<X, Y> extends false ? [] : ['error: type assertion failed, types should be NOT equal']): void;
|
|
31
70
|
declare const typingTest: {
|
|
32
71
|
test: typeof test;
|
|
33
72
|
describe: typeof describe;
|
|
34
73
|
expectType: typeof expectType;
|
|
35
74
|
expectTypesAre: typeof expectTypesAre;
|
|
75
|
+
expectTypesAreEqual: typeof expectTypesAreEqual;
|
|
76
|
+
expectTypesAreNotEqual: typeof expectTypesAreNotEqual;
|
|
36
77
|
};
|
|
37
78
|
|
|
38
79
|
export { type TestTypeIsEqual, type TestTypeNotEqual, typingTest };
|
package/dist/typingTestUtils.js
CHANGED
|
@@ -10,11 +10,17 @@ function expectType() {
|
|
|
10
10
|
}
|
|
11
11
|
function expectTypesAre(result) {
|
|
12
12
|
}
|
|
13
|
+
function expectTypesAreEqual(...result) {
|
|
14
|
+
}
|
|
15
|
+
function expectTypesAreNotEqual(...result) {
|
|
16
|
+
}
|
|
13
17
|
var typingTest = {
|
|
14
18
|
test,
|
|
15
19
|
describe,
|
|
16
20
|
expectType,
|
|
17
|
-
expectTypesAre
|
|
21
|
+
expectTypesAre,
|
|
22
|
+
expectTypesAreEqual,
|
|
23
|
+
expectTypesAreNotEqual
|
|
18
24
|
};
|
|
19
25
|
export {
|
|
20
26
|
typingTest
|
package/dist/typingUtils.d.cts
CHANGED
|
@@ -6,7 +6,10 @@ type PartialRecord<K extends keyof any, T> = {
|
|
|
6
6
|
type NonPartial<T> = {
|
|
7
7
|
[K in keyof Required<T>]: T[K];
|
|
8
8
|
};
|
|
9
|
-
/**
|
|
9
|
+
/**
|
|
10
|
+
* @deprecated Use `ObjKeysWithValuesOfType` from `@ls-stack/utils/typeUtils`
|
|
11
|
+
* instead
|
|
12
|
+
*/
|
|
10
13
|
type ObjKeysWithValuesOfType<Obj extends Record<PropertyKey, unknown>, ValueType> = {
|
|
11
14
|
[K in keyof Obj]: Obj[K] extends ValueType ? K : never;
|
|
12
15
|
}[keyof Obj];
|
package/dist/typingUtils.d.ts
CHANGED
|
@@ -6,7 +6,10 @@ type PartialRecord<K extends keyof any, T> = {
|
|
|
6
6
|
type NonPartial<T> = {
|
|
7
7
|
[K in keyof Required<T>]: T[K];
|
|
8
8
|
};
|
|
9
|
-
/**
|
|
9
|
+
/**
|
|
10
|
+
* @deprecated Use `ObjKeysWithValuesOfType` from `@ls-stack/utils/typeUtils`
|
|
11
|
+
* instead
|
|
12
|
+
*/
|
|
10
13
|
type ObjKeysWithValuesOfType<Obj extends Record<PropertyKey, unknown>, ValueType> = {
|
|
11
14
|
[K in keyof Obj]: Obj[K] extends ValueType ? K : never;
|
|
12
15
|
}[keyof Obj];
|
package/dist/yamlStringify.cjs
CHANGED
|
@@ -88,14 +88,12 @@ function stringifyValue(value, indent, maxLineLength, showUndefined, maxDepth, d
|
|
|
88
88
|
const entries = Object.entries(value).filter(
|
|
89
89
|
([, val]) => val !== void 0 || showUndefined
|
|
90
90
|
);
|
|
91
|
-
const isSimpleObject = entries.every(
|
|
92
|
-
(
|
|
93
|
-
|
|
94
|
-
return !val.includes("'") && !val.includes('"') && !val.includes("\\");
|
|
95
|
-
}
|
|
96
|
-
return typeof val === "number" || typeof val === "boolean" || val === null || val === void 0;
|
|
91
|
+
const isSimpleObject = entries.every(([, val]) => {
|
|
92
|
+
if (typeof val === "string") {
|
|
93
|
+
return !val.includes("'") && !val.includes('"') && !val.includes("\\");
|
|
97
94
|
}
|
|
98
|
-
|
|
95
|
+
return typeof val === "number" || typeof val === "boolean" || val === null || val === void 0;
|
|
96
|
+
});
|
|
99
97
|
const shouldCollapse = isArrayItem ? entries.length > 1 : entries.length > 0;
|
|
100
98
|
if (isSimpleObject && shouldCollapse) {
|
|
101
99
|
let line = "{ ";
|
|
@@ -148,7 +146,9 @@ function stringifyValue(value, indent, maxLineLength, showUndefined, maxDepth, d
|
|
|
148
146
|
false
|
|
149
147
|
);
|
|
150
148
|
const willBeCollapsed = isObject(objVal) && (Object.keys(objVal).length === 0 || collapseObjects && depth + 1 > 0 && (() => {
|
|
151
|
-
const filteredEntries = Object.entries(objVal).filter(
|
|
149
|
+
const filteredEntries = Object.entries(objVal).filter(
|
|
150
|
+
([, val]) => val !== void 0 || showUndefined
|
|
151
|
+
);
|
|
152
152
|
const shouldCollapseThis = isArrayItem ? filteredEntries.length > 1 : filteredEntries.length > 0;
|
|
153
153
|
return shouldCollapseThis && filteredEntries.every(([, val]) => {
|
|
154
154
|
if (typeof val === "string") {
|
|
@@ -158,7 +158,9 @@ function stringifyValue(value, indent, maxLineLength, showUndefined, maxDepth, d
|
|
|
158
158
|
});
|
|
159
159
|
})());
|
|
160
160
|
const prevWasCollapsed = prevValue && isObject(prevValue) && (Object.keys(prevValue).length === 0 || collapseObjects && depth + 1 > 0 && (() => {
|
|
161
|
-
const filteredEntries = Object.entries(prevValue).filter(
|
|
161
|
+
const filteredEntries = Object.entries(prevValue).filter(
|
|
162
|
+
([, val]) => val !== void 0 || showUndefined
|
|
163
|
+
);
|
|
162
164
|
const shouldCollapseThis = isArrayItem ? filteredEntries.length > 1 : filteredEntries.length > 0;
|
|
163
165
|
return shouldCollapseThis && filteredEntries.every(([, val]) => {
|
|
164
166
|
if (typeof val === "string") {
|
package/dist/yamlStringify.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ls-stack/utils",
|
|
3
3
|
"description": "Universal TypeScript utilities for browser and Node.js",
|
|
4
|
-
"version": "3.
|
|
4
|
+
"version": "3.41.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
7
7
|
"dist",
|
|
@@ -212,6 +212,10 @@
|
|
|
212
212
|
"import": "./dist/typingTestUtils.js",
|
|
213
213
|
"require": "./dist/typingTestUtils.cjs"
|
|
214
214
|
},
|
|
215
|
+
"./typingTestUtils.typesTest": {
|
|
216
|
+
"import": "./dist/typingTestUtils.typesTest.js",
|
|
217
|
+
"require": "./dist/typingTestUtils.typesTest.cjs"
|
|
218
|
+
},
|
|
215
219
|
"./typingUtils": {
|
|
216
220
|
"import": "./dist/typingUtils.js",
|
|
217
221
|
"require": "./dist/typingUtils.cjs"
|
package/docs/README.md
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
**@ls-stack/utils**
|
|
2
|
-
|
|
3
|
-
***
|
|
4
|
-
|
|
5
|
-
# @ls-stack/utils
|
|
6
|
-
|
|
7
|
-
Generic TypeScript utilities for modern JavaScript/TypeScript projects.
|
|
8
|
-
|
|
9
|
-
## Installation
|
|
10
|
-
|
|
11
|
-
```bash
|
|
12
|
-
npm install @ls-stack/utils
|
|
13
|
-
# or
|
|
14
|
-
pnpm add @ls-stack/utils
|
|
15
|
-
# or
|
|
16
|
-
yarn add @ls-stack/utils
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
## Usage
|
|
20
|
-
|
|
21
|
-
Import specific utilities from their modules:
|
|
22
|
-
|
|
23
|
-
```typescript
|
|
24
|
-
import { createAsyncQueue } from '@ls-stack/utils/asyncQueue';
|
|
25
|
-
import { deepEqual } from '@ls-stack/utils/deepEqual';
|
|
26
|
-
import { debounce } from '@ls-stack/utils/debounce';
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
## Documentation
|
|
30
|
-
|
|
31
|
-
For a complete list of available utilities and their APIs, see the auto-generated documentation in the [`docs/`](docs/) folder. Start with the [modules overview](_media/modules.md) to explore all available utilities.
|
|
32
|
-
|
|
33
|
-
### Generating Documentation
|
|
34
|
-
|
|
35
|
-
To regenerate the documentation after making changes:
|
|
36
|
-
|
|
37
|
-
```bash
|
|
38
|
-
pnpm docs
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
For continuous updates during development:
|
|
42
|
-
|
|
43
|
-
```bash
|
|
44
|
-
pnpm docs:watch
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
## Development
|
|
48
|
-
|
|
49
|
-
```bash
|
|
50
|
-
# Install dependencies
|
|
51
|
-
pnpm install
|
|
52
|
-
|
|
53
|
-
# Run tests
|
|
54
|
-
pnpm test
|
|
55
|
-
|
|
56
|
-
# Run tests with UI
|
|
57
|
-
pnpm test:ui
|
|
58
|
-
|
|
59
|
-
# Build the library
|
|
60
|
-
pnpm build
|
|
61
|
-
|
|
62
|
-
# Lint code
|
|
63
|
-
pnpm lint
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
## License
|
|
67
|
-
|
|
68
|
-
MIT
|
|
69
|
-
|
|
70
|
-
## Repository
|
|
71
|
-
|
|
72
|
-
[github:lucasols/utils](https://github.com/lucasols/utils)
|
package/docs/_media/modules.md
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
[**@ls-stack/utils**](README.md)
|
|
2
|
-
|
|
3
|
-
***
|
|
4
|
-
|
|
5
|
-
# @ls-stack/utils
|
|
6
|
-
|
|
7
|
-
## Modules
|
|
8
|
-
|
|
9
|
-
- [arrayUtils](arrayUtils/README.md)
|
|
10
|
-
- [assertions](assertions/README.md)
|
|
11
|
-
- [asyncQueue](asyncQueue/README.md)
|
|
12
|
-
- [awaitDebounce](awaitDebounce.md)
|
|
13
|
-
- [cache](cache/README.md)
|
|
14
|
-
- [castValues](castValues.md)
|
|
15
|
-
- [concurrentCalls](concurrentCalls/README.md)
|
|
16
|
-
- [consoleFmt](consoleFmt.md)
|
|
17
|
-
- [conversions](conversions.md)
|
|
18
|
-
- [createThrottleController](createThrottleController/README.md)
|
|
19
|
-
- [debounce](debounce.md)
|
|
20
|
-
- [dedent](dedent/README.md)
|
|
21
|
-
- [deepEqual](deepEqual.md)
|
|
22
|
-
- [enhancedMap](enhancedMap.md)
|
|
23
|
-
- [exhaustiveMatch](exhaustiveMatch/README.md)
|
|
24
|
-
- [filterObjectOrArrayKeys](filterObjectOrArrayKeys.md)
|
|
25
|
-
- [getAutoIncrementId](getAutoIncrementId.md)
|
|
26
|
-
- [getCompositeKey](getCompositeKey.md)
|
|
27
|
-
- [getValueStableKey](getValueStableKey.md)
|
|
28
|
-
- [hash](hash.md)
|
|
29
|
-
- [interpolate](interpolate/README.md)
|
|
30
|
-
- [keepPrevIfUnchanged](keepPrevIfUnchanged.md)
|
|
31
|
-
- [levenshtein](levenshtein.md)
|
|
32
|
-
- [main](main.md)
|
|
33
|
-
- [mathUtils](mathUtils.md)
|
|
34
|
-
- [mutationUtils](mutationUtils.md)
|
|
35
|
-
- [objUtils](objUtils.md)
|
|
36
|
-
- [parallelAsyncCalls](parallelAsyncCalls/README.md)
|
|
37
|
-
- [promiseUtils](promiseUtils/README.md)
|
|
38
|
-
- [retryOnError](retryOnError/README.md)
|
|
39
|
-
- [runShellCmd](runShellCmd/README.md)
|
|
40
|
-
- [safeJson](safeJson.md)
|
|
41
|
-
- [saferTyping](saferTyping.md)
|
|
42
|
-
- [serializeXML](serializeXML.md)
|
|
43
|
-
- [shallowEqual](shallowEqual.md)
|
|
44
|
-
- [sleep](sleep.md)
|
|
45
|
-
- [stringUtils](stringUtils/README.md)
|
|
46
|
-
- [testUtils](testUtils.md)
|
|
47
|
-
- [throttle](throttle/README.md)
|
|
48
|
-
- [time](time.md)
|
|
49
|
-
- [timers](timers.md)
|
|
50
|
-
- [tsResult](tsResult/README.md)
|
|
51
|
-
- [typedStrings](typedStrings.md)
|
|
52
|
-
- [typeGuards](typeGuards.md)
|
|
53
|
-
- [typeUtils](typeUtils/README.md)
|
|
54
|
-
- [typeUtils.typesTest](typeUtils.typesTest.md)
|
|
55
|
-
- [typingFnUtils](typingFnUtils/README.md)
|
|
56
|
-
- [typingTestUtils](typingTestUtils.md)
|
|
57
|
-
- [typingUtils](typingUtils.md)
|
|
58
|
-
- [yamlStringify](yamlStringify.md)
|
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
[**@ls-stack/utils**](../README.md)
|
|
2
|
-
|
|
3
|
-
***
|
|
4
|
-
|
|
5
|
-
[@ls-stack/utils](../modules.md) / [arrayUtils](README.md) / \<internal\>
|
|
6
|
-
|
|
7
|
-
# \<internal\>
|
|
8
|
-
|
|
9
|
-
## Type Aliases
|
|
10
|
-
|
|
11
|
-
### ArrayOps\<T\>
|
|
12
|
-
|
|
13
|
-
```ts
|
|
14
|
-
type ArrayOps<T> = object;
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
Defined in: [packages/utils/src/arrayUtils.ts:259](https://github.com/lucasols/utils/blob/main/packages/utils/src/arrayUtils.ts#L259)
|
|
18
|
-
|
|
19
|
-
#### Type Parameters
|
|
20
|
-
|
|
21
|
-
##### T
|
|
22
|
-
|
|
23
|
-
`T`
|
|
24
|
-
|
|
25
|
-
#### Properties
|
|
26
|
-
|
|
27
|
-
##### filterAndMap()
|
|
28
|
-
|
|
29
|
-
```ts
|
|
30
|
-
filterAndMap: <R>(mapFilter) => R[];
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
Defined in: [packages/utils/src/arrayUtils.ts:272](https://github.com/lucasols/utils/blob/main/packages/utils/src/arrayUtils.ts#L272)
|
|
34
|
-
|
|
35
|
-
Filter and map an array
|
|
36
|
-
|
|
37
|
-
###### Type Parameters
|
|
38
|
-
|
|
39
|
-
###### R
|
|
40
|
-
|
|
41
|
-
`R`
|
|
42
|
-
|
|
43
|
-
###### Parameters
|
|
44
|
-
|
|
45
|
-
###### mapFilter
|
|
46
|
-
|
|
47
|
-
(`item`, `index`) => `false` \| `R`
|
|
48
|
-
|
|
49
|
-
A function that takes an item and returns a value or `false`
|
|
50
|
-
to reject the item.
|
|
51
|
-
|
|
52
|
-
###### Returns
|
|
53
|
-
|
|
54
|
-
`R`[]
|
|
55
|
-
|
|
56
|
-
###### Example
|
|
57
|
-
|
|
58
|
-
```ts
|
|
59
|
-
const items = [1, 2, 3];
|
|
60
|
-
|
|
61
|
-
const enhancedItems = arrayOps(items);
|
|
62
|
-
|
|
63
|
-
enhancedItems.filterAndMap((item) => item === 2 ? false : item);
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
##### findAndMap()
|
|
67
|
-
|
|
68
|
-
```ts
|
|
69
|
-
findAndMap: <R>(predicate) => R | undefined;
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
Defined in: [packages/utils/src/arrayUtils.ts:275](https://github.com/lucasols/utils/blob/main/packages/utils/src/arrayUtils.ts#L275)
|
|
73
|
-
|
|
74
|
-
###### Type Parameters
|
|
75
|
-
|
|
76
|
-
###### R
|
|
77
|
-
|
|
78
|
-
`R`
|
|
79
|
-
|
|
80
|
-
###### Parameters
|
|
81
|
-
|
|
82
|
-
###### predicate
|
|
83
|
-
|
|
84
|
-
(`value`) => `R` \| `false`
|
|
85
|
-
|
|
86
|
-
###### Returns
|
|
87
|
-
|
|
88
|
-
`R` \| `undefined`
|
|
89
|
-
|
|
90
|
-
##### rejectDuplicates()
|
|
91
|
-
|
|
92
|
-
```ts
|
|
93
|
-
rejectDuplicates: (getKey) => T[];
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
Defined in: [packages/utils/src/arrayUtils.ts:274](https://github.com/lucasols/utils/blob/main/packages/utils/src/arrayUtils.ts#L274)
|
|
97
|
-
|
|
98
|
-
###### Parameters
|
|
99
|
-
|
|
100
|
-
###### getKey
|
|
101
|
-
|
|
102
|
-
(`item`) => `unknown`
|
|
103
|
-
|
|
104
|
-
###### Returns
|
|
105
|
-
|
|
106
|
-
`T`[]
|
|
107
|
-
|
|
108
|
-
##### sortBy()
|
|
109
|
-
|
|
110
|
-
```ts
|
|
111
|
-
sortBy: (sortByValue, props) => T[];
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
Defined in: [packages/utils/src/arrayUtils.ts:273](https://github.com/lucasols/utils/blob/main/packages/utils/src/arrayUtils.ts#L273)
|
|
115
|
-
|
|
116
|
-
###### Parameters
|
|
117
|
-
|
|
118
|
-
###### sortByValue
|
|
119
|
-
|
|
120
|
-
[`SortByValue`](#sortbyvalue)\<`T`\>
|
|
121
|
-
|
|
122
|
-
###### props
|
|
123
|
-
|
|
124
|
-
[`SortByProps`](#sortbyprops)
|
|
125
|
-
|
|
126
|
-
###### Returns
|
|
127
|
-
|
|
128
|
-
`T`[]
|
|
129
|
-
|
|
130
|
-
***
|
|
131
|
-
|
|
132
|
-
### SortByProps
|
|
133
|
-
|
|
134
|
-
```ts
|
|
135
|
-
type SortByProps =
|
|
136
|
-
| {
|
|
137
|
-
order?: SortOrder | SortOrder[];
|
|
138
|
-
}
|
|
139
|
-
| SortOrder
|
|
140
|
-
| SortOrder[];
|
|
141
|
-
```
|
|
142
|
-
|
|
143
|
-
Defined in: [packages/utils/src/arrayUtils.ts:48](https://github.com/lucasols/utils/blob/main/packages/utils/src/arrayUtils.ts#L48)
|
|
144
|
-
|
|
145
|
-
***
|
|
146
|
-
|
|
147
|
-
### SortByValue()\<T\>
|
|
148
|
-
|
|
149
|
-
```ts
|
|
150
|
-
type SortByValue<T> = (item) => (number | string)[] | number | string;
|
|
151
|
-
```
|
|
152
|
-
|
|
153
|
-
Defined in: [packages/utils/src/arrayUtils.ts:46](https://github.com/lucasols/utils/blob/main/packages/utils/src/arrayUtils.ts#L46)
|
|
154
|
-
|
|
155
|
-
#### Type Parameters
|
|
156
|
-
|
|
157
|
-
##### T
|
|
158
|
-
|
|
159
|
-
`T`
|
|
160
|
-
|
|
161
|
-
#### Parameters
|
|
162
|
-
|
|
163
|
-
##### item
|
|
164
|
-
|
|
165
|
-
`T`
|
|
166
|
-
|
|
167
|
-
#### Returns
|
|
168
|
-
|
|
169
|
-
(`number` \| `string`)[] \| `number` \| `string`
|
|
170
|
-
|
|
171
|
-
***
|
|
172
|
-
|
|
173
|
-
### SortOrder
|
|
174
|
-
|
|
175
|
-
```ts
|
|
176
|
-
type SortOrder = "desc" | "asc";
|
|
177
|
-
```
|
|
178
|
-
|
|
179
|
-
Defined in: [packages/utils/src/arrayUtils.ts:44](https://github.com/lucasols/utils/blob/main/packages/utils/src/arrayUtils.ts#L44)
|