@twin.org/core 0.0.1-next.6 → 0.0.1-next.60
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/cjs/index.cjs +1672 -787
- package/dist/esm/index.mjs +1668 -788
- package/dist/types/encoding/base58.d.ts +18 -0
- package/dist/types/errors/baseError.d.ts +2 -1
- package/dist/types/factories/factory.d.ts +20 -1
- package/dist/types/helpers/arrayHelper.d.ts +13 -0
- package/dist/types/helpers/envHelper.d.ts +16 -0
- package/dist/types/helpers/errorHelper.d.ts +2 -1
- package/dist/types/helpers/jsonHelper.d.ts +30 -0
- package/dist/types/helpers/objectHelper.d.ts +33 -0
- package/dist/types/helpers/uint8ArrayHelper.d.ts +11 -0
- package/dist/types/index.d.ts +7 -0
- package/dist/types/models/IComponent.d.ts +12 -3
- package/dist/types/models/II18nShared.d.ts +29 -0
- package/dist/types/models/coerceType.d.ts +49 -0
- package/dist/types/models/compressionType.d.ts +1 -1
- package/dist/types/models/objectOrArray.d.ts +4 -0
- package/dist/types/utils/asyncCache.d.ts +10 -1
- package/dist/types/utils/coerce.d.ts +22 -0
- package/dist/types/utils/converter.d.ts +12 -0
- package/dist/types/utils/guards.d.ts +35 -0
- package/dist/types/utils/is.d.ts +12 -0
- package/dist/types/utils/sharedStore.d.ts +23 -0
- package/dist/types/utils/validation.d.ts +2 -0
- package/docs/changelog.md +79 -1
- package/docs/reference/classes/AlreadyExistsError.md +77 -27
- package/docs/reference/classes/ArrayHelper.md +79 -5
- package/docs/reference/classes/AsyncCache.md +75 -13
- package/docs/reference/classes/Base32.md +9 -5
- package/docs/reference/classes/Base58.md +61 -0
- package/docs/reference/classes/Base64.md +12 -6
- package/docs/reference/classes/Base64Url.md +9 -5
- package/docs/reference/classes/BaseError.md +79 -29
- package/docs/reference/classes/BitString.md +23 -11
- package/docs/reference/classes/Coerce.md +110 -12
- package/docs/reference/classes/Compression.md +19 -11
- package/docs/reference/classes/ConflictError.md +80 -28
- package/docs/reference/classes/Converter.md +110 -26
- package/docs/reference/classes/EnvHelper.md +45 -0
- package/docs/reference/classes/ErrorHelper.md +19 -7
- package/docs/reference/classes/Factory.md +95 -17
- package/docs/reference/classes/FilenameHelper.md +6 -4
- package/docs/reference/classes/GeneralError.md +75 -27
- package/docs/reference/classes/GuardError.md +80 -28
- package/docs/reference/classes/Guards.md +398 -80
- package/docs/reference/classes/HexHelper.md +18 -8
- package/docs/reference/classes/I18n.md +46 -20
- package/docs/reference/classes/Is.md +179 -51
- package/docs/reference/classes/JsonHelper.md +146 -10
- package/docs/reference/classes/NotFoundError.md +77 -27
- package/docs/reference/classes/NotImplementedError.md +71 -25
- package/docs/reference/classes/NotSupportedError.md +74 -26
- package/docs/reference/classes/ObjectHelper.md +225 -35
- package/docs/reference/classes/RandomHelper.md +6 -4
- package/docs/reference/classes/SharedStore.md +94 -0
- package/docs/reference/classes/StringHelper.md +54 -20
- package/docs/reference/classes/Uint8ArrayHelper.md +35 -0
- package/docs/reference/classes/UnauthorizedError.md +74 -26
- package/docs/reference/classes/UnprocessableError.md +75 -27
- package/docs/reference/classes/Url.md +37 -17
- package/docs/reference/classes/Urn.md +63 -27
- package/docs/reference/classes/Validation.md +349 -135
- package/docs/reference/classes/ValidationError.md +74 -26
- package/docs/reference/index.md +8 -0
- package/docs/reference/interfaces/IComponent.md +30 -8
- package/docs/reference/interfaces/IError.md +2 -2
- package/docs/reference/interfaces/II18nShared.md +47 -0
- package/docs/reference/interfaces/IKeyValue.md +3 -1
- package/docs/reference/interfaces/ILabelledValue.md +3 -1
- package/docs/reference/interfaces/ILocaleDictionary.md +1 -1
- package/docs/reference/interfaces/IPatchOperation.md +1 -1
- package/docs/reference/interfaces/IValidationFailure.md +1 -1
- package/docs/reference/type-aliases/CoerceType.md +5 -0
- package/docs/reference/type-aliases/CompressionType.md +1 -1
- package/docs/reference/type-aliases/ObjectOrArray.md +11 -0
- package/docs/reference/variables/CoerceType.md +67 -0
- package/docs/reference/variables/CompressionType.md +1 -1
- package/locales/en.json +23 -1
- package/package.json +6 -6
package/docs/changelog.md
CHANGED
|
@@ -1,5 +1,83 @@
|
|
|
1
1
|
# @twin.org/core - Changelog
|
|
2
2
|
|
|
3
|
-
## 0.0.1-next.
|
|
3
|
+
## [0.0.1-next.60](https://github.com/twinfoundation/framework/compare/core-v0.0.1-next.59...core-v0.0.1-next.60) (2025-06-17)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* improve error display in CLI ([94b6ca8](https://github.com/twinfoundation/framework/commit/94b6ca8bdcfe3ca7671c4095b436ea7bddaae98e))
|
|
9
|
+
|
|
10
|
+
## [0.0.1-next.59](https://github.com/twinfoundation/framework/compare/core-v0.0.1-next.58...core-v0.0.1-next.59) (2025-06-17)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Features
|
|
14
|
+
|
|
15
|
+
* propagate includeStackTrace on error conversion ([8471cbb](https://github.com/twinfoundation/framework/commit/8471cbb71f8fc98247a0e92126c438c1a8b04d9b))
|
|
16
|
+
* propagate includeStackTrace on error conversion ([818337d](https://github.com/twinfoundation/framework/commit/818337d50d14bf5a7e8b3204649aa7527115cca9))
|
|
17
|
+
|
|
18
|
+
## [0.0.1-next.58](https://github.com/twinfoundation/framework/compare/core-v0.0.1-next.57...core-v0.0.1-next.58) (2025-06-13)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
### Miscellaneous Chores
|
|
22
|
+
|
|
23
|
+
* **core:** Synchronize repo versions
|
|
24
|
+
|
|
25
|
+
## [0.0.1-next.57](https://github.com/twinfoundation/framework/compare/core-v0.0.1-next.56...core-v0.0.1-next.57) (2025-06-10)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
### Features
|
|
29
|
+
|
|
30
|
+
* add guards arrayEndsWith and arrayStartsWith ([95d875e](https://github.com/twinfoundation/framework/commit/95d875ec8ccb4713c145fdde941d4cfedcec2ed3))
|
|
31
|
+
|
|
32
|
+
## [0.0.1-next.56](https://github.com/twinfoundation/framework/compare/core-v0.0.1-next.55...core-v0.0.1-next.56) (2025-05-08)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
### Features
|
|
36
|
+
|
|
37
|
+
* add ObjectOrArray and ArrayHelper methods ([0ac9077](https://github.com/twinfoundation/framework/commit/0ac907764d64b38ad1b04b0e9c3027055b527559))
|
|
38
|
+
|
|
39
|
+
## [0.0.1-next.55](https://github.com/twinfoundation/framework/compare/core-v0.0.1-next.54...core-v0.0.1-next.55) (2025-05-07)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
### Miscellaneous Chores
|
|
43
|
+
|
|
44
|
+
* **core:** Synchronize repo versions
|
|
45
|
+
|
|
46
|
+
## [0.0.1-next.54](https://github.com/twinfoundation/framework/compare/core-v0.0.1-next.53...core-v0.0.1-next.54) (2025-05-06)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
### Miscellaneous Chores
|
|
50
|
+
|
|
51
|
+
* **core:** Synchronize repo versions
|
|
52
|
+
|
|
53
|
+
## [0.0.1-next.53](https://github.com/twinfoundation/framework/compare/core-v0.0.1-next.52...core-v0.0.1-next.53) (2025-05-01)
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
### Features
|
|
57
|
+
|
|
58
|
+
* async cache don't cache failures unless requested ([658ec4b](https://github.com/twinfoundation/framework/commit/658ec4b67a58a075de4702a3886d151e25ad3ddc))
|
|
59
|
+
|
|
60
|
+
## [0.0.1-next.52](https://github.com/twinfoundation/framework/compare/core-v0.0.1-next.51...core-v0.0.1-next.52) (2025-04-17)
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
### Features
|
|
64
|
+
|
|
65
|
+
* use new shared store mechanism ([#131](https://github.com/twinfoundation/framework/issues/131)) ([934385b](https://github.com/twinfoundation/framework/commit/934385b2fbaf9f5c00a505ebf9d093bd5a425f55))
|
|
66
|
+
|
|
67
|
+
## [0.0.1-next.51](https://github.com/twinfoundation/framework/compare/core-v0.0.1-next.50...core-v0.0.1-next.51) (2025-03-27)
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
### Features
|
|
71
|
+
|
|
72
|
+
* simplify async set ([#121](https://github.com/twinfoundation/framework/issues/121)) ([2693c32](https://github.com/twinfoundation/framework/commit/2693c325266fd1a0aede6f1336c8b254c981a9ca))
|
|
73
|
+
|
|
74
|
+
## [0.0.1-next.50](https://github.com/twinfoundation/framework/compare/core-v0.0.1-next.49...core-v0.0.1-next.50) (2025-03-26)
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
### Features
|
|
78
|
+
|
|
79
|
+
* add set method for async caches ([ba34b55](https://github.com/twinfoundation/framework/commit/ba34b55e651ad56ab8fc59e139e4af631c19cda0))
|
|
80
|
+
|
|
81
|
+
## 0.0.1-next.49
|
|
4
82
|
|
|
5
83
|
- Initial Release
|
|
@@ -8,37 +8,45 @@ Class to handle errors which are triggered by data already existing.
|
|
|
8
8
|
|
|
9
9
|
## Constructors
|
|
10
10
|
|
|
11
|
-
###
|
|
11
|
+
### Constructor
|
|
12
12
|
|
|
13
|
-
> **new AlreadyExistsError**(`source`, `message`, `existingId
|
|
13
|
+
> **new AlreadyExistsError**(`source`, `message`, `existingId?`, `inner?`): `AlreadyExistsError`
|
|
14
14
|
|
|
15
15
|
Create a new instance of AlreadyExistsError.
|
|
16
16
|
|
|
17
17
|
#### Parameters
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
##### source
|
|
20
|
+
|
|
21
|
+
`string`
|
|
20
22
|
|
|
21
23
|
The source of the error.
|
|
22
24
|
|
|
23
|
-
|
|
25
|
+
##### message
|
|
26
|
+
|
|
27
|
+
`string`
|
|
24
28
|
|
|
25
29
|
The message as a code.
|
|
26
30
|
|
|
27
|
-
|
|
31
|
+
##### existingId?
|
|
32
|
+
|
|
33
|
+
`string`
|
|
28
34
|
|
|
29
35
|
The id for the item.
|
|
30
36
|
|
|
31
|
-
|
|
37
|
+
##### inner?
|
|
38
|
+
|
|
39
|
+
`unknown`
|
|
32
40
|
|
|
33
41
|
The inner error if we have wrapped another error.
|
|
34
42
|
|
|
35
43
|
#### Returns
|
|
36
44
|
|
|
37
|
-
|
|
45
|
+
`AlreadyExistsError`
|
|
38
46
|
|
|
39
47
|
#### Overrides
|
|
40
48
|
|
|
41
|
-
[`BaseError`](BaseError.md).[`constructor`](BaseError.md#
|
|
49
|
+
[`BaseError`](BaseError.md).[`constructor`](BaseError.md#constructor)
|
|
42
50
|
|
|
43
51
|
## Properties
|
|
44
52
|
|
|
@@ -70,7 +78,7 @@ Any additional information for the error.
|
|
|
70
78
|
|
|
71
79
|
#### Index Signature
|
|
72
80
|
|
|
73
|
-
|
|
81
|
+
\[`id`: `string`\]: `unknown`
|
|
74
82
|
|
|
75
83
|
#### Inherited from
|
|
76
84
|
|
|
@@ -98,7 +106,9 @@ Construct an error from an existing one.
|
|
|
98
106
|
|
|
99
107
|
#### Parameters
|
|
100
108
|
|
|
101
|
-
|
|
109
|
+
##### err
|
|
110
|
+
|
|
111
|
+
`unknown`
|
|
102
112
|
|
|
103
113
|
The existing error.
|
|
104
114
|
|
|
@@ -122,7 +132,9 @@ Flatten an error tree.
|
|
|
122
132
|
|
|
123
133
|
#### Parameters
|
|
124
134
|
|
|
125
|
-
|
|
135
|
+
##### err
|
|
136
|
+
|
|
137
|
+
`unknown`
|
|
126
138
|
|
|
127
139
|
The starting error.
|
|
128
140
|
|
|
@@ -146,10 +158,12 @@ Expand an error tree.
|
|
|
146
158
|
|
|
147
159
|
#### Parameters
|
|
148
160
|
|
|
149
|
-
|
|
161
|
+
##### errors
|
|
150
162
|
|
|
151
163
|
The list of errors to expand.
|
|
152
164
|
|
|
165
|
+
`undefined` | [`IError`](../interfaces/IError.md)[]
|
|
166
|
+
|
|
153
167
|
#### Returns
|
|
154
168
|
|
|
155
169
|
`undefined` \| [`IError`](../interfaces/IError.md)
|
|
@@ -170,14 +184,18 @@ Test to see if the error has the specified error name.
|
|
|
170
184
|
|
|
171
185
|
#### Parameters
|
|
172
186
|
|
|
173
|
-
|
|
187
|
+
##### error
|
|
188
|
+
|
|
189
|
+
`unknown`
|
|
174
190
|
|
|
175
191
|
The error to test.
|
|
176
192
|
|
|
177
|
-
|
|
193
|
+
##### name
|
|
178
194
|
|
|
179
195
|
The name to check for.
|
|
180
196
|
|
|
197
|
+
`string` | `RegExp`
|
|
198
|
+
|
|
181
199
|
#### Returns
|
|
182
200
|
|
|
183
201
|
`error is BaseError`
|
|
@@ -198,14 +216,18 @@ Test to see if the error has the specified error message.
|
|
|
198
216
|
|
|
199
217
|
#### Parameters
|
|
200
218
|
|
|
201
|
-
|
|
219
|
+
##### error
|
|
220
|
+
|
|
221
|
+
`unknown`
|
|
202
222
|
|
|
203
223
|
The error to test.
|
|
204
224
|
|
|
205
|
-
|
|
225
|
+
##### message
|
|
206
226
|
|
|
207
227
|
The message to check for.
|
|
208
228
|
|
|
229
|
+
`string` | `RegExp`
|
|
230
|
+
|
|
209
231
|
#### Returns
|
|
210
232
|
|
|
211
233
|
`error is BaseError`
|
|
@@ -226,14 +248,18 @@ Test to see if the error has the specified error code.
|
|
|
226
248
|
|
|
227
249
|
#### Parameters
|
|
228
250
|
|
|
229
|
-
|
|
251
|
+
##### error
|
|
252
|
+
|
|
253
|
+
`unknown`
|
|
230
254
|
|
|
231
255
|
The error to test.
|
|
232
256
|
|
|
233
|
-
|
|
257
|
+
##### code
|
|
234
258
|
|
|
235
259
|
The code to check for.
|
|
236
260
|
|
|
261
|
+
`string` | `RegExp`
|
|
262
|
+
|
|
237
263
|
#### Returns
|
|
238
264
|
|
|
239
265
|
`boolean`
|
|
@@ -254,14 +280,18 @@ Test to see if any of the errors or children have the given error name.
|
|
|
254
280
|
|
|
255
281
|
#### Parameters
|
|
256
282
|
|
|
257
|
-
|
|
283
|
+
##### error
|
|
284
|
+
|
|
285
|
+
`unknown`
|
|
258
286
|
|
|
259
287
|
The error to test.
|
|
260
288
|
|
|
261
|
-
|
|
289
|
+
##### name
|
|
262
290
|
|
|
263
291
|
The name to check for.
|
|
264
292
|
|
|
293
|
+
`string` | `RegExp`
|
|
294
|
+
|
|
265
295
|
#### Returns
|
|
266
296
|
|
|
267
297
|
`error is BaseError`
|
|
@@ -282,14 +312,18 @@ Test to see if any of the errors or children have the given error message.
|
|
|
282
312
|
|
|
283
313
|
#### Parameters
|
|
284
314
|
|
|
285
|
-
|
|
315
|
+
##### error
|
|
316
|
+
|
|
317
|
+
`unknown`
|
|
286
318
|
|
|
287
319
|
The error to test.
|
|
288
320
|
|
|
289
|
-
|
|
321
|
+
##### message
|
|
290
322
|
|
|
291
323
|
The message to check for.
|
|
292
324
|
|
|
325
|
+
`string` | `RegExp`
|
|
326
|
+
|
|
293
327
|
#### Returns
|
|
294
328
|
|
|
295
329
|
`error is BaseError`
|
|
@@ -310,11 +344,15 @@ Test to see if any of the errors or children are from a specific class.
|
|
|
310
344
|
|
|
311
345
|
#### Parameters
|
|
312
346
|
|
|
313
|
-
|
|
347
|
+
##### error
|
|
348
|
+
|
|
349
|
+
`unknown`
|
|
314
350
|
|
|
315
351
|
The error to test.
|
|
316
352
|
|
|
317
|
-
|
|
353
|
+
##### cls
|
|
354
|
+
|
|
355
|
+
`string`
|
|
318
356
|
|
|
319
357
|
The class to check for.
|
|
320
358
|
|
|
@@ -338,14 +376,18 @@ Test to see if any of the errors or children have the given error code.
|
|
|
338
376
|
|
|
339
377
|
#### Parameters
|
|
340
378
|
|
|
341
|
-
|
|
379
|
+
##### error
|
|
380
|
+
|
|
381
|
+
`unknown`
|
|
342
382
|
|
|
343
383
|
The error to test.
|
|
344
384
|
|
|
345
|
-
|
|
385
|
+
##### code
|
|
346
386
|
|
|
347
387
|
The code to check for.
|
|
348
388
|
|
|
389
|
+
`string` | `RegExp`
|
|
390
|
+
|
|
349
391
|
#### Returns
|
|
350
392
|
|
|
351
393
|
`error is BaseError`
|
|
@@ -360,10 +402,18 @@ True if the error has the name.
|
|
|
360
402
|
|
|
361
403
|
### toJsonObject()
|
|
362
404
|
|
|
363
|
-
> **toJsonObject**(): [`IError`](../interfaces/IError.md)
|
|
405
|
+
> **toJsonObject**(`includeStackTrace?`): [`IError`](../interfaces/IError.md)
|
|
364
406
|
|
|
365
407
|
Serialize the error to the error model.
|
|
366
408
|
|
|
409
|
+
#### Parameters
|
|
410
|
+
|
|
411
|
+
##### includeStackTrace?
|
|
412
|
+
|
|
413
|
+
`boolean`
|
|
414
|
+
|
|
415
|
+
Whether to include the error stack in the model, defaults to false.
|
|
416
|
+
|
|
367
417
|
#### Returns
|
|
368
418
|
|
|
369
419
|
[`IError`](../interfaces/IError.md)
|
|
@@ -4,13 +4,13 @@ Class to help with arrays.
|
|
|
4
4
|
|
|
5
5
|
## Constructors
|
|
6
6
|
|
|
7
|
-
###
|
|
7
|
+
### Constructor
|
|
8
8
|
|
|
9
|
-
> **new ArrayHelper**():
|
|
9
|
+
> **new ArrayHelper**(): `ArrayHelper`
|
|
10
10
|
|
|
11
11
|
#### Returns
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
`ArrayHelper`
|
|
14
14
|
|
|
15
15
|
## Methods
|
|
16
16
|
|
|
@@ -22,11 +22,15 @@ Do the two arrays match.
|
|
|
22
22
|
|
|
23
23
|
#### Parameters
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
##### arr1
|
|
26
|
+
|
|
27
|
+
`unknown`
|
|
26
28
|
|
|
27
29
|
The first array.
|
|
28
30
|
|
|
29
|
-
|
|
31
|
+
##### arr2
|
|
32
|
+
|
|
33
|
+
`unknown`
|
|
30
34
|
|
|
31
35
|
The second array.
|
|
32
36
|
|
|
@@ -35,3 +39,73 @@ The second array.
|
|
|
35
39
|
`boolean`
|
|
36
40
|
|
|
37
41
|
True if both arrays are empty of have the same values.
|
|
42
|
+
|
|
43
|
+
***
|
|
44
|
+
|
|
45
|
+
### fromObjectOrArray()
|
|
46
|
+
|
|
47
|
+
Convert an object or array to an array.
|
|
48
|
+
|
|
49
|
+
#### Param
|
|
50
|
+
|
|
51
|
+
The object or array to convert.
|
|
52
|
+
|
|
53
|
+
#### Call Signature
|
|
54
|
+
|
|
55
|
+
> `static` **fromObjectOrArray**\<`T`\>(`value`): `undefined`
|
|
56
|
+
|
|
57
|
+
Convert an object or array to an array.
|
|
58
|
+
|
|
59
|
+
##### Type Parameters
|
|
60
|
+
|
|
61
|
+
###### T
|
|
62
|
+
|
|
63
|
+
`T` = `unknown`
|
|
64
|
+
|
|
65
|
+
##### Parameters
|
|
66
|
+
|
|
67
|
+
###### value
|
|
68
|
+
|
|
69
|
+
`undefined`
|
|
70
|
+
|
|
71
|
+
The object or array to convert.
|
|
72
|
+
|
|
73
|
+
##### Returns
|
|
74
|
+
|
|
75
|
+
`undefined`
|
|
76
|
+
|
|
77
|
+
The array.
|
|
78
|
+
|
|
79
|
+
##### Param
|
|
80
|
+
|
|
81
|
+
The object or array to convert.
|
|
82
|
+
|
|
83
|
+
#### Call Signature
|
|
84
|
+
|
|
85
|
+
> `static` **fromObjectOrArray**\<`T`\>(`value`): `T`[]
|
|
86
|
+
|
|
87
|
+
Convert an object or array to an array.
|
|
88
|
+
|
|
89
|
+
##### Type Parameters
|
|
90
|
+
|
|
91
|
+
###### T
|
|
92
|
+
|
|
93
|
+
`T` = `unknown`
|
|
94
|
+
|
|
95
|
+
##### Parameters
|
|
96
|
+
|
|
97
|
+
###### value
|
|
98
|
+
|
|
99
|
+
[`ObjectOrArray`](../type-aliases/ObjectOrArray.md)\<`T`\>
|
|
100
|
+
|
|
101
|
+
The object or array to convert.
|
|
102
|
+
|
|
103
|
+
##### Returns
|
|
104
|
+
|
|
105
|
+
`T`[]
|
|
106
|
+
|
|
107
|
+
The array.
|
|
108
|
+
|
|
109
|
+
##### Param
|
|
110
|
+
|
|
111
|
+
The object or array to convert.
|
|
@@ -4,40 +4,54 @@ Cache the results from asynchronous requests.
|
|
|
4
4
|
|
|
5
5
|
## Constructors
|
|
6
6
|
|
|
7
|
-
###
|
|
7
|
+
### Constructor
|
|
8
8
|
|
|
9
|
-
> **new AsyncCache**():
|
|
9
|
+
> **new AsyncCache**(): `AsyncCache`
|
|
10
10
|
|
|
11
11
|
#### Returns
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
`AsyncCache`
|
|
14
14
|
|
|
15
15
|
## Methods
|
|
16
16
|
|
|
17
17
|
### exec()
|
|
18
18
|
|
|
19
|
-
> `static` **exec**\<`T`\>(`key`, `ttlMs`, `requestMethod`): `undefined` \| `Promise`\<`T`\>
|
|
19
|
+
> `static` **exec**\<`T`\>(`key`, `ttlMs`, `requestMethod`, `cacheFailures?`): `undefined` \| `Promise`\<`T`\>
|
|
20
20
|
|
|
21
21
|
Execute an async request and cache the result.
|
|
22
22
|
|
|
23
23
|
#### Type Parameters
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
##### T
|
|
26
|
+
|
|
27
|
+
`T` = `unknown`
|
|
26
28
|
|
|
27
29
|
#### Parameters
|
|
28
30
|
|
|
29
|
-
|
|
31
|
+
##### key
|
|
32
|
+
|
|
33
|
+
`string`
|
|
30
34
|
|
|
31
35
|
The key for the entry in the cache.
|
|
32
36
|
|
|
33
|
-
|
|
37
|
+
##### ttlMs
|
|
34
38
|
|
|
35
39
|
The TTL of the entry in the cache.
|
|
36
40
|
|
|
37
|
-
|
|
41
|
+
`undefined` | `number`
|
|
42
|
+
|
|
43
|
+
##### requestMethod
|
|
44
|
+
|
|
45
|
+
() => `Promise`\<`T`\>
|
|
38
46
|
|
|
39
47
|
The method to call if not cached.
|
|
40
48
|
|
|
49
|
+
##### cacheFailures?
|
|
50
|
+
|
|
51
|
+
`boolean`
|
|
52
|
+
|
|
53
|
+
Cache failure results, defaults to false.
|
|
54
|
+
|
|
41
55
|
#### Returns
|
|
42
56
|
|
|
43
57
|
`undefined` \| `Promise`\<`T`\>
|
|
@@ -54,11 +68,15 @@ Get an entry from the cache.
|
|
|
54
68
|
|
|
55
69
|
#### Type Parameters
|
|
56
70
|
|
|
57
|
-
|
|
71
|
+
##### T
|
|
72
|
+
|
|
73
|
+
`T` = `unknown`
|
|
58
74
|
|
|
59
75
|
#### Parameters
|
|
60
76
|
|
|
61
|
-
|
|
77
|
+
##### key
|
|
78
|
+
|
|
79
|
+
`string`
|
|
62
80
|
|
|
63
81
|
The key to get from the cache.
|
|
64
82
|
|
|
@@ -70,6 +88,46 @@ The item from the cache if it exists.
|
|
|
70
88
|
|
|
71
89
|
***
|
|
72
90
|
|
|
91
|
+
### set()
|
|
92
|
+
|
|
93
|
+
> `static` **set**\<`T`\>(`key`, `value`, `ttlMs?`): `Promise`\<`void`\>
|
|
94
|
+
|
|
95
|
+
Set an entry into the cache.
|
|
96
|
+
|
|
97
|
+
#### Type Parameters
|
|
98
|
+
|
|
99
|
+
##### T
|
|
100
|
+
|
|
101
|
+
`T` = `unknown`
|
|
102
|
+
|
|
103
|
+
#### Parameters
|
|
104
|
+
|
|
105
|
+
##### key
|
|
106
|
+
|
|
107
|
+
`string`
|
|
108
|
+
|
|
109
|
+
The key to set in the cache.
|
|
110
|
+
|
|
111
|
+
##### value
|
|
112
|
+
|
|
113
|
+
`T`
|
|
114
|
+
|
|
115
|
+
The value to set in the cache.
|
|
116
|
+
|
|
117
|
+
##### ttlMs?
|
|
118
|
+
|
|
119
|
+
`number`
|
|
120
|
+
|
|
121
|
+
The TTL of the entry in the cache in ms, defaults to 1s.
|
|
122
|
+
|
|
123
|
+
#### Returns
|
|
124
|
+
|
|
125
|
+
`Promise`\<`void`\>
|
|
126
|
+
|
|
127
|
+
Nothing.
|
|
128
|
+
|
|
129
|
+
***
|
|
130
|
+
|
|
73
131
|
### remove()
|
|
74
132
|
|
|
75
133
|
> `static` **remove**(`key`): `void`
|
|
@@ -78,7 +136,9 @@ Remove an entry from the cache.
|
|
|
78
136
|
|
|
79
137
|
#### Parameters
|
|
80
138
|
|
|
81
|
-
|
|
139
|
+
##### key
|
|
140
|
+
|
|
141
|
+
`string`
|
|
82
142
|
|
|
83
143
|
The key to remove from the cache.
|
|
84
144
|
|
|
@@ -90,13 +150,15 @@ The key to remove from the cache.
|
|
|
90
150
|
|
|
91
151
|
### clearCache()
|
|
92
152
|
|
|
93
|
-
> `static` **clearCache**(`prefix
|
|
153
|
+
> `static` **clearCache**(`prefix?`): `void`
|
|
94
154
|
|
|
95
155
|
Clear the cache.
|
|
96
156
|
|
|
97
157
|
#### Parameters
|
|
98
158
|
|
|
99
|
-
|
|
159
|
+
##### prefix?
|
|
160
|
+
|
|
161
|
+
`string`
|
|
100
162
|
|
|
101
163
|
Optional prefix to clear only entries with that prefix.
|
|
102
164
|
|
|
@@ -4,13 +4,13 @@ Class to help with base63 Encoding/Decoding.
|
|
|
4
4
|
|
|
5
5
|
## Constructors
|
|
6
6
|
|
|
7
|
-
###
|
|
7
|
+
### Constructor
|
|
8
8
|
|
|
9
|
-
> **new Base32**():
|
|
9
|
+
> **new Base32**(): `Base32`
|
|
10
10
|
|
|
11
11
|
#### Returns
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
`Base32`
|
|
14
14
|
|
|
15
15
|
## Methods
|
|
16
16
|
|
|
@@ -22,7 +22,9 @@ Convert the base 32 string to a byte array.
|
|
|
22
22
|
|
|
23
23
|
#### Parameters
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
##### base32
|
|
26
|
+
|
|
27
|
+
`string`
|
|
26
28
|
|
|
27
29
|
The base32 string to convert.
|
|
28
30
|
|
|
@@ -46,7 +48,9 @@ Convert a byte array to base 32.
|
|
|
46
48
|
|
|
47
49
|
#### Parameters
|
|
48
50
|
|
|
49
|
-
|
|
51
|
+
##### bytes
|
|
52
|
+
|
|
53
|
+
`Uint8Array`
|
|
50
54
|
|
|
51
55
|
The byte array to convert.
|
|
52
56
|
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# Class: Base58
|
|
2
|
+
|
|
3
|
+
Class to help with base58 Encoding/Decoding.
|
|
4
|
+
|
|
5
|
+
## Constructors
|
|
6
|
+
|
|
7
|
+
### Constructor
|
|
8
|
+
|
|
9
|
+
> **new Base58**(): `Base58`
|
|
10
|
+
|
|
11
|
+
#### Returns
|
|
12
|
+
|
|
13
|
+
`Base58`
|
|
14
|
+
|
|
15
|
+
## Methods
|
|
16
|
+
|
|
17
|
+
### decode()
|
|
18
|
+
|
|
19
|
+
> `static` **decode**(`base58`): `Uint8Array`
|
|
20
|
+
|
|
21
|
+
Convert the base 58 string to a byte array.
|
|
22
|
+
|
|
23
|
+
#### Parameters
|
|
24
|
+
|
|
25
|
+
##### base58
|
|
26
|
+
|
|
27
|
+
`string`
|
|
28
|
+
|
|
29
|
+
The base58 string to convert.
|
|
30
|
+
|
|
31
|
+
#### Returns
|
|
32
|
+
|
|
33
|
+
`Uint8Array`
|
|
34
|
+
|
|
35
|
+
The byte array.
|
|
36
|
+
|
|
37
|
+
#### Throws
|
|
38
|
+
|
|
39
|
+
If the input string contains a character not in the Base58 alphabet.
|
|
40
|
+
|
|
41
|
+
***
|
|
42
|
+
|
|
43
|
+
### encode()
|
|
44
|
+
|
|
45
|
+
> `static` **encode**(`bytes`): `string`
|
|
46
|
+
|
|
47
|
+
Convert a byte array to base 58.
|
|
48
|
+
|
|
49
|
+
#### Parameters
|
|
50
|
+
|
|
51
|
+
##### bytes
|
|
52
|
+
|
|
53
|
+
`Uint8Array`
|
|
54
|
+
|
|
55
|
+
The byte array to encode.
|
|
56
|
+
|
|
57
|
+
#### Returns
|
|
58
|
+
|
|
59
|
+
`string`
|
|
60
|
+
|
|
61
|
+
The data as base58 string.
|