@ls-stack/utils 3.63.0 → 3.66.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{arrayUtils.d.cts → arrayUtils.d.mts} +24 -23
- package/dist/arrayUtils.mjs +249 -0
- package/dist/assertions-qMxfVhSu.mjs +207 -0
- package/dist/{assertions.d.ts → assertions.d.mts} +4 -3
- package/dist/assertions.mjs +3 -0
- package/dist/asyncQueue.d.mts +497 -0
- package/dist/asyncQueue.mjs +757 -0
- package/dist/{awaitDebounce.d.cts → awaitDebounce.d.mts} +11 -6
- package/dist/awaitDebounce.mjs +54 -0
- package/dist/{cache.d.ts → cache.d.mts} +76 -68
- package/dist/cache.mjs +355 -0
- package/dist/castValues-DfICShCc.mjs +19 -0
- package/dist/{castValues.d.cts → castValues.d.mts} +3 -2
- package/dist/castValues.mjs +3 -0
- package/dist/{concurrentCalls.d.ts → concurrentCalls.d.mts} +74 -65
- package/dist/concurrentCalls.mjs +295 -0
- package/dist/consoleFmt.d.mts +55 -0
- package/dist/consoleFmt.mjs +63 -0
- package/dist/conversions-DTmwEMIu.mjs +12 -0
- package/dist/conversions.d.mts +4 -0
- package/dist/conversions.mjs +3 -0
- package/dist/createThrottleController.d.mts +18 -0
- package/dist/createThrottleController.mjs +40 -0
- package/dist/debounce.d.mts +47 -0
- package/dist/debounce.mjs +117 -0
- package/dist/dedent.d.mts +74 -0
- package/dist/dedent.mjs +80 -0
- package/dist/deepEqual-C7EZEixx.mjs +78 -0
- package/dist/{deepEqual.d.cts → deepEqual.d.mts} +3 -2
- package/dist/deepEqual.mjs +3 -0
- package/dist/{deepReplaceValues.d.cts → deepReplaceValues.d.mts} +4 -3
- package/dist/deepReplaceValues.mjs +61 -0
- package/dist/diffParser.d.mts +63 -0
- package/dist/diffParser.mjs +410 -0
- package/dist/enhancedMap.d.mts +21 -0
- package/dist/enhancedMap.mjs +69 -0
- package/dist/exhaustiveMatch.d.mts +10 -0
- package/dist/exhaustiveMatch.mjs +48 -0
- package/dist/{filterObjectOrArrayKeys.d.cts → filterObjectOrArrayKeys.d.mts} +15 -8
- package/dist/filterObjectOrArrayKeys.mjs +497 -0
- package/dist/{getAutoIncrementId.d.cts → getAutoIncrementId.d.mts} +9 -5
- package/dist/getAutoIncrementId.mjs +53 -0
- package/dist/{getCompositeKey.d.cts → getCompositeKey.d.mts} +3 -2
- package/dist/getCompositeKey.mjs +50 -0
- package/dist/{getValueStableKey.d.cts → getValueStableKey.d.mts} +5 -3
- package/dist/getValueStableKey.mjs +17 -0
- package/dist/{hash.d.cts → hash.d.mts} +3 -2
- package/dist/hash.mjs +28 -0
- package/dist/interpolate.d.mts +17 -0
- package/dist/interpolate.mjs +28 -0
- package/dist/{iteratorUtils.d.cts → iteratorUtils.d.mts} +5 -4
- package/dist/iteratorUtils.mjs +39 -0
- package/dist/keepPrevIfUnchanged.d.mts +12 -0
- package/dist/keepPrevIfUnchanged.mjs +9 -0
- package/dist/keyedMap.d.mts +76 -0
- package/dist/keyedMap.mjs +139 -0
- package/dist/keyedSet.d.mts +77 -0
- package/dist/keyedSet.mjs +129 -0
- package/dist/{levenshtein.d.cts → levenshtein.d.mts} +3 -2
- package/dist/levenshtein.mjs +121 -0
- package/dist/main.d.mts +4 -0
- package/dist/main.mjs +7 -0
- package/dist/matchPath.d.mts +50 -0
- package/dist/matchPath.mjs +81 -0
- package/dist/mathUtils-BDP1lM_z.mjs +81 -0
- package/dist/{mathUtils.d.cts → mathUtils.d.mts} +3 -2
- package/dist/mathUtils.mjs +3 -0
- package/dist/{mutationUtils.d.cts → mutationUtils.d.mts} +6 -5
- package/dist/mutationUtils.mjs +44 -0
- package/dist/{objUtils.d.ts → objUtils.d.mts} +8 -6
- package/dist/objUtils.mjs +115 -0
- package/dist/parallelAsyncCalls.d.mts +83 -0
- package/dist/parallelAsyncCalls.mjs +121 -0
- package/dist/partialEqual.d.mts +139 -0
- package/dist/partialEqual.mjs +1055 -0
- package/dist/promiseUtils.d.mts +9 -0
- package/dist/promiseUtils.mjs +17 -0
- package/dist/regexUtils.d.mts +18 -0
- package/dist/regexUtils.mjs +34 -0
- package/dist/{retryOnError.d.cts → retryOnError.d.mts} +38 -37
- package/dist/retryOnError.mjs +91 -0
- package/dist/{runShellCmd.d.ts → runShellCmd.d.mts} +24 -15
- package/dist/runShellCmd.mjs +151 -0
- package/dist/{safeJson.d.cts → safeJson.d.mts} +3 -2
- package/dist/safeJson.mjs +30 -0
- package/dist/{saferTyping.d.cts → saferTyping.d.mts} +4 -3
- package/dist/saferTyping.mjs +45 -0
- package/dist/serializeXML.d.mts +23 -0
- package/dist/serializeXML.mjs +74 -0
- package/dist/{shallowEqual.d.cts → shallowEqual.d.mts} +3 -2
- package/dist/shallowEqual.mjs +54 -0
- package/dist/sleep.d.mts +4 -0
- package/dist/sleep.mjs +7 -0
- package/dist/stringUtils-DjhWOiYn.mjs +113 -0
- package/dist/{stringUtils.d.cts → stringUtils.d.mts} +3 -2
- package/dist/stringUtils.mjs +3 -0
- package/dist/{testUtils.d.ts → testUtils.d.mts} +83 -52
- package/dist/testUtils.mjs +310 -0
- package/dist/{throttle.d.ts → throttle.d.mts} +18 -17
- package/dist/throttle.mjs +102 -0
- package/dist/time-sr2lhQRw.mjs +67 -0
- package/dist/{time.d.ts → time.d.mts} +8 -7
- package/dist/time.mjs +3 -0
- package/dist/{timers.d.cts → timers.d.mts} +22 -13
- package/dist/timers.mjs +220 -0
- package/dist/{tsResult.d.cts → tsResult.d.mts} +52 -48
- package/dist/tsResult.mjs +142 -0
- package/dist/typeGuards-B1mzA-Rz.mjs +128 -0
- package/dist/{typeGuards.d.cts → typeGuards.d.mts} +3 -2
- package/dist/typeGuards.mjs +3 -0
- package/dist/{typeUtils.d.ts → typeUtils.d.mts} +13 -34
- package/dist/typeUtils.mjs +1 -0
- package/dist/{typedStrings.d.cts → typedStrings.d.mts} +5 -4
- package/dist/typedStrings.mjs +131 -0
- package/dist/typingFnUtils-Bb8drgKF.mjs +101 -0
- package/dist/{typingFnUtils.d.cts → typingFnUtils.d.mts} +13 -22
- package/dist/typingFnUtils.mjs +3 -0
- package/dist/{typingTestUtils.d.cts → typingTestUtils.d.mts} +11 -15
- package/dist/typingTestUtils.mjs +80 -0
- package/dist/typingUtils.d.mts +20 -0
- package/dist/typingUtils.mjs +1 -0
- package/dist/yamlStringify.d.mts +17 -0
- package/dist/yamlStringify.mjs +189 -0
- package/package.json +65 -234
- 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/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/typedStrings.d.ts
DELETED
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A type representing a string that contains a specific substring. Uses
|
|
3
|
-
* template literal types to ensure type safety at compile time.
|
|
4
|
-
*
|
|
5
|
-
* @example
|
|
6
|
-
* ```ts
|
|
7
|
-
* type EmailString = StringContaining<'@'>; // string that contains '@'
|
|
8
|
-
* const email: EmailString = 'user@example.com'; // ✓ valid
|
|
9
|
-
* ```;
|
|
10
|
-
*
|
|
11
|
-
* @template T - The substring that must be contained within the string
|
|
12
|
-
*/
|
|
13
|
-
type StringContaining<T extends string> = string extends T ? never : `${string}${T}${string}`;
|
|
14
|
-
/**
|
|
15
|
-
* A type representing a string that starts with a specific substring. Uses
|
|
16
|
-
* template literal types to ensure the string begins with the specified
|
|
17
|
-
* prefix.
|
|
18
|
-
*
|
|
19
|
-
* @example
|
|
20
|
-
* ```ts
|
|
21
|
-
* type HttpUrl = StringStartingWith<'http'>; // string starting with 'http'
|
|
22
|
-
* const url: HttpUrl = 'https://example.com'; // ✓ valid
|
|
23
|
-
* ```;
|
|
24
|
-
*
|
|
25
|
-
* @template T - The substring that the string must start with
|
|
26
|
-
*/
|
|
27
|
-
type StringStartingWith<T extends string> = string extends T ? never : `${T}${string}`;
|
|
28
|
-
/**
|
|
29
|
-
* A type representing a string that ends with a specific substring. Uses
|
|
30
|
-
* template literal types to ensure the string ends with the specified suffix.
|
|
31
|
-
*
|
|
32
|
-
* @example
|
|
33
|
-
* ```ts
|
|
34
|
-
* type JavaFile = StringEndingWith<'.java'>; // string ending with '.java'
|
|
35
|
-
* const filename: JavaFile = 'HelloWorld.java'; // ✓ valid
|
|
36
|
-
* ```;
|
|
37
|
-
*
|
|
38
|
-
* @template T - The substring that the string must end with
|
|
39
|
-
*/
|
|
40
|
-
type StringEndingWith<T extends string> = string extends T ? never : `${string}${T}`;
|
|
41
|
-
/**
|
|
42
|
-
* Type guard function that checks if a string contains a specific substring.
|
|
43
|
-
* Narrows the type to `StringContaining<T>` when the check passes.
|
|
44
|
-
*
|
|
45
|
-
* @param str - The string to check
|
|
46
|
-
* @param substring - The substring to search for
|
|
47
|
-
* @returns `true` if the string contains the substring, `false` otherwise
|
|
48
|
-
*/
|
|
49
|
-
declare function stringContains<T extends string>(str: string, substring: T): str is StringContaining<T>;
|
|
50
|
-
/**
|
|
51
|
-
* Type guard function that checks if a string starts with a specific substring.
|
|
52
|
-
* Narrows the type to `StringStartingWith<T>` when the check passes.
|
|
53
|
-
*
|
|
54
|
-
* @param str - The string to check
|
|
55
|
-
* @param substring - The substring to check for at the beginning
|
|
56
|
-
* @returns `true` if the string starts with the substring, `false` otherwise
|
|
57
|
-
*/
|
|
58
|
-
declare function stringStartsWith<T extends string>(str: string, substring: T): str is StringStartingWith<T>;
|
|
59
|
-
/**
|
|
60
|
-
* Type guard function that checks if a string ends with a specific substring.
|
|
61
|
-
* Narrows the type to `StringEndingWith<T>` when the check passes.
|
|
62
|
-
*
|
|
63
|
-
* @param str - The string to check
|
|
64
|
-
* @param substring - The substring to check for at the end
|
|
65
|
-
* @returns `true` if the string ends with the substring, `false` otherwise
|
|
66
|
-
*/
|
|
67
|
-
declare function stringEndsWith<T extends string>(str: string, substring: T): str is StringEndingWith<T>;
|
|
68
|
-
/**
|
|
69
|
-
* Splits a typed string by a separator that is guaranteed to exist in the
|
|
70
|
-
* string. Returns an array with at least two elements: the parts before and
|
|
71
|
-
* after the first separator, plus any additional parts if there are multiple
|
|
72
|
-
* separators.
|
|
73
|
-
*
|
|
74
|
-
* @example
|
|
75
|
-
* ```ts
|
|
76
|
-
* const path: StringContaining<'/'> = 'src/utils/types.ts';
|
|
77
|
-
* const [first, second, ...rest] = splitTypedString(path, '/');
|
|
78
|
-
* // first: 'src', second: 'utils', rest: ['types.ts']
|
|
79
|
-
* ```;
|
|
80
|
-
*
|
|
81
|
-
* @param str - A string that contains, starts with, or ends with the separator
|
|
82
|
-
* @param separator - The separator to split by
|
|
83
|
-
* @returns An array with at least two string elements
|
|
84
|
-
*/
|
|
85
|
-
declare function splitTypedString<T extends string>(str: StringContaining<NoInfer<T>> | StringStartingWith<NoInfer<T>> | StringEndingWith<NoInfer<T>>, separator: T): [string, string, ...string[]];
|
|
86
|
-
/**
|
|
87
|
-
* Splits a typed string at a specific occurrence of the separator. Unlike
|
|
88
|
-
* `splitTypedString`, this returns exactly two parts: everything before the nth
|
|
89
|
-
* separator and everything after it.
|
|
90
|
-
*
|
|
91
|
-
* @example
|
|
92
|
-
* ```ts
|
|
93
|
-
* const path: StringContaining<'.'> = 'file.name.ext';
|
|
94
|
-
* const [name, ext] = splitTypedStringAt(path, '.', 2);
|
|
95
|
-
* // name: 'file.name', ext: 'ext'
|
|
96
|
-
* ```;
|
|
97
|
-
*
|
|
98
|
-
* @param str - A string that contains, starts with, or ends with the separator
|
|
99
|
-
* @param separator - The separator to split by
|
|
100
|
-
* @param splitAtNSeparatorPos - The position of the separator to split at
|
|
101
|
-
* (1-based)
|
|
102
|
-
* @returns A tuple with exactly two string elements
|
|
103
|
-
*/
|
|
104
|
-
declare function splitTypedStringAt<T extends string>(str: StringContaining<NoInfer<T>> | StringStartingWith<NoInfer<T>> | StringEndingWith<NoInfer<T>>, separator: T,
|
|
105
|
-
/**
|
|
106
|
-
* The position of the separator to split at.
|
|
107
|
-
*
|
|
108
|
-
* @default 1 - split at the first separator
|
|
109
|
-
*/
|
|
110
|
-
splitAtNSeparatorPos?: number): [string, string];
|
|
111
|
-
/**
|
|
112
|
-
* A branded type representing a string that is guaranteed to be non-empty
|
|
113
|
-
* (length > 0). This type provides compile-time safety by preventing empty
|
|
114
|
-
* strings from being assigned without proper validation.
|
|
115
|
-
*
|
|
116
|
-
* @example
|
|
117
|
-
* ```ts
|
|
118
|
-
* function processName(name: NonEmptyString) {
|
|
119
|
-
* // name is guaranteed to be non-empty
|
|
120
|
-
* return name.toUpperCase();
|
|
121
|
-
* }
|
|
122
|
-
* ```;
|
|
123
|
-
*/
|
|
124
|
-
type NonEmptyString = string & {
|
|
125
|
-
__nonEmptyString: true;
|
|
126
|
-
};
|
|
127
|
-
/**
|
|
128
|
-
* Type guard function that checks if a string is non-empty. Narrows the type to
|
|
129
|
-
* `NonEmptyString` when the check passes.
|
|
130
|
-
*
|
|
131
|
-
* @param str - The string to check
|
|
132
|
-
* @returns `true` if the string has length > 0, `false` otherwise
|
|
133
|
-
*/
|
|
134
|
-
declare function isNonEmptyString(str: string): str is NonEmptyString;
|
|
135
|
-
/**
|
|
136
|
-
* Converts a string to `NonEmptyString` or throws an error if the string is
|
|
137
|
-
* empty. Use this when you need to ensure a string is non-empty and want to
|
|
138
|
-
* fail fast.
|
|
139
|
-
*
|
|
140
|
-
* @param str - The string to convert
|
|
141
|
-
* @returns The string as `NonEmptyString`
|
|
142
|
-
* @throws Error if the string is empty
|
|
143
|
-
*/
|
|
144
|
-
declare function asNonEmptyStringOrThrow(str: string): NonEmptyString;
|
|
145
|
-
/**
|
|
146
|
-
* Converts a string to `NonEmptyString` or returns `null` if the string is
|
|
147
|
-
* empty. Use this when empty strings should be handled gracefully rather than
|
|
148
|
-
* throwing errors.
|
|
149
|
-
*
|
|
150
|
-
* @param str - The string to convert
|
|
151
|
-
* @returns The string as `NonEmptyString` or `null` if empty
|
|
152
|
-
*/
|
|
153
|
-
declare function asNonEmptyStringOrNull(str: string): NonEmptyString | null;
|
|
154
|
-
/**
|
|
155
|
-
* Assertion function that ensures a string is non-empty. Throws an error if the
|
|
156
|
-
* string is empty, otherwise narrows the type to `NonEmptyString`.
|
|
157
|
-
*
|
|
158
|
-
* @param str - The string to assert as non-empty
|
|
159
|
-
* @throws Error if the string is empty
|
|
160
|
-
*/
|
|
161
|
-
declare function assertStringIsNonEmpty(str: string): asserts str is NonEmptyString;
|
|
162
|
-
|
|
163
|
-
export { type NonEmptyString, type StringContaining, type StringEndingWith, type StringStartingWith, asNonEmptyStringOrNull, asNonEmptyStringOrThrow, assertStringIsNonEmpty, isNonEmptyString, splitTypedString, splitTypedStringAt, stringContains, stringEndsWith, stringStartsWith };
|
package/dist/typedStrings.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
// src/typedStrings.ts
|
|
2
|
-
function stringContains(str, substring) {
|
|
3
|
-
return str.includes(substring);
|
|
4
|
-
}
|
|
5
|
-
function stringStartsWith(str, substring) {
|
|
6
|
-
return str.startsWith(substring);
|
|
7
|
-
}
|
|
8
|
-
function stringEndsWith(str, substring) {
|
|
9
|
-
return str.endsWith(substring);
|
|
10
|
-
}
|
|
11
|
-
function splitTypedString(str, separator) {
|
|
12
|
-
return str.split(separator);
|
|
13
|
-
}
|
|
14
|
-
function splitTypedStringAt(str, separator, splitAtNSeparatorPos = 1) {
|
|
15
|
-
const parts = str.split(separator);
|
|
16
|
-
let leftPart = parts[0];
|
|
17
|
-
let rightPart = parts.slice(1).join(separator);
|
|
18
|
-
if (leftPart === void 0) {
|
|
19
|
-
throw new Error("String does not contain the separator");
|
|
20
|
-
}
|
|
21
|
-
if (splitAtNSeparatorPos > 1) {
|
|
22
|
-
leftPart = parts.slice(0, splitAtNSeparatorPos).join(separator);
|
|
23
|
-
rightPart = parts.slice(splitAtNSeparatorPos).join(separator);
|
|
24
|
-
}
|
|
25
|
-
return [leftPart, rightPart];
|
|
26
|
-
}
|
|
27
|
-
function isNonEmptyString(str) {
|
|
28
|
-
return str.length > 0;
|
|
29
|
-
}
|
|
30
|
-
function asNonEmptyStringOrThrow(str) {
|
|
31
|
-
if (isNonEmptyString(str)) {
|
|
32
|
-
return str;
|
|
33
|
-
}
|
|
34
|
-
throw new Error("String is empty");
|
|
35
|
-
}
|
|
36
|
-
function asNonEmptyStringOrNull(str) {
|
|
37
|
-
if (isNonEmptyString(str)) {
|
|
38
|
-
return str;
|
|
39
|
-
}
|
|
40
|
-
return null;
|
|
41
|
-
}
|
|
42
|
-
function assertStringIsNonEmpty(str) {
|
|
43
|
-
if (!isNonEmptyString(str)) {
|
|
44
|
-
throw new Error("String is empty");
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
export {
|
|
48
|
-
asNonEmptyStringOrNull,
|
|
49
|
-
asNonEmptyStringOrThrow,
|
|
50
|
-
assertStringIsNonEmpty,
|
|
51
|
-
isNonEmptyString,
|
|
52
|
-
splitTypedString,
|
|
53
|
-
splitTypedStringAt,
|
|
54
|
-
stringContains,
|
|
55
|
-
stringEndsWith,
|
|
56
|
-
stringStartsWith
|
|
57
|
-
};
|
package/dist/typingFnUtils.cjs
DELETED
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/typingFnUtils.ts
|
|
21
|
-
var typingFnUtils_exports = {};
|
|
22
|
-
__export(typingFnUtils_exports, {
|
|
23
|
-
asNonPartial: () => asNonPartial,
|
|
24
|
-
asPartialUndefinedValues: () => asPartialUndefinedValues,
|
|
25
|
-
asType: () => asType,
|
|
26
|
-
isNonEmptyArray: () => isNonEmptyArray,
|
|
27
|
-
isObjKey: () => isObjKey,
|
|
28
|
-
isSubTypeOf: () => isSubTypeOf,
|
|
29
|
-
narrowStringToUnion: () => narrowStringToUnion,
|
|
30
|
-
objectHasKey: () => objectHasKey,
|
|
31
|
-
strictTypedObjectEntries: () => strictTypedObjectEntries,
|
|
32
|
-
typeOnRightExtendsLeftType: () => typeOnRightExtendsLeftType,
|
|
33
|
-
typedObjectEntries: () => typedObjectEntries,
|
|
34
|
-
typedObjectKeys: () => typedObjectKeys,
|
|
35
|
-
unionsAreTheSame: () => unionsAreTheSame
|
|
36
|
-
});
|
|
37
|
-
module.exports = __toCommonJS(typingFnUtils_exports);
|
|
38
|
-
function asNonPartial(obj) {
|
|
39
|
-
return obj;
|
|
40
|
-
}
|
|
41
|
-
function typedObjectEntries(obj) {
|
|
42
|
-
return Object.entries(obj);
|
|
43
|
-
}
|
|
44
|
-
function strictTypedObjectEntries(obj) {
|
|
45
|
-
return Object.entries(obj);
|
|
46
|
-
}
|
|
47
|
-
function typedObjectKeys(obj) {
|
|
48
|
-
return Object.keys(obj);
|
|
49
|
-
}
|
|
50
|
-
function asType(value) {
|
|
51
|
-
return value;
|
|
52
|
-
}
|
|
53
|
-
function narrowStringToUnion(key, union) {
|
|
54
|
-
if (!key) return void 0;
|
|
55
|
-
if (union instanceof Set) {
|
|
56
|
-
return union.has(key) ? key : void 0;
|
|
57
|
-
}
|
|
58
|
-
if (union.includes(key)) {
|
|
59
|
-
return key;
|
|
60
|
-
}
|
|
61
|
-
return void 0;
|
|
62
|
-
}
|
|
63
|
-
function typeOnRightExtendsLeftType() {
|
|
64
|
-
return void 0;
|
|
65
|
-
}
|
|
66
|
-
var isSubTypeOf = typeOnRightExtendsLeftType;
|
|
67
|
-
function isObjKey(key, obj) {
|
|
68
|
-
return typeof key === "string" && key in obj;
|
|
69
|
-
}
|
|
70
|
-
function unionsAreTheSame(_diff) {
|
|
71
|
-
}
|
|
72
|
-
function asPartialUndefinedValues(value) {
|
|
73
|
-
return value;
|
|
74
|
-
}
|
|
75
|
-
function isNonEmptyArray(array) {
|
|
76
|
-
return array.length > 0;
|
|
77
|
-
}
|
|
78
|
-
function objectHasKey(obj, key) {
|
|
79
|
-
return key in obj;
|
|
80
|
-
}
|
|
81
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
82
|
-
0 && (module.exports = {
|
|
83
|
-
asNonPartial,
|
|
84
|
-
asPartialUndefinedValues,
|
|
85
|
-
asType,
|
|
86
|
-
isNonEmptyArray,
|
|
87
|
-
isObjKey,
|
|
88
|
-
isSubTypeOf,
|
|
89
|
-
narrowStringToUnion,
|
|
90
|
-
objectHasKey,
|
|
91
|
-
strictTypedObjectEntries,
|
|
92
|
-
typeOnRightExtendsLeftType,
|
|
93
|
-
typedObjectEntries,
|
|
94
|
-
typedObjectKeys,
|
|
95
|
-
unionsAreTheSame
|
|
96
|
-
});
|
package/dist/typingFnUtils.d.ts
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import { PartialPossiblyUndefinedValues } from './typeUtils.js';
|
|
2
|
-
import { NonPartial } from './typingUtils.js';
|
|
3
|
-
|
|
4
|
-
declare function asNonPartial<T extends Record<string, unknown>>(obj: T): NonPartial<T>;
|
|
5
|
-
/**
|
|
6
|
-
* A wrapper to Object.entries with a better typing inference
|
|
7
|
-
*
|
|
8
|
-
* @param obj
|
|
9
|
-
*/
|
|
10
|
-
declare function typedObjectEntries<T extends Record<string, unknown>>(obj: T): NonNullable<{
|
|
11
|
-
[K in keyof T]: [K, T[K]];
|
|
12
|
-
}[keyof T]>[];
|
|
13
|
-
/**
|
|
14
|
-
* A wrapper to Object.entries with a better typing inference, but with strict
|
|
15
|
-
* typing narrowing keys to strings.
|
|
16
|
-
*
|
|
17
|
-
* @param obj
|
|
18
|
-
*/
|
|
19
|
-
declare function strictTypedObjectEntries<T extends Record<string, unknown>>(obj: T): NonNullable<{
|
|
20
|
-
[K in keyof T]: [K & string, T[K]];
|
|
21
|
-
}[keyof T]>[];
|
|
22
|
-
/**
|
|
23
|
-
* A wrapper to Object.keys with a better typing inference
|
|
24
|
-
*
|
|
25
|
-
* @param obj
|
|
26
|
-
*/
|
|
27
|
-
declare function typedObjectKeys<T extends Record<string, unknown>>(obj: T): (keyof T)[];
|
|
28
|
-
/**
|
|
29
|
-
* A safe way to cast types, use to substitute the `as Type`
|
|
30
|
-
*
|
|
31
|
-
* @param value
|
|
32
|
-
*/
|
|
33
|
-
declare function asType<T = unknown>(value: T): T;
|
|
34
|
-
/**
|
|
35
|
-
* Narrow a string to a union of strings
|
|
36
|
-
*
|
|
37
|
-
* @param key
|
|
38
|
-
* @param union
|
|
39
|
-
*/
|
|
40
|
-
declare function narrowStringToUnion<const T extends string>(key: string | undefined | null, union: T[] | readonly T[] | Set<T>): T | undefined;
|
|
41
|
-
/**
|
|
42
|
-
* Type helper to check if a type is a subtype of another type.
|
|
43
|
-
*
|
|
44
|
-
* @template BaseType - The base type to check against
|
|
45
|
-
* @template SubType - The type that should extend BaseType
|
|
46
|
-
* @returns Returns undefined, only used for type checking
|
|
47
|
-
*/
|
|
48
|
-
declare function typeOnRightExtendsLeftType<BaseType, SubType extends BaseType>(): unknown;
|
|
49
|
-
/** @deprecated Use typeOnRightExtendsLeftType instead */
|
|
50
|
-
declare const isSubTypeOf: typeof typeOnRightExtendsLeftType;
|
|
51
|
-
/**
|
|
52
|
-
* Type helper to narrow a string to a key of an object.
|
|
53
|
-
*
|
|
54
|
-
* @param key
|
|
55
|
-
* @param obj
|
|
56
|
-
*/
|
|
57
|
-
declare function isObjKey<T extends Record<string, unknown>>(key: unknown, obj: T): key is keyof T;
|
|
58
|
-
type UnionDiff<T, U> = [
|
|
59
|
-
T
|
|
60
|
-
] extends [U] ? [
|
|
61
|
-
U
|
|
62
|
-
] extends [T] ? null : {
|
|
63
|
-
onRightHasExtraErr: Exclude<U, T>;
|
|
64
|
-
} : [U] extends [T] ? {
|
|
65
|
-
onRightHasMissingErr: Exclude<T, U>;
|
|
66
|
-
} : {
|
|
67
|
-
onRightHasExtraErr: Exclude<U, T>;
|
|
68
|
-
onRightHasMissingErr: Exclude<T, U>;
|
|
69
|
-
};
|
|
70
|
-
/**
|
|
71
|
-
* Type helper to compare two union types and determine their relationship.
|
|
72
|
-
*
|
|
73
|
-
* @template T - The first union type (left side)
|
|
74
|
-
* @template U - The second union type (right side)
|
|
75
|
-
* @param _diff - Null if unions are identical, or an object describing the
|
|
76
|
-
* errors
|
|
77
|
-
*/
|
|
78
|
-
declare function unionsAreTheSame<T, U>(_diff: UnionDiff<T, U>): void;
|
|
79
|
-
declare function asPartialUndefinedValues<T extends Record<string, unknown>>(value: PartialPossiblyUndefinedValues<T>): T;
|
|
80
|
-
/** A type representing an array that is guaranteed to have at least one element. */
|
|
81
|
-
type NonEmptyArray<T> = [T, ...T[]];
|
|
82
|
-
/**
|
|
83
|
-
* Type guard to check if an array has at least one element.
|
|
84
|
-
*
|
|
85
|
-
* @param array - The array to check
|
|
86
|
-
* @returns True if the array is non-empty, false otherwise
|
|
87
|
-
*/
|
|
88
|
-
declare function isNonEmptyArray<T>(array: T[]): array is NonEmptyArray<T>;
|
|
89
|
-
/**
|
|
90
|
-
* Type guard to check if an object has a specific key and narrow its type.
|
|
91
|
-
*
|
|
92
|
-
* @param obj - The object to check
|
|
93
|
-
* @param key - The key to check for
|
|
94
|
-
* @returns True if the object has the key, false otherwise
|
|
95
|
-
*/
|
|
96
|
-
declare function objectHasKey<T extends string>(obj: object, key: T): obj is object & {
|
|
97
|
-
[K in T]: unknown;
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
export { type NonEmptyArray, asNonPartial, asPartialUndefinedValues, asType, isNonEmptyArray, isObjKey, isSubTypeOf, narrowStringToUnion, objectHasKey, strictTypedObjectEntries, typeOnRightExtendsLeftType, typedObjectEntries, typedObjectKeys, unionsAreTheSame };
|
package/dist/typingFnUtils.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
asNonPartial,
|
|
3
|
-
asPartialUndefinedValues,
|
|
4
|
-
asType,
|
|
5
|
-
isNonEmptyArray,
|
|
6
|
-
isObjKey,
|
|
7
|
-
isSubTypeOf,
|
|
8
|
-
narrowStringToUnion,
|
|
9
|
-
objectHasKey,
|
|
10
|
-
strictTypedObjectEntries,
|
|
11
|
-
typeOnRightExtendsLeftType,
|
|
12
|
-
typedObjectEntries,
|
|
13
|
-
typedObjectKeys,
|
|
14
|
-
unionsAreTheSame
|
|
15
|
-
} from "./chunk-GMJTLFM6.js";
|
|
16
|
-
export {
|
|
17
|
-
asNonPartial,
|
|
18
|
-
asPartialUndefinedValues,
|
|
19
|
-
asType,
|
|
20
|
-
isNonEmptyArray,
|
|
21
|
-
isObjKey,
|
|
22
|
-
isSubTypeOf,
|
|
23
|
-
narrowStringToUnion,
|
|
24
|
-
objectHasKey,
|
|
25
|
-
strictTypedObjectEntries,
|
|
26
|
-
typeOnRightExtendsLeftType,
|
|
27
|
-
typedObjectEntries,
|
|
28
|
-
typedObjectKeys,
|
|
29
|
-
unionsAreTheSame
|
|
30
|
-
};
|
package/dist/typingTestUtils.cjs
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/typingTestUtils.ts
|
|
21
|
-
var typingTestUtils_exports = {};
|
|
22
|
-
__export(typingTestUtils_exports, {
|
|
23
|
-
typingTest: () => typingTest
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(typingTestUtils_exports);
|
|
26
|
-
function test(title, func) {
|
|
27
|
-
func();
|
|
28
|
-
}
|
|
29
|
-
function describe(title, func) {
|
|
30
|
-
func();
|
|
31
|
-
}
|
|
32
|
-
function expectType() {
|
|
33
|
-
return {};
|
|
34
|
-
}
|
|
35
|
-
function expectTypesAre(result) {
|
|
36
|
-
}
|
|
37
|
-
function expectTypesAreEqual(...result) {
|
|
38
|
-
}
|
|
39
|
-
function expectTypesAreNotEqual(...result) {
|
|
40
|
-
}
|
|
41
|
-
var typingTest = {
|
|
42
|
-
test,
|
|
43
|
-
describe,
|
|
44
|
-
expectType,
|
|
45
|
-
expectTypesAre,
|
|
46
|
-
expectTypesAreEqual,
|
|
47
|
-
expectTypesAreNotEqual
|
|
48
|
-
};
|
|
49
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
50
|
-
0 && (module.exports = {
|
|
51
|
-
typingTest
|
|
52
|
-
});
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
type TestTypeIsEqual<X, Y> = (<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2 ? true : false;
|
|
2
|
-
type TestTypeNotEqual<X, Y> = true extends TestTypeIsEqual<X, Y> ? false : true;
|
|
3
|
-
declare function test(title: string, func: () => any): void;
|
|
4
|
-
declare function describe(title: string, func: () => any): void;
|
|
5
|
-
/**
|
|
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
|
-
*
|
|
9
|
-
* @deprecated Use {@link expectTypesAreEqual} or {@link expectTypesAreNotEqual}
|
|
10
|
-
* instead
|
|
11
|
-
* @example
|
|
12
|
-
* expectType<TestTypeIsEqual<string, string>>(); // OK
|
|
13
|
-
* expectType<TestTypeIsEqual<string, number>>(); // Type error
|
|
14
|
-
*
|
|
15
|
-
* @template T Type that must extend `true`
|
|
16
|
-
* @returns An empty object cast to type T
|
|
17
|
-
*/
|
|
18
|
-
declare function expectType<T extends true>(): T;
|
|
19
|
-
/**
|
|
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
|
|
45
|
-
*
|
|
46
|
-
* @template X First type to compare
|
|
47
|
-
* @template Y Second type to compare
|
|
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.
|
|
60
|
-
*
|
|
61
|
-
* @example
|
|
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
|
|
68
|
-
*/
|
|
69
|
-
declare function expectTypesAreNotEqual<X, Y>(...result: TestTypeIsEqual<X, Y> extends false ? [] : ['error: type assertion failed, types should be NOT equal']): void;
|
|
70
|
-
declare const typingTest: {
|
|
71
|
-
test: typeof test;
|
|
72
|
-
describe: typeof describe;
|
|
73
|
-
expectType: typeof expectType;
|
|
74
|
-
expectTypesAre: typeof expectTypesAre;
|
|
75
|
-
expectTypesAreEqual: typeof expectTypesAreEqual;
|
|
76
|
-
expectTypesAreNotEqual: typeof expectTypesAreNotEqual;
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
export { type TestTypeIsEqual, type TestTypeNotEqual, typingTest };
|
package/dist/typingTestUtils.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
// src/typingTestUtils.ts
|
|
2
|
-
function test(title, func) {
|
|
3
|
-
func();
|
|
4
|
-
}
|
|
5
|
-
function describe(title, func) {
|
|
6
|
-
func();
|
|
7
|
-
}
|
|
8
|
-
function expectType() {
|
|
9
|
-
return {};
|
|
10
|
-
}
|
|
11
|
-
function expectTypesAre(result) {
|
|
12
|
-
}
|
|
13
|
-
function expectTypesAreEqual(...result) {
|
|
14
|
-
}
|
|
15
|
-
function expectTypesAreNotEqual(...result) {
|
|
16
|
-
}
|
|
17
|
-
var typingTest = {
|
|
18
|
-
test,
|
|
19
|
-
describe,
|
|
20
|
-
expectType,
|
|
21
|
-
expectTypesAre,
|
|
22
|
-
expectTypesAreEqual,
|
|
23
|
-
expectTypesAreNotEqual
|
|
24
|
-
};
|
|
25
|
-
export {
|
|
26
|
-
typingTest
|
|
27
|
-
};
|
package/dist/typingUtils.cjs
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __copyProps = (to, from, except, desc) => {
|
|
7
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
-
for (let key of __getOwnPropNames(from))
|
|
9
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
-
}
|
|
12
|
-
return to;
|
|
13
|
-
};
|
|
14
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
-
|
|
16
|
-
// src/typingUtils.ts
|
|
17
|
-
var typingUtils_exports = {};
|
|
18
|
-
module.exports = __toCommonJS(typingUtils_exports);
|
package/dist/typingUtils.d.cts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/** @deprecated Use `PartialRecord` from `@ls-stack/utils/typeUtils` instead */
|
|
2
|
-
type PartialRecord<K extends keyof any, T> = {
|
|
3
|
-
[P in K]?: T;
|
|
4
|
-
};
|
|
5
|
-
/** @deprecated Use `NonPartial` from `@ls-stack/utils/typeUtils` instead */
|
|
6
|
-
type NonPartial<T> = {
|
|
7
|
-
[K in keyof Required<T>]: T[K];
|
|
8
|
-
};
|
|
9
|
-
/**
|
|
10
|
-
* @deprecated Use `ObjKeysWithValuesOfType` from `@ls-stack/utils/typeUtils`
|
|
11
|
-
* instead
|
|
12
|
-
*/
|
|
13
|
-
type ObjKeysWithValuesOfType<Obj extends Record<PropertyKey, unknown>, ValueType> = {
|
|
14
|
-
[K in keyof Obj]: Obj[K] extends ValueType ? K : never;
|
|
15
|
-
}[keyof Obj];
|
|
16
|
-
/** @deprecated Use `IsAny` from `@ls-stack/utils/typeUtils` instead */
|
|
17
|
-
type IsAny<T> = unknown extends T ? [
|
|
18
|
-
keyof T
|
|
19
|
-
] extends [never] ? false : true : false;
|
|
20
|
-
/** @deprecated Use `DeepPrettify` from `@ls-stack/utils/typeUtils` instead */
|
|
21
|
-
type Prettify<T extends Record<string, unknown>> = {
|
|
22
|
-
[P in keyof T]: T[P];
|
|
23
|
-
} & {};
|
|
24
|
-
/** @deprecated Use `DeepPrettify` from `@ls-stack/utils/typeUtils` instead */
|
|
25
|
-
type DeepPrettify<T> = {
|
|
26
|
-
[K in keyof T]: T[K] extends Record<string, unknown> ? DeepPrettify<T[K]> : T[K];
|
|
27
|
-
} & {};
|
|
28
|
-
type AddPrefixToObjKeys<T extends Record<string, unknown>, Prefix extends string> = {
|
|
29
|
-
[K in keyof T & string as `${Prefix}${K}`]: T[K];
|
|
30
|
-
};
|
|
31
|
-
type AddSuffixToObjKeys<T extends Record<string, unknown>, Suffix extends string> = {
|
|
32
|
-
[K in keyof T & string as `${K}${Suffix}`]: T[K];
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
export type { AddPrefixToObjKeys, AddSuffixToObjKeys, DeepPrettify, IsAny, NonPartial, ObjKeysWithValuesOfType, PartialRecord, Prettify };
|