@ls-stack/utils 3.17.1 → 3.19.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/README.md +1 -15
- package/docs/README.md +72 -0
- package/docs/_media/modules.md +52 -0
- package/docs/arrayUtils/-internal-.md +17 -0
- package/docs/arrayUtils/README.md +423 -0
- package/docs/assertions/-internal-.md +63 -0
- package/docs/assertions/README.md +565 -0
- package/docs/asyncQueue/-internal-.md +815 -0
- package/docs/asyncQueue/README.md +75 -0
- package/docs/awaitDebounce.md +66 -0
- package/docs/cache/-internal-.md +168 -0
- package/docs/cache/README.md +360 -0
- package/docs/castValues.md +47 -0
- package/docs/concurrentCalls/-internal-.md +416 -0
- package/docs/concurrentCalls/README.md +77 -0
- package/docs/consoleFmt.md +91 -0
- package/docs/conversions.md +27 -0
- package/docs/createThrottleController/-internal-.md +73 -0
- package/docs/createThrottleController/README.md +31 -0
- package/docs/debounce.md +188 -0
- package/docs/dedent.md +117 -0
- package/docs/deepEqual.md +94 -0
- package/docs/enhancedMap.md +358 -0
- package/docs/exhaustiveMatch/-internal-.md +39 -0
- package/docs/exhaustiveMatch/README.md +146 -0
- package/docs/getAutoIncrementId.md +93 -0
- package/docs/getCompositeKey.md +39 -0
- package/docs/getValueStableKey.md +57 -0
- package/docs/hash.md +31 -0
- package/docs/interpolate/-internal-.md +61 -0
- package/docs/interpolate/README.md +62 -0
- package/docs/levenshtein.md +93 -0
- package/docs/main.md +21 -0
- package/docs/mathUtils.md +137 -0
- package/docs/modules.md +52 -0
- package/docs/objUtils.md +237 -0
- package/docs/parallelAsyncCalls/-internal-.md +347 -0
- package/docs/parallelAsyncCalls/README.md +45 -0
- package/docs/promiseUtils/-internal-.md +69 -0
- package/docs/promiseUtils/README.md +31 -0
- package/docs/retryOnError.md +67 -0
- package/docs/runShellCmd/-internal-.md +111 -0
- package/docs/runShellCmd/README.md +201 -0
- package/docs/safeJson.md +51 -0
- package/docs/saferTyping.md +228 -0
- package/docs/serializeXML.md +100 -0
- package/docs/shallowEqual.md +33 -0
- package/docs/sleep.md +27 -0
- package/docs/stringUtils/-internal-.md +17 -0
- package/docs/stringUtils/README.md +166 -0
- package/docs/testUtils.md +315 -0
- package/docs/throttle/-internal-.md +47 -0
- package/docs/throttle/README.md +178 -0
- package/docs/time.md +274 -0
- package/docs/timers.md +256 -0
- package/docs/tsResult/-internal-.md +327 -0
- package/docs/tsResult/README.md +696 -0
- package/docs/typeGuards.md +399 -0
- package/docs/typingFnUtils/-internal-.md +27 -0
- package/docs/typingFnUtils/README.md +293 -0
- package/docs/typingTestUtils.md +172 -0
- package/docs/typingUtils.md +111 -0
- package/docs/yamlStringify.md +45 -0
- package/lib/arrayUtils.js +3 -3
- package/lib/assertions.js +2 -2
- package/lib/awaitDebounce.cjs +106 -0
- package/lib/awaitDebounce.d.cts +38 -0
- package/lib/awaitDebounce.d.ts +38 -0
- package/lib/awaitDebounce.js +28 -0
- package/lib/cache.js +2 -2
- package/lib/{chunk-NH2LCAQS.js → chunk-6FIBVC2P.js} +1 -1
- package/lib/{chunk-GKOTKAIV.js → chunk-7CQPOM5I.js} +1 -1
- package/lib/{chunk-WS4WEVHU.js → chunk-C2SVCIWE.js} +1 -1
- package/lib/{chunk-SSKW673U.js → chunk-JF2MDHOJ.js} +5 -1
- package/lib/chunk-NW5H5EW7.js +100 -0
- package/lib/{chunk-DMW5Q4T2.js → chunk-SRVMMYSW.js} +1 -1
- package/lib/concurrentCalls.js +3 -3
- package/lib/createThrottleController.js +3 -3
- package/lib/debounce.js +4 -95
- package/lib/enhancedMap.js +3 -3
- package/lib/getAutoIncrementId.cjs +44 -0
- package/lib/getAutoIncrementId.d.cts +44 -0
- package/lib/getAutoIncrementId.d.ts +44 -0
- package/lib/getAutoIncrementId.js +18 -0
- package/lib/getCompositeKey.js +3 -3
- package/lib/getValueStableKey.js +3 -3
- package/lib/interpolate.js +2 -2
- package/lib/parallelAsyncCalls.js +2 -2
- package/lib/runShellCmd.d.cts +50 -0
- package/lib/runShellCmd.d.ts +50 -0
- package/lib/serializeXML.cjs +7 -2
- package/lib/serializeXML.d.cts +1 -1
- package/lib/serializeXML.d.ts +1 -1
- package/lib/serializeXML.js +7 -5
- package/lib/testUtils.js +3 -3
- package/lib/throttle.cjs +250 -0
- package/lib/throttle.d.cts +89 -0
- package/lib/throttle.d.ts +89 -0
- package/lib/throttle.js +38 -0
- package/lib/timers.cjs +93 -0
- package/lib/timers.d.cts +110 -0
- package/lib/timers.d.ts +110 -0
- package/lib/timers.js +65 -0
- package/lib/tsResult.js +2 -2
- package/lib/typeGuards.cjs +7 -2
- package/lib/typeGuards.d.cts +2 -1
- package/lib/typeGuards.d.ts +2 -1
- package/lib/typeGuards.js +5 -3
- package/lib/typingFnUtils.cjs +5 -1
- package/lib/typingFnUtils.d.cts +1 -1
- package/lib/typingFnUtils.d.ts +1 -1
- package/lib/typingFnUtils.js +5 -1
- package/lib/yamlStringify.js +5 -5
- package/package.json +26 -12
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
[**@ls-stack/utils**](../README.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
[@ls-stack/utils](../modules.md) / runShellCmd
|
|
6
|
+
|
|
7
|
+
# runShellCmd
|
|
8
|
+
|
|
9
|
+
## Modules
|
|
10
|
+
|
|
11
|
+
- [\<internal\>](-internal-.md)
|
|
12
|
+
|
|
13
|
+
## Functions
|
|
14
|
+
|
|
15
|
+
### ~~concurrentCmd()~~
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
function concurrentCmd(
|
|
19
|
+
label,
|
|
20
|
+
cmd,
|
|
21
|
+
onResult): Promise<() => void>;
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Defined in: [packages/utils/src/runShellCmd.ts:122](https://github.com/lucasols/utils/blob/main/packages/utils/src/runShellCmd.ts#L122)
|
|
25
|
+
|
|
26
|
+
#### Parameters
|
|
27
|
+
|
|
28
|
+
##### label
|
|
29
|
+
|
|
30
|
+
`string`
|
|
31
|
+
|
|
32
|
+
##### cmd
|
|
33
|
+
|
|
34
|
+
`string` | `string`[]
|
|
35
|
+
|
|
36
|
+
##### onResult
|
|
37
|
+
|
|
38
|
+
(`result`) => `void`
|
|
39
|
+
|
|
40
|
+
#### Returns
|
|
41
|
+
|
|
42
|
+
`Promise`\<() => `void`\>
|
|
43
|
+
|
|
44
|
+
#### Deprecated
|
|
45
|
+
|
|
46
|
+
This utility has been moved to @ls-stack/node-utils. Please update your imports:
|
|
47
|
+
```
|
|
48
|
+
// Old (deprecated)
|
|
49
|
+
import { concurrentCmd } from '@ls-stack/utils/runShellCmd';
|
|
50
|
+
|
|
51
|
+
// New (preferred)
|
|
52
|
+
import { concurrentCmd } from '@ls-stack/node-utils/runShellCmd';
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
***
|
|
56
|
+
|
|
57
|
+
### ~~runCmd()~~
|
|
58
|
+
|
|
59
|
+
```ts
|
|
60
|
+
function runCmd(
|
|
61
|
+
label,
|
|
62
|
+
command,
|
|
63
|
+
__namedParameters): Promise<CmdResult>;
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Defined in: [packages/utils/src/runShellCmd.ts:31](https://github.com/lucasols/utils/blob/main/packages/utils/src/runShellCmd.ts#L31)
|
|
67
|
+
|
|
68
|
+
#### Parameters
|
|
69
|
+
|
|
70
|
+
##### label
|
|
71
|
+
|
|
72
|
+
`null` | `string`
|
|
73
|
+
|
|
74
|
+
##### command
|
|
75
|
+
|
|
76
|
+
`string` | `string`[]
|
|
77
|
+
|
|
78
|
+
##### \_\_namedParameters
|
|
79
|
+
|
|
80
|
+
[`RunCmdOptions`](-internal-.md#runcmdoptions) = `{}`
|
|
81
|
+
|
|
82
|
+
#### Returns
|
|
83
|
+
|
|
84
|
+
`Promise`\<[`CmdResult`](-internal-.md#cmdresult)\>
|
|
85
|
+
|
|
86
|
+
#### Deprecated
|
|
87
|
+
|
|
88
|
+
This utility has been moved to @ls-stack/node-utils. Please update your imports:
|
|
89
|
+
```
|
|
90
|
+
// Old (deprecated)
|
|
91
|
+
import { runCmd } from '@ls-stack/utils/runShellCmd';
|
|
92
|
+
|
|
93
|
+
// New (preferred)
|
|
94
|
+
import { runCmd } from '@ls-stack/node-utils/runShellCmd';
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
***
|
|
98
|
+
|
|
99
|
+
### ~~runCmdSilent()~~
|
|
100
|
+
|
|
101
|
+
```ts
|
|
102
|
+
function runCmdSilent(command): Promise<CmdResult>;
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Defined in: [packages/utils/src/runShellCmd.ts:182](https://github.com/lucasols/utils/blob/main/packages/utils/src/runShellCmd.ts#L182)
|
|
106
|
+
|
|
107
|
+
#### Parameters
|
|
108
|
+
|
|
109
|
+
##### command
|
|
110
|
+
|
|
111
|
+
`string` | `string`[]
|
|
112
|
+
|
|
113
|
+
#### Returns
|
|
114
|
+
|
|
115
|
+
`Promise`\<[`CmdResult`](-internal-.md#cmdresult)\>
|
|
116
|
+
|
|
117
|
+
#### Deprecated
|
|
118
|
+
|
|
119
|
+
This utility has been moved to @ls-stack/node-utils. Please update your imports:
|
|
120
|
+
```
|
|
121
|
+
// Old (deprecated)
|
|
122
|
+
import { runCmdSilent } from '@ls-stack/utils/runShellCmd';
|
|
123
|
+
|
|
124
|
+
// New (preferred)
|
|
125
|
+
import { runCmdSilent } from '@ls-stack/node-utils/runShellCmd';
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
***
|
|
129
|
+
|
|
130
|
+
### ~~runCmdSilentUnwrap()~~
|
|
131
|
+
|
|
132
|
+
```ts
|
|
133
|
+
function runCmdSilentUnwrap(command): Promise<string>;
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
Defined in: [packages/utils/src/runShellCmd.ts:196](https://github.com/lucasols/utils/blob/main/packages/utils/src/runShellCmd.ts#L196)
|
|
137
|
+
|
|
138
|
+
#### Parameters
|
|
139
|
+
|
|
140
|
+
##### command
|
|
141
|
+
|
|
142
|
+
`string` | `string`[]
|
|
143
|
+
|
|
144
|
+
#### Returns
|
|
145
|
+
|
|
146
|
+
`Promise`\<`string`\>
|
|
147
|
+
|
|
148
|
+
#### Deprecated
|
|
149
|
+
|
|
150
|
+
This utility has been moved to @ls-stack/node-utils. Please update your imports:
|
|
151
|
+
```
|
|
152
|
+
// Old (deprecated)
|
|
153
|
+
import { runCmdSilentUnwrap } from '@ls-stack/utils/runShellCmd';
|
|
154
|
+
|
|
155
|
+
// New (preferred)
|
|
156
|
+
import { runCmdSilentUnwrap } from '@ls-stack/node-utils/runShellCmd';
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
***
|
|
160
|
+
|
|
161
|
+
### ~~runCmdUnwrap()~~
|
|
162
|
+
|
|
163
|
+
```ts
|
|
164
|
+
function runCmdUnwrap(
|
|
165
|
+
label,
|
|
166
|
+
command,
|
|
167
|
+
__namedParameters): Promise<string>;
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
Defined in: [packages/utils/src/runShellCmd.ts:160](https://github.com/lucasols/utils/blob/main/packages/utils/src/runShellCmd.ts#L160)
|
|
171
|
+
|
|
172
|
+
#### Parameters
|
|
173
|
+
|
|
174
|
+
##### label
|
|
175
|
+
|
|
176
|
+
`null` | `string`
|
|
177
|
+
|
|
178
|
+
##### command
|
|
179
|
+
|
|
180
|
+
`string` | `string`[]
|
|
181
|
+
|
|
182
|
+
##### \_\_namedParameters
|
|
183
|
+
|
|
184
|
+
###### silent?
|
|
185
|
+
|
|
186
|
+
`boolean` \| `"timeOnly"`
|
|
187
|
+
|
|
188
|
+
#### Returns
|
|
189
|
+
|
|
190
|
+
`Promise`\<`string`\>
|
|
191
|
+
|
|
192
|
+
#### Deprecated
|
|
193
|
+
|
|
194
|
+
This utility has been moved to @ls-stack/node-utils. Please update your imports:
|
|
195
|
+
```
|
|
196
|
+
// Old (deprecated)
|
|
197
|
+
import { runCmdUnwrap } from '@ls-stack/utils/runShellCmd';
|
|
198
|
+
|
|
199
|
+
// New (preferred)
|
|
200
|
+
import { runCmdUnwrap } from '@ls-stack/node-utils/runShellCmd';
|
|
201
|
+
```
|
package/docs/safeJson.md
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
[**@ls-stack/utils**](README.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
[@ls-stack/utils](modules.md) / safeJson
|
|
6
|
+
|
|
7
|
+
# safeJson
|
|
8
|
+
|
|
9
|
+
## Functions
|
|
10
|
+
|
|
11
|
+
### safeJsonParse()
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
function safeJsonParse(value): unknown;
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Defined in: [packages/utils/src/safeJson.ts:11](https://github.com/lucasols/utils/blob/main/packages/utils/src/safeJson.ts#L11)
|
|
18
|
+
|
|
19
|
+
JSON.parse can throw if the value is not valid JSON, this function catches those errors and returns undefined
|
|
20
|
+
|
|
21
|
+
#### Parameters
|
|
22
|
+
|
|
23
|
+
##### value
|
|
24
|
+
|
|
25
|
+
`string`
|
|
26
|
+
|
|
27
|
+
#### Returns
|
|
28
|
+
|
|
29
|
+
`unknown`
|
|
30
|
+
|
|
31
|
+
***
|
|
32
|
+
|
|
33
|
+
### safeJsonStringify()
|
|
34
|
+
|
|
35
|
+
```ts
|
|
36
|
+
function safeJsonStringify(value): undefined | string;
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Defined in: [packages/utils/src/safeJson.ts:2](https://github.com/lucasols/utils/blob/main/packages/utils/src/safeJson.ts#L2)
|
|
40
|
+
|
|
41
|
+
JSON.stringify can throw if the value is circular or contains functions, this function catches those errors and returns undefined
|
|
42
|
+
|
|
43
|
+
#### Parameters
|
|
44
|
+
|
|
45
|
+
##### value
|
|
46
|
+
|
|
47
|
+
`unknown`
|
|
48
|
+
|
|
49
|
+
#### Returns
|
|
50
|
+
|
|
51
|
+
`undefined` \| `string`
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
[**@ls-stack/utils**](README.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
[@ls-stack/utils](modules.md) / saferTyping
|
|
6
|
+
|
|
7
|
+
# saferTyping
|
|
8
|
+
|
|
9
|
+
## Type Aliases
|
|
10
|
+
|
|
11
|
+
### \_\_FIX\_THIS\_TYPING\_\_
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
type __FIX_THIS_TYPING__ = any;
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Defined in: [packages/utils/src/saferTyping.ts:48](https://github.com/lucasols/utils/blob/main/packages/utils/src/saferTyping.ts#L48)
|
|
18
|
+
|
|
19
|
+
***
|
|
20
|
+
|
|
21
|
+
### \_\_LEGIT\_ANY\_\_
|
|
22
|
+
|
|
23
|
+
```ts
|
|
24
|
+
type __LEGIT_ANY__ = any;
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Defined in: [packages/utils/src/saferTyping.ts:4](https://github.com/lucasols/utils/blob/main/packages/utils/src/saferTyping.ts#L4)
|
|
28
|
+
|
|
29
|
+
Use this only when you have 100% of certainty that this will not break the types
|
|
30
|
+
|
|
31
|
+
***
|
|
32
|
+
|
|
33
|
+
### \_\_LEGIT\_ANY\_FUNCTION\_\_()
|
|
34
|
+
|
|
35
|
+
```ts
|
|
36
|
+
type __LEGIT_ANY_FUNCTION__ = (...params) => __LEGIT_ANY__;
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Defined in: [packages/utils/src/saferTyping.ts:8](https://github.com/lucasols/utils/blob/main/packages/utils/src/saferTyping.ts#L8)
|
|
40
|
+
|
|
41
|
+
#### Parameters
|
|
42
|
+
|
|
43
|
+
##### params
|
|
44
|
+
|
|
45
|
+
...`any`
|
|
46
|
+
|
|
47
|
+
#### Returns
|
|
48
|
+
|
|
49
|
+
[`__LEGIT_ANY__`](#__legit_any__)
|
|
50
|
+
|
|
51
|
+
***
|
|
52
|
+
|
|
53
|
+
### AnyNonPrimitiveValue
|
|
54
|
+
|
|
55
|
+
```ts
|
|
56
|
+
type AnyNonPrimitiveValue = object;
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Defined in: [packages/utils/src/saferTyping.ts:56](https://github.com/lucasols/utils/blob/main/packages/utils/src/saferTyping.ts#L56)
|
|
60
|
+
|
|
61
|
+
Any type that is not a primitive (number, string, boolean, null, undefined, symbol, bigint, ...)
|
|
62
|
+
Equivalent to `object` type
|
|
63
|
+
|
|
64
|
+
***
|
|
65
|
+
|
|
66
|
+
### EmptyObject
|
|
67
|
+
|
|
68
|
+
```ts
|
|
69
|
+
type EmptyObject = Record<string, never>;
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Defined in: [packages/utils/src/saferTyping.ts:13](https://github.com/lucasols/utils/blob/main/packages/utils/src/saferTyping.ts#L13)
|
|
73
|
+
|
|
74
|
+
An empty object type, equivalent to `{}` but with safer typing
|
|
75
|
+
|
|
76
|
+
## Functions
|
|
77
|
+
|
|
78
|
+
### \_\_FIX\_THIS\_CASTING\_\_()
|
|
79
|
+
|
|
80
|
+
```ts
|
|
81
|
+
function __FIX_THIS_CASTING__<T>(value): T;
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Defined in: [packages/utils/src/saferTyping.ts:44](https://github.com/lucasols/utils/blob/main/packages/utils/src/saferTyping.ts#L44)
|
|
85
|
+
|
|
86
|
+
#### Type Parameters
|
|
87
|
+
|
|
88
|
+
##### T
|
|
89
|
+
|
|
90
|
+
`T`
|
|
91
|
+
|
|
92
|
+
#### Parameters
|
|
93
|
+
|
|
94
|
+
##### value
|
|
95
|
+
|
|
96
|
+
`unknown`
|
|
97
|
+
|
|
98
|
+
#### Returns
|
|
99
|
+
|
|
100
|
+
`T`
|
|
101
|
+
|
|
102
|
+
***
|
|
103
|
+
|
|
104
|
+
### \_\_FIX\_THIS\_TYPING\_\_()
|
|
105
|
+
|
|
106
|
+
```ts
|
|
107
|
+
function __FIX_THIS_TYPING__(value): any;
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Defined in: [packages/utils/src/saferTyping.ts:48](https://github.com/lucasols/utils/blob/main/packages/utils/src/saferTyping.ts#L48)
|
|
111
|
+
|
|
112
|
+
#### Parameters
|
|
113
|
+
|
|
114
|
+
##### value
|
|
115
|
+
|
|
116
|
+
`unknown`
|
|
117
|
+
|
|
118
|
+
#### Returns
|
|
119
|
+
|
|
120
|
+
`any`
|
|
121
|
+
|
|
122
|
+
***
|
|
123
|
+
|
|
124
|
+
### \_\_LEGIT\_ANY\_CAST\_\_()
|
|
125
|
+
|
|
126
|
+
```ts
|
|
127
|
+
function __LEGIT_ANY_CAST__<V>(value): any;
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
Defined in: [packages/utils/src/saferTyping.ts:20](https://github.com/lucasols/utils/blob/main/packages/utils/src/saferTyping.ts#L20)
|
|
131
|
+
|
|
132
|
+
Cast a value to `any` type. Use this when you have legit usage of `any` casting.
|
|
133
|
+
|
|
134
|
+
#### Type Parameters
|
|
135
|
+
|
|
136
|
+
##### V
|
|
137
|
+
|
|
138
|
+
`V` = `unknown`
|
|
139
|
+
|
|
140
|
+
(optional) - When used enforces that the casted value is assignable to the type V, use it for safer casts
|
|
141
|
+
|
|
142
|
+
#### Parameters
|
|
143
|
+
|
|
144
|
+
##### value
|
|
145
|
+
|
|
146
|
+
`V`
|
|
147
|
+
|
|
148
|
+
#### Returns
|
|
149
|
+
|
|
150
|
+
`any`
|
|
151
|
+
|
|
152
|
+
***
|
|
153
|
+
|
|
154
|
+
### \_\_LEGIT\_CAST\_\_()
|
|
155
|
+
|
|
156
|
+
```ts
|
|
157
|
+
function __LEGIT_CAST__<T, V>(value): T;
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
Defined in: [packages/utils/src/saferTyping.ts:30](https://github.com/lucasols/utils/blob/main/packages/utils/src/saferTyping.ts#L30)
|
|
161
|
+
|
|
162
|
+
Cast a value to a specific type T. Use this when you have legit usage of type assertion.
|
|
163
|
+
|
|
164
|
+
#### Type Parameters
|
|
165
|
+
|
|
166
|
+
##### T
|
|
167
|
+
|
|
168
|
+
`T`
|
|
169
|
+
|
|
170
|
+
The type to cast to
|
|
171
|
+
|
|
172
|
+
##### V
|
|
173
|
+
|
|
174
|
+
`V` = `unknown`
|
|
175
|
+
|
|
176
|
+
(optional) - When used enforces that the casted value is assignable to the type V, use it for safer casts
|
|
177
|
+
|
|
178
|
+
#### Parameters
|
|
179
|
+
|
|
180
|
+
##### value
|
|
181
|
+
|
|
182
|
+
`V`
|
|
183
|
+
|
|
184
|
+
#### Returns
|
|
185
|
+
|
|
186
|
+
`T`
|
|
187
|
+
|
|
188
|
+
***
|
|
189
|
+
|
|
190
|
+
### \_\_REFINE\_CAST\_\_()
|
|
191
|
+
|
|
192
|
+
```ts
|
|
193
|
+
function __REFINE_CAST__<T>(value): <R>() => R;
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
Defined in: [packages/utils/src/saferTyping.ts:40](https://github.com/lucasols/utils/blob/main/packages/utils/src/saferTyping.ts#L40)
|
|
197
|
+
|
|
198
|
+
Refine a value to a specific type T. Use this when you have legit usage of type assertion.
|
|
199
|
+
|
|
200
|
+
#### Type Parameters
|
|
201
|
+
|
|
202
|
+
##### T
|
|
203
|
+
|
|
204
|
+
`T`
|
|
205
|
+
|
|
206
|
+
The type to cast to
|
|
207
|
+
|
|
208
|
+
#### Parameters
|
|
209
|
+
|
|
210
|
+
##### value
|
|
211
|
+
|
|
212
|
+
`T`
|
|
213
|
+
|
|
214
|
+
#### Returns
|
|
215
|
+
|
|
216
|
+
```ts
|
|
217
|
+
<R>(): R;
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
##### Type Parameters
|
|
221
|
+
|
|
222
|
+
###### R
|
|
223
|
+
|
|
224
|
+
`R`
|
|
225
|
+
|
|
226
|
+
##### Returns
|
|
227
|
+
|
|
228
|
+
`R`
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
[**@ls-stack/utils**](README.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
[@ls-stack/utils](modules.md) / serializeXML
|
|
6
|
+
|
|
7
|
+
# serializeXML
|
|
8
|
+
|
|
9
|
+
## Type Aliases
|
|
10
|
+
|
|
11
|
+
### SerializeOptions
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
type SerializeOptions = object;
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Defined in: [packages/utils/src/serializeXML.ts:36](https://github.com/lucasols/utils/blob/main/packages/utils/src/serializeXML.ts#L36)
|
|
18
|
+
|
|
19
|
+
#### Properties
|
|
20
|
+
|
|
21
|
+
##### escapeText?
|
|
22
|
+
|
|
23
|
+
```ts
|
|
24
|
+
optional escapeText: boolean;
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Defined in: [packages/utils/src/serializeXML.ts:38](https://github.com/lucasols/utils/blob/main/packages/utils/src/serializeXML.ts#L38)
|
|
28
|
+
|
|
29
|
+
##### indent?
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
optional indent: number | string;
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Defined in: [packages/utils/src/serializeXML.ts:37](https://github.com/lucasols/utils/blob/main/packages/utils/src/serializeXML.ts#L37)
|
|
36
|
+
|
|
37
|
+
##### invalidNodes?
|
|
38
|
+
|
|
39
|
+
```ts
|
|
40
|
+
optional invalidNodes: "throw" | "reject";
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Defined in: [packages/utils/src/serializeXML.ts:40](https://github.com/lucasols/utils/blob/main/packages/utils/src/serializeXML.ts#L40)
|
|
44
|
+
|
|
45
|
+
##### validateTagName?
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
optional validateTagName: boolean;
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Defined in: [packages/utils/src/serializeXML.ts:39](https://github.com/lucasols/utils/blob/main/packages/utils/src/serializeXML.ts#L39)
|
|
52
|
+
|
|
53
|
+
***
|
|
54
|
+
|
|
55
|
+
### XMLNode
|
|
56
|
+
|
|
57
|
+
```ts
|
|
58
|
+
type XMLNode =
|
|
59
|
+
| {
|
|
60
|
+
attrs?: Record<string, string | number | boolean | null | undefined>;
|
|
61
|
+
children?: (XMLNode | null | undefined | false)[] | string;
|
|
62
|
+
escapeText?: boolean;
|
|
63
|
+
name: string;
|
|
64
|
+
type?: "node";
|
|
65
|
+
}
|
|
66
|
+
| {
|
|
67
|
+
content: string;
|
|
68
|
+
escapeText?: boolean;
|
|
69
|
+
type: "comment";
|
|
70
|
+
}
|
|
71
|
+
| {
|
|
72
|
+
type: "emptyLine";
|
|
73
|
+
};
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Defined in: [packages/utils/src/serializeXML.ts:19](https://github.com/lucasols/utils/blob/main/packages/utils/src/serializeXML.ts#L19)
|
|
77
|
+
|
|
78
|
+
## Functions
|
|
79
|
+
|
|
80
|
+
### serializeXML()
|
|
81
|
+
|
|
82
|
+
```ts
|
|
83
|
+
function serializeXML(node, options?): string;
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Defined in: [packages/utils/src/serializeXML.ts:43](https://github.com/lucasols/utils/blob/main/packages/utils/src/serializeXML.ts#L43)
|
|
87
|
+
|
|
88
|
+
#### Parameters
|
|
89
|
+
|
|
90
|
+
##### node
|
|
91
|
+
|
|
92
|
+
[`XMLNode`](#xmlnode) | false \| XMLNode \| null \| undefined[]
|
|
93
|
+
|
|
94
|
+
##### options?
|
|
95
|
+
|
|
96
|
+
[`SerializeOptions`](#serializeoptions)
|
|
97
|
+
|
|
98
|
+
#### Returns
|
|
99
|
+
|
|
100
|
+
`string`
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
[**@ls-stack/utils**](README.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
[@ls-stack/utils](modules.md) / shallowEqual
|
|
6
|
+
|
|
7
|
+
# shallowEqual
|
|
8
|
+
|
|
9
|
+
## Functions
|
|
10
|
+
|
|
11
|
+
### shallowEqual()
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
function shallowEqual(foo, bar): boolean;
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Defined in: [packages/utils/src/shallowEqual.ts:11](https://github.com/lucasols/utils/blob/main/packages/utils/src/shallowEqual.ts#L11)
|
|
18
|
+
|
|
19
|
+
shallow equal version of https://github.com/lukeed/dequal
|
|
20
|
+
|
|
21
|
+
#### Parameters
|
|
22
|
+
|
|
23
|
+
##### foo
|
|
24
|
+
|
|
25
|
+
`any`
|
|
26
|
+
|
|
27
|
+
##### bar
|
|
28
|
+
|
|
29
|
+
`any`
|
|
30
|
+
|
|
31
|
+
#### Returns
|
|
32
|
+
|
|
33
|
+
`boolean`
|
package/docs/sleep.md
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
[**@ls-stack/utils**](README.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
[@ls-stack/utils](modules.md) / sleep
|
|
6
|
+
|
|
7
|
+
# sleep
|
|
8
|
+
|
|
9
|
+
## Functions
|
|
10
|
+
|
|
11
|
+
### sleep()
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
function sleep(ms): Promise<unknown>;
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Defined in: [packages/utils/src/sleep.ts:1](https://github.com/lucasols/utils/blob/main/packages/utils/src/sleep.ts#L1)
|
|
18
|
+
|
|
19
|
+
#### Parameters
|
|
20
|
+
|
|
21
|
+
##### ms
|
|
22
|
+
|
|
23
|
+
`number`
|
|
24
|
+
|
|
25
|
+
#### Returns
|
|
26
|
+
|
|
27
|
+
`Promise`\<`unknown`\>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
[**@ls-stack/utils**](../README.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
[@ls-stack/utils](../modules.md) / [stringUtils](README.md) / \<internal\>
|
|
6
|
+
|
|
7
|
+
# \<internal\>
|
|
8
|
+
|
|
9
|
+
## Type Aliases
|
|
10
|
+
|
|
11
|
+
### Arg
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
type Arg = string | false | undefined | null;
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Defined in: [packages/utils/src/stringUtils.ts:1](https://github.com/lucasols/utils/blob/main/packages/utils/src/stringUtils.ts#L1)
|