@ls-stack/utils 3.40.0 → 3.42.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-ADM37GSC.js → chunk-7L4KCZJJ.js} +12 -10
- package/dist/{chunk-KW55OTUG.js → chunk-B3KFV2MH.js} +2 -2
- package/dist/chunk-GMJTLFM6.js +60 -0
- package/dist/{chunk-GHAQOUA6.js → chunk-Y45CE75W.js} +22 -1
- 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.cjs +15 -0
- package/dist/typingFnUtils.d.cts +34 -7
- package/dist/typingFnUtils.d.ts +34 -7
- package/dist/typingFnUtils.js +18 -35
- package/dist/typingTestUtils.cjs +7 -1
- package/dist/typingTestUtils.d.cts +52 -11
- package/dist/typingTestUtils.d.ts +52 -11
- package/dist/typingTestUtils.js +7 -1
- package/dist/typingUtils.d.cts +4 -1
- package/dist/typingUtils.d.ts +4 -1
- package/dist/yamlStringify.cjs +11 -9
- package/dist/yamlStringify.js +2 -2
- package/package.json +5 -1
- package/docs/README.md +0 -72
- package/docs/_media/modules.md +0 -58
- package/docs/arrayUtils/-internal-.md +0 -179
- package/docs/arrayUtils/README.md +0 -550
- package/docs/assertions/-internal-.md +0 -63
- package/docs/assertions/README.md +0 -565
- package/docs/asyncQueue/-internal-.md +0 -297
- package/docs/asyncQueue/README.md +0 -1485
- package/docs/awaitDebounce.md +0 -66
- package/docs/cache/-internal-.md +0 -168
- package/docs/cache/README.md +0 -360
- package/docs/castValues.md +0 -47
- package/docs/concurrentCalls/-internal-.md +0 -490
- package/docs/concurrentCalls/README.md +0 -299
- package/docs/consoleFmt.md +0 -115
- package/docs/conversions.md +0 -27
- package/docs/createThrottleController/-internal-.md +0 -73
- package/docs/createThrottleController/README.md +0 -31
- package/docs/debounce.md +0 -188
- package/docs/dedent/-internal-.md +0 -17
- package/docs/dedent/README.md +0 -204
- package/docs/deepEqual.md +0 -94
- package/docs/enhancedMap.md +0 -358
- package/docs/exhaustiveMatch/-internal-.md +0 -39
- package/docs/exhaustiveMatch/README.md +0 -146
- package/docs/filterObjectOrArrayKeys.md +0 -109
- package/docs/getAutoIncrementId.md +0 -93
- package/docs/getCompositeKey.md +0 -39
- package/docs/getValueStableKey.md +0 -57
- package/docs/hash.md +0 -31
- package/docs/interpolate/-internal-.md +0 -61
- package/docs/interpolate/README.md +0 -62
- package/docs/keepPrevIfUnchanged.md +0 -43
- package/docs/levenshtein.md +0 -93
- package/docs/main.md +0 -21
- package/docs/mathUtils.md +0 -137
- package/docs/modules.md +0 -58
- package/docs/mutationUtils.md +0 -44
- package/docs/objUtils.md +0 -237
- package/docs/parallelAsyncCalls/-internal-.md +0 -347
- package/docs/parallelAsyncCalls/README.md +0 -45
- package/docs/promiseUtils/-internal-.md +0 -69
- package/docs/promiseUtils/README.md +0 -31
- package/docs/retryOnError/-internal-.md +0 -111
- package/docs/retryOnError/README.md +0 -168
- package/docs/runShellCmd/-internal-.md +0 -111
- package/docs/runShellCmd/README.md +0 -201
- package/docs/safeJson.md +0 -51
- package/docs/saferTyping.md +0 -228
- package/docs/serializeXML.md +0 -100
- package/docs/shallowEqual.md +0 -33
- package/docs/sleep.md +0 -27
- package/docs/stringUtils/-internal-.md +0 -17
- package/docs/stringUtils/README.md +0 -270
- package/docs/testUtils.md +0 -382
- package/docs/throttle/-internal-.md +0 -47
- package/docs/throttle/README.md +0 -178
- package/docs/time.md +0 -274
- package/docs/timers.md +0 -256
- package/docs/tsResult/-internal-.md +0 -327
- package/docs/tsResult/README.md +0 -702
- package/docs/typeGuards.md +0 -399
- package/docs/typeUtils/-internal-.md +0 -99
- package/docs/typeUtils/README.md +0 -195
- package/docs/typeUtils.typesTest.md +0 -7
- package/docs/typedStrings.md +0 -458
- package/docs/typingFnUtils/-internal-.md +0 -43
- package/docs/typingFnUtils/README.md +0 -317
- package/docs/typingTestUtils.md +0 -172
- package/docs/typingUtils.md +0 -135
- package/docs/yamlStringify.md +0 -83
package/docs/awaitDebounce.md
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
[**@ls-stack/utils**](README.md)
|
|
2
|
-
|
|
3
|
-
***
|
|
4
|
-
|
|
5
|
-
[@ls-stack/utils](modules.md) / awaitDebounce
|
|
6
|
-
|
|
7
|
-
# awaitDebounce
|
|
8
|
-
|
|
9
|
-
## Functions
|
|
10
|
-
|
|
11
|
-
### awaitDebounce()
|
|
12
|
-
|
|
13
|
-
```ts
|
|
14
|
-
function awaitDebounce(options): Promise<"skip" | "continue">;
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
Defined in: [packages/utils/src/awaitDebounce.ts:41](https://github.com/lucasols/utils/blob/main/packages/utils/src/awaitDebounce.ts#L41)
|
|
18
|
-
|
|
19
|
-
Creates an awaitable debounce mechanism that allows you to debounce async operations.
|
|
20
|
-
When called multiple times with the same `callId`, only the last call will resolve with 'continue',
|
|
21
|
-
while all previous calls resolve with 'skip'.
|
|
22
|
-
|
|
23
|
-
This is useful for debouncing API calls, search operations, or any async work where you want
|
|
24
|
-
to ensure only the most recent request is processed.
|
|
25
|
-
|
|
26
|
-
#### Parameters
|
|
27
|
-
|
|
28
|
-
##### options
|
|
29
|
-
|
|
30
|
-
Configuration object
|
|
31
|
-
|
|
32
|
-
###### callId
|
|
33
|
-
|
|
34
|
-
`any`
|
|
35
|
-
|
|
36
|
-
Unique identifier for the debounce group. Calls with the same ID are debounced together
|
|
37
|
-
|
|
38
|
-
###### debounce
|
|
39
|
-
|
|
40
|
-
`number`
|
|
41
|
-
|
|
42
|
-
Debounce delay in milliseconds
|
|
43
|
-
|
|
44
|
-
#### Returns
|
|
45
|
-
|
|
46
|
-
`Promise`\<`"skip"` \| `"continue"`\>
|
|
47
|
-
|
|
48
|
-
Promise that resolves to 'continue' if this call should proceed, or 'skip' if it was superseded
|
|
49
|
-
|
|
50
|
-
#### Example
|
|
51
|
-
|
|
52
|
-
```ts
|
|
53
|
-
async function searchUsers(query: string) {
|
|
54
|
-
const result = await awaitDebounce({ callId: 'search', debounce: 300 });
|
|
55
|
-
if (result === 'skip') return; // This search was superseded
|
|
56
|
-
|
|
57
|
-
// Only the most recent search will reach here
|
|
58
|
-
const users = await fetchUsers(query);
|
|
59
|
-
updateUI(users);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
// Called rapidly - only the last call will execute
|
|
63
|
-
searchUsers('a');
|
|
64
|
-
searchUsers('ab');
|
|
65
|
-
searchUsers('abc'); // Only this one will continue
|
|
66
|
-
```
|
package/docs/cache/-internal-.md
DELETED
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
[**@ls-stack/utils**](../README.md)
|
|
2
|
-
|
|
3
|
-
***
|
|
4
|
-
|
|
5
|
-
[@ls-stack/utils](../modules.md) / [cache](README.md) / \<internal\>
|
|
6
|
-
|
|
7
|
-
# \<internal\>
|
|
8
|
-
|
|
9
|
-
## Type Aliases
|
|
10
|
-
|
|
11
|
-
### GetOptions\<T\>
|
|
12
|
-
|
|
13
|
-
```ts
|
|
14
|
-
type GetOptions<T> = object;
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
Defined in: [packages/utils/src/cache.ts:65](https://github.com/lucasols/utils/blob/main/packages/utils/src/cache.ts#L65)
|
|
18
|
-
|
|
19
|
-
#### Type Parameters
|
|
20
|
-
|
|
21
|
-
##### T
|
|
22
|
-
|
|
23
|
-
`T`
|
|
24
|
-
|
|
25
|
-
#### Properties
|
|
26
|
-
|
|
27
|
-
##### skipCachingWhen()?
|
|
28
|
-
|
|
29
|
-
```ts
|
|
30
|
-
optional skipCachingWhen: (value) => boolean;
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
Defined in: [packages/utils/src/cache.ts:72](https://github.com/lucasols/utils/blob/main/packages/utils/src/cache.ts#L72)
|
|
34
|
-
|
|
35
|
-
A function that determines whether a value should be rejected from being cached.
|
|
36
|
-
If the function returns true, the value will be returned but not cached.
|
|
37
|
-
|
|
38
|
-
###### Parameters
|
|
39
|
-
|
|
40
|
-
###### value
|
|
41
|
-
|
|
42
|
-
`T`
|
|
43
|
-
|
|
44
|
-
The value to check
|
|
45
|
-
|
|
46
|
-
###### Returns
|
|
47
|
-
|
|
48
|
-
`boolean`
|
|
49
|
-
|
|
50
|
-
true if the value should be rejected, false otherwise
|
|
51
|
-
|
|
52
|
-
***
|
|
53
|
-
|
|
54
|
-
### Options
|
|
55
|
-
|
|
56
|
-
```ts
|
|
57
|
-
type Options = object;
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
Defined in: [packages/utils/src/cache.ts:15](https://github.com/lucasols/utils/blob/main/packages/utils/src/cache.ts#L15)
|
|
61
|
-
|
|
62
|
-
#### Properties
|
|
63
|
-
|
|
64
|
-
##### expirationThrottle?
|
|
65
|
-
|
|
66
|
-
```ts
|
|
67
|
-
optional expirationThrottle: number;
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
Defined in: [packages/utils/src/cache.ts:30](https://github.com/lucasols/utils/blob/main/packages/utils/src/cache.ts#L30)
|
|
71
|
-
|
|
72
|
-
The throttle for checking expired items in milliseconds.
|
|
73
|
-
|
|
74
|
-
###### Default
|
|
75
|
-
|
|
76
|
-
```ts
|
|
77
|
-
10_000
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
##### maxCacheSize?
|
|
81
|
-
|
|
82
|
-
```ts
|
|
83
|
-
optional maxCacheSize: number;
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
Defined in: [packages/utils/src/cache.ts:20](https://github.com/lucasols/utils/blob/main/packages/utils/src/cache.ts#L20)
|
|
87
|
-
|
|
88
|
-
The maximum number of items in the cache.
|
|
89
|
-
|
|
90
|
-
###### Default
|
|
91
|
-
|
|
92
|
-
```ts
|
|
93
|
-
1000
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
##### maxItemAge?
|
|
97
|
-
|
|
98
|
-
```ts
|
|
99
|
-
optional maxItemAge: DurationObj;
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
Defined in: [packages/utils/src/cache.ts:24](https://github.com/lucasols/utils/blob/main/packages/utils/src/cache.ts#L24)
|
|
103
|
-
|
|
104
|
-
The maximum age of items in the cache.
|
|
105
|
-
|
|
106
|
-
***
|
|
107
|
-
|
|
108
|
-
### Utils\<T\>
|
|
109
|
-
|
|
110
|
-
```ts
|
|
111
|
-
type Utils<T> = object;
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
Defined in: [packages/utils/src/cache.ts:55](https://github.com/lucasols/utils/blob/main/packages/utils/src/cache.ts#L55)
|
|
115
|
-
|
|
116
|
-
#### Type Parameters
|
|
117
|
-
|
|
118
|
-
##### T
|
|
119
|
-
|
|
120
|
-
`T`
|
|
121
|
-
|
|
122
|
-
#### Properties
|
|
123
|
-
|
|
124
|
-
##### skipCaching()
|
|
125
|
-
|
|
126
|
-
```ts
|
|
127
|
-
skipCaching: (value) => SkipCaching<T>;
|
|
128
|
-
```
|
|
129
|
-
|
|
130
|
-
Defined in: [packages/utils/src/cache.ts:56](https://github.com/lucasols/utils/blob/main/packages/utils/src/cache.ts#L56)
|
|
131
|
-
|
|
132
|
-
###### Parameters
|
|
133
|
-
|
|
134
|
-
###### value
|
|
135
|
-
|
|
136
|
-
`T`
|
|
137
|
-
|
|
138
|
-
###### Returns
|
|
139
|
-
|
|
140
|
-
[`SkipCaching`](README.md#skipcaching)\<`T`\>
|
|
141
|
-
|
|
142
|
-
##### withExpiration()
|
|
143
|
-
|
|
144
|
-
```ts
|
|
145
|
-
withExpiration: (value, expiration) => WithExpiration<T>;
|
|
146
|
-
```
|
|
147
|
-
|
|
148
|
-
Defined in: [packages/utils/src/cache.ts:62](https://github.com/lucasols/utils/blob/main/packages/utils/src/cache.ts#L62)
|
|
149
|
-
|
|
150
|
-
Create a new WithExpiration object with the given value and expiration time.
|
|
151
|
-
|
|
152
|
-
###### Parameters
|
|
153
|
-
|
|
154
|
-
###### value
|
|
155
|
-
|
|
156
|
-
`T`
|
|
157
|
-
|
|
158
|
-
The value to store in the cache.
|
|
159
|
-
|
|
160
|
-
###### expiration
|
|
161
|
-
|
|
162
|
-
[`DurationObj`](../time.md#durationobj)
|
|
163
|
-
|
|
164
|
-
The expiration time of the value in seconds or a duration object.
|
|
165
|
-
|
|
166
|
-
###### Returns
|
|
167
|
-
|
|
168
|
-
[`WithExpiration`](README.md#withexpiration)\<`T`\>
|
package/docs/cache/README.md
DELETED
|
@@ -1,360 +0,0 @@
|
|
|
1
|
-
[**@ls-stack/utils**](../README.md)
|
|
2
|
-
|
|
3
|
-
***
|
|
4
|
-
|
|
5
|
-
[@ls-stack/utils](../modules.md) / cache
|
|
6
|
-
|
|
7
|
-
# cache
|
|
8
|
-
|
|
9
|
-
## Modules
|
|
10
|
-
|
|
11
|
-
- [\<internal\>](-internal-.md)
|
|
12
|
-
|
|
13
|
-
## Classes
|
|
14
|
-
|
|
15
|
-
### SkipCaching\<T\>
|
|
16
|
-
|
|
17
|
-
Defined in: [packages/utils/src/cache.ts:33](https://github.com/lucasols/utils/blob/main/packages/utils/src/cache.ts#L33)
|
|
18
|
-
|
|
19
|
-
#### Type Parameters
|
|
20
|
-
|
|
21
|
-
##### T
|
|
22
|
-
|
|
23
|
-
`T`
|
|
24
|
-
|
|
25
|
-
#### Constructors
|
|
26
|
-
|
|
27
|
-
##### Constructor
|
|
28
|
-
|
|
29
|
-
```ts
|
|
30
|
-
new SkipCaching<T>(value): SkipCaching<T>;
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
Defined in: [packages/utils/src/cache.ts:36](https://github.com/lucasols/utils/blob/main/packages/utils/src/cache.ts#L36)
|
|
34
|
-
|
|
35
|
-
###### Parameters
|
|
36
|
-
|
|
37
|
-
###### value
|
|
38
|
-
|
|
39
|
-
`T`
|
|
40
|
-
|
|
41
|
-
###### Returns
|
|
42
|
-
|
|
43
|
-
[`SkipCaching`](#skipcaching)\<`T`\>
|
|
44
|
-
|
|
45
|
-
#### Properties
|
|
46
|
-
|
|
47
|
-
##### value
|
|
48
|
-
|
|
49
|
-
```ts
|
|
50
|
-
value: T;
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
Defined in: [packages/utils/src/cache.ts:34](https://github.com/lucasols/utils/blob/main/packages/utils/src/cache.ts#L34)
|
|
54
|
-
|
|
55
|
-
***
|
|
56
|
-
|
|
57
|
-
### WithExpiration\<T\>
|
|
58
|
-
|
|
59
|
-
Defined in: [packages/utils/src/cache.ts:41](https://github.com/lucasols/utils/blob/main/packages/utils/src/cache.ts#L41)
|
|
60
|
-
|
|
61
|
-
#### Type Parameters
|
|
62
|
-
|
|
63
|
-
##### T
|
|
64
|
-
|
|
65
|
-
`T`
|
|
66
|
-
|
|
67
|
-
#### Constructors
|
|
68
|
-
|
|
69
|
-
##### Constructor
|
|
70
|
-
|
|
71
|
-
```ts
|
|
72
|
-
new WithExpiration<T>(value, expiration): WithExpiration<T>;
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
Defined in: [packages/utils/src/cache.ts:49](https://github.com/lucasols/utils/blob/main/packages/utils/src/cache.ts#L49)
|
|
76
|
-
|
|
77
|
-
###### Parameters
|
|
78
|
-
|
|
79
|
-
###### value
|
|
80
|
-
|
|
81
|
-
`T`
|
|
82
|
-
|
|
83
|
-
The value to store in the cache.
|
|
84
|
-
|
|
85
|
-
###### expiration
|
|
86
|
-
|
|
87
|
-
[`DurationObj`](../time.md#durationobj)
|
|
88
|
-
|
|
89
|
-
The expiration time of the value in seconds or a duration object.
|
|
90
|
-
|
|
91
|
-
###### Returns
|
|
92
|
-
|
|
93
|
-
[`WithExpiration`](#withexpiration)\<`T`\>
|
|
94
|
-
|
|
95
|
-
#### Properties
|
|
96
|
-
|
|
97
|
-
##### expiration
|
|
98
|
-
|
|
99
|
-
```ts
|
|
100
|
-
expiration: number;
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
Defined in: [packages/utils/src/cache.ts:43](https://github.com/lucasols/utils/blob/main/packages/utils/src/cache.ts#L43)
|
|
104
|
-
|
|
105
|
-
##### value
|
|
106
|
-
|
|
107
|
-
```ts
|
|
108
|
-
value: T;
|
|
109
|
-
```
|
|
110
|
-
|
|
111
|
-
Defined in: [packages/utils/src/cache.ts:42](https://github.com/lucasols/utils/blob/main/packages/utils/src/cache.ts#L42)
|
|
112
|
-
|
|
113
|
-
## Type Aliases
|
|
114
|
-
|
|
115
|
-
### Cache\<T\>
|
|
116
|
-
|
|
117
|
-
```ts
|
|
118
|
-
type Cache<T> = object;
|
|
119
|
-
```
|
|
120
|
-
|
|
121
|
-
Defined in: [packages/utils/src/cache.ts:75](https://github.com/lucasols/utils/blob/main/packages/utils/src/cache.ts#L75)
|
|
122
|
-
|
|
123
|
-
#### Type Parameters
|
|
124
|
-
|
|
125
|
-
##### T
|
|
126
|
-
|
|
127
|
-
`T`
|
|
128
|
-
|
|
129
|
-
#### Properties
|
|
130
|
-
|
|
131
|
-
##### cache
|
|
132
|
-
|
|
133
|
-
```ts
|
|
134
|
-
cache: object;
|
|
135
|
-
```
|
|
136
|
-
|
|
137
|
-
Defined in: [packages/utils/src/cache.ts:95](https://github.com/lucasols/utils/blob/main/packages/utils/src/cache.ts#L95)
|
|
138
|
-
|
|
139
|
-
###### map
|
|
140
|
-
|
|
141
|
-
```ts
|
|
142
|
-
map: Map<string, {
|
|
143
|
-
timestamp: number;
|
|
144
|
-
value: T | Promise<T>;
|
|
145
|
-
}>;
|
|
146
|
-
```
|
|
147
|
-
|
|
148
|
-
##### cleanExpiredItems()
|
|
149
|
-
|
|
150
|
-
```ts
|
|
151
|
-
cleanExpiredItems: () => void;
|
|
152
|
-
```
|
|
153
|
-
|
|
154
|
-
Defined in: [packages/utils/src/cache.ts:89](https://github.com/lucasols/utils/blob/main/packages/utils/src/cache.ts#L89)
|
|
155
|
-
|
|
156
|
-
###### Returns
|
|
157
|
-
|
|
158
|
-
`void`
|
|
159
|
-
|
|
160
|
-
##### clear()
|
|
161
|
-
|
|
162
|
-
```ts
|
|
163
|
-
clear: () => void;
|
|
164
|
-
```
|
|
165
|
-
|
|
166
|
-
Defined in: [packages/utils/src/cache.ts:86](https://github.com/lucasols/utils/blob/main/packages/utils/src/cache.ts#L86)
|
|
167
|
-
|
|
168
|
-
###### Returns
|
|
169
|
-
|
|
170
|
-
`void`
|
|
171
|
-
|
|
172
|
-
##### get()
|
|
173
|
-
|
|
174
|
-
```ts
|
|
175
|
-
get: (cacheKey) => T | undefined;
|
|
176
|
-
```
|
|
177
|
-
|
|
178
|
-
Defined in: [packages/utils/src/cache.ts:87](https://github.com/lucasols/utils/blob/main/packages/utils/src/cache.ts#L87)
|
|
179
|
-
|
|
180
|
-
###### Parameters
|
|
181
|
-
|
|
182
|
-
###### cacheKey
|
|
183
|
-
|
|
184
|
-
`string`
|
|
185
|
-
|
|
186
|
-
###### Returns
|
|
187
|
-
|
|
188
|
-
`T` \| `undefined`
|
|
189
|
-
|
|
190
|
-
##### getAsync()
|
|
191
|
-
|
|
192
|
-
```ts
|
|
193
|
-
getAsync: (cacheKey) => Promise<T | undefined>;
|
|
194
|
-
```
|
|
195
|
-
|
|
196
|
-
Defined in: [packages/utils/src/cache.ts:90](https://github.com/lucasols/utils/blob/main/packages/utils/src/cache.ts#L90)
|
|
197
|
-
|
|
198
|
-
###### Parameters
|
|
199
|
-
|
|
200
|
-
###### cacheKey
|
|
201
|
-
|
|
202
|
-
`string`
|
|
203
|
-
|
|
204
|
-
###### Returns
|
|
205
|
-
|
|
206
|
-
`Promise`\<`T` \| `undefined`\>
|
|
207
|
-
|
|
208
|
-
##### getOrInsert()
|
|
209
|
-
|
|
210
|
-
```ts
|
|
211
|
-
getOrInsert: (cacheKey, val, options?) => T;
|
|
212
|
-
```
|
|
213
|
-
|
|
214
|
-
Defined in: [packages/utils/src/cache.ts:76](https://github.com/lucasols/utils/blob/main/packages/utils/src/cache.ts#L76)
|
|
215
|
-
|
|
216
|
-
###### Parameters
|
|
217
|
-
|
|
218
|
-
###### cacheKey
|
|
219
|
-
|
|
220
|
-
`string`
|
|
221
|
-
|
|
222
|
-
###### val
|
|
223
|
-
|
|
224
|
-
(`utils`) => `T` \| [`SkipCaching`](#skipcaching)\<`T`\>
|
|
225
|
-
|
|
226
|
-
###### options?
|
|
227
|
-
|
|
228
|
-
[`GetOptions`](-internal-.md#getoptions)\<`T`\>
|
|
229
|
-
|
|
230
|
-
###### Returns
|
|
231
|
-
|
|
232
|
-
`T`
|
|
233
|
-
|
|
234
|
-
##### getOrInsertAsync()
|
|
235
|
-
|
|
236
|
-
```ts
|
|
237
|
-
getOrInsertAsync: (cacheKey, val, options?) => Promise<T>;
|
|
238
|
-
```
|
|
239
|
-
|
|
240
|
-
Defined in: [packages/utils/src/cache.ts:81](https://github.com/lucasols/utils/blob/main/packages/utils/src/cache.ts#L81)
|
|
241
|
-
|
|
242
|
-
###### Parameters
|
|
243
|
-
|
|
244
|
-
###### cacheKey
|
|
245
|
-
|
|
246
|
-
`string`
|
|
247
|
-
|
|
248
|
-
###### val
|
|
249
|
-
|
|
250
|
-
(`utils`) => `Promise`\<`T` \| [`SkipCaching`](#skipcaching)\<`T`\>\>
|
|
251
|
-
|
|
252
|
-
###### options?
|
|
253
|
-
|
|
254
|
-
[`GetOptions`](-internal-.md#getoptions)\<`T`\>
|
|
255
|
-
|
|
256
|
-
###### Returns
|
|
257
|
-
|
|
258
|
-
`Promise`\<`T`\>
|
|
259
|
-
|
|
260
|
-
##### set()
|
|
261
|
-
|
|
262
|
-
```ts
|
|
263
|
-
set: (cacheKey, value) => void;
|
|
264
|
-
```
|
|
265
|
-
|
|
266
|
-
Defined in: [packages/utils/src/cache.ts:88](https://github.com/lucasols/utils/blob/main/packages/utils/src/cache.ts#L88)
|
|
267
|
-
|
|
268
|
-
###### Parameters
|
|
269
|
-
|
|
270
|
-
###### cacheKey
|
|
271
|
-
|
|
272
|
-
`string`
|
|
273
|
-
|
|
274
|
-
###### value
|
|
275
|
-
|
|
276
|
-
`T` | [`WithExpiration`](#withexpiration)\<`T`\>
|
|
277
|
-
|
|
278
|
-
###### Returns
|
|
279
|
-
|
|
280
|
-
`void`
|
|
281
|
-
|
|
282
|
-
##### setAsync()
|
|
283
|
-
|
|
284
|
-
```ts
|
|
285
|
-
setAsync: (cacheKey, value) => Promise<T>;
|
|
286
|
-
```
|
|
287
|
-
|
|
288
|
-
Defined in: [packages/utils/src/cache.ts:91](https://github.com/lucasols/utils/blob/main/packages/utils/src/cache.ts#L91)
|
|
289
|
-
|
|
290
|
-
###### Parameters
|
|
291
|
-
|
|
292
|
-
###### cacheKey
|
|
293
|
-
|
|
294
|
-
`string`
|
|
295
|
-
|
|
296
|
-
###### value
|
|
297
|
-
|
|
298
|
-
(`utils`) => `Promise`\<`T` \| [`WithExpiration`](#withexpiration)\<`T`\>\>
|
|
299
|
-
|
|
300
|
-
###### Returns
|
|
301
|
-
|
|
302
|
-
`Promise`\<`T`\>
|
|
303
|
-
|
|
304
|
-
## Functions
|
|
305
|
-
|
|
306
|
-
### cachedGetter()
|
|
307
|
-
|
|
308
|
-
```ts
|
|
309
|
-
function cachedGetter<T>(getter): object;
|
|
310
|
-
```
|
|
311
|
-
|
|
312
|
-
Defined in: [packages/utils/src/cache.ts:3](https://github.com/lucasols/utils/blob/main/packages/utils/src/cache.ts#L3)
|
|
313
|
-
|
|
314
|
-
#### Type Parameters
|
|
315
|
-
|
|
316
|
-
##### T
|
|
317
|
-
|
|
318
|
-
`T`
|
|
319
|
-
|
|
320
|
-
#### Parameters
|
|
321
|
-
|
|
322
|
-
##### getter
|
|
323
|
-
|
|
324
|
-
() => `T`
|
|
325
|
-
|
|
326
|
-
#### Returns
|
|
327
|
-
|
|
328
|
-
`object`
|
|
329
|
-
|
|
330
|
-
##### value
|
|
331
|
-
|
|
332
|
-
```ts
|
|
333
|
-
value: T;
|
|
334
|
-
```
|
|
335
|
-
|
|
336
|
-
***
|
|
337
|
-
|
|
338
|
-
### createCache()
|
|
339
|
-
|
|
340
|
-
```ts
|
|
341
|
-
function createCache<T>(__namedParameters): Cache<T>;
|
|
342
|
-
```
|
|
343
|
-
|
|
344
|
-
Defined in: [packages/utils/src/cache.ts:100](https://github.com/lucasols/utils/blob/main/packages/utils/src/cache.ts#L100)
|
|
345
|
-
|
|
346
|
-
#### Type Parameters
|
|
347
|
-
|
|
348
|
-
##### T
|
|
349
|
-
|
|
350
|
-
`T`
|
|
351
|
-
|
|
352
|
-
#### Parameters
|
|
353
|
-
|
|
354
|
-
##### \_\_namedParameters
|
|
355
|
-
|
|
356
|
-
[`Options`](-internal-.md#options) = `{}`
|
|
357
|
-
|
|
358
|
-
#### Returns
|
|
359
|
-
|
|
360
|
-
[`Cache`](#cache)\<`T`\>
|
package/docs/castValues.md
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
[**@ls-stack/utils**](README.md)
|
|
2
|
-
|
|
3
|
-
***
|
|
4
|
-
|
|
5
|
-
[@ls-stack/utils](modules.md) / castValues
|
|
6
|
-
|
|
7
|
-
# castValues
|
|
8
|
-
|
|
9
|
-
## Functions
|
|
10
|
-
|
|
11
|
-
### castToNumber()
|
|
12
|
-
|
|
13
|
-
```ts
|
|
14
|
-
function castToNumber(value): null | number;
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
Defined in: [packages/utils/src/castValues.ts:14](https://github.com/lucasols/utils/blob/main/packages/utils/src/castValues.ts#L14)
|
|
18
|
-
|
|
19
|
-
#### Parameters
|
|
20
|
-
|
|
21
|
-
##### value
|
|
22
|
-
|
|
23
|
-
`unknown`
|
|
24
|
-
|
|
25
|
-
#### Returns
|
|
26
|
-
|
|
27
|
-
`null` \| `number`
|
|
28
|
-
|
|
29
|
-
***
|
|
30
|
-
|
|
31
|
-
### castToString()
|
|
32
|
-
|
|
33
|
-
```ts
|
|
34
|
-
function castToString(value): null | string;
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
Defined in: [packages/utils/src/castValues.ts:1](https://github.com/lucasols/utils/blob/main/packages/utils/src/castValues.ts#L1)
|
|
38
|
-
|
|
39
|
-
#### Parameters
|
|
40
|
-
|
|
41
|
-
##### value
|
|
42
|
-
|
|
43
|
-
`unknown`
|
|
44
|
-
|
|
45
|
-
#### Returns
|
|
46
|
-
|
|
47
|
-
`null` \| `string`
|