@twin.org/core 0.0.1-next.9 → 0.0.2-next.10
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 +2266 -1470
- package/dist/esm/index.mjs +2263 -1471
- package/dist/types/errors/alreadyExistsError.d.ts +2 -2
- package/dist/types/errors/baseError.d.ts +25 -5
- package/dist/types/errors/conflictError.d.ts +2 -2
- package/dist/types/errors/generalError.d.ts +2 -2
- package/dist/types/errors/notFoundError.d.ts +2 -2
- package/dist/types/errors/notSupportedError.d.ts +2 -2
- package/dist/types/errors/unauthorizedError.d.ts +2 -2
- package/dist/types/errors/unprocessableError.d.ts +2 -2
- package/dist/types/factories/factory.d.ts +21 -2
- 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 +5 -4
- package/dist/types/helpers/jsonHelper.d.ts +30 -0
- package/dist/types/helpers/objectHelper.d.ts +25 -0
- package/dist/types/helpers/uint8ArrayHelper.d.ts +11 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/types/models/IComponent.d.ts +6 -6
- package/dist/types/models/IError.d.ts +2 -2
- 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/guards.d.ts +35 -0
- package/dist/types/utils/is.d.ts +18 -0
- package/dist/types/utils/sharedStore.d.ts +23 -0
- package/dist/types/utils/validation.d.ts +2 -0
- package/docs/changelog.md +442 -1
- package/docs/reference/classes/AlreadyExistsError.md +166 -32
- package/docs/reference/classes/ArrayHelper.md +71 -5
- package/docs/reference/classes/AsyncCache.md +75 -13
- package/docs/reference/classes/Base32.md +9 -5
- package/docs/reference/classes/Base58.md +9 -5
- package/docs/reference/classes/Base64.md +12 -6
- package/docs/reference/classes/Base64Url.md +9 -5
- package/docs/reference/classes/BaseError.md +160 -34
- 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 +169 -33
- package/docs/reference/classes/Converter.md +72 -28
- package/docs/reference/classes/EnvHelper.md +45 -0
- package/docs/reference/classes/ErrorHelper.md +22 -10
- package/docs/reference/classes/Factory.md +96 -18
- package/docs/reference/classes/FilenameHelper.md +6 -4
- package/docs/reference/classes/GeneralError.md +164 -32
- package/docs/reference/classes/GuardError.md +168 -32
- 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 +207 -51
- package/docs/reference/classes/JsonHelper.md +146 -10
- package/docs/reference/classes/NotFoundError.md +166 -32
- package/docs/reference/classes/NotImplementedError.md +159 -29
- package/docs/reference/classes/NotSupportedError.md +163 -31
- package/docs/reference/classes/ObjectHelper.md +197 -39
- 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 +163 -31
- package/docs/reference/classes/UnprocessableError.md +164 -32
- 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 +162 -30
- package/docs/reference/index.md +7 -0
- package/docs/reference/interfaces/IComponent.md +21 -11
- package/docs/reference/interfaces/IError.md +4 -4
- 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 +2 -2
- package/locales/en.json +14 -1
- package/package.json +7 -7
|
@@ -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?`, `cause?`): `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
|
+
##### cause?
|
|
32
38
|
|
|
33
|
-
|
|
39
|
+
`unknown`
|
|
40
|
+
|
|
41
|
+
The cause of the 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
|
|
|
@@ -78,15 +86,15 @@ Any additional information for the error.
|
|
|
78
86
|
|
|
79
87
|
***
|
|
80
88
|
|
|
81
|
-
###
|
|
89
|
+
### cause?
|
|
82
90
|
|
|
83
|
-
> `optional` **
|
|
91
|
+
> `optional` **cause**: [`IError`](../interfaces/IError.md)
|
|
84
92
|
|
|
85
|
-
The
|
|
93
|
+
The cause of the error.
|
|
86
94
|
|
|
87
95
|
#### Inherited from
|
|
88
96
|
|
|
89
|
-
[`BaseError`](BaseError.md).[`
|
|
97
|
+
[`BaseError`](BaseError.md).[`cause`](BaseError.md#cause)
|
|
90
98
|
|
|
91
99
|
## Methods
|
|
92
100
|
|
|
@@ -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`
|
|
@@ -358,12 +400,104 @@ True if the error has the name.
|
|
|
358
400
|
|
|
359
401
|
***
|
|
360
402
|
|
|
403
|
+
### isEmpty()
|
|
404
|
+
|
|
405
|
+
> `static` **isEmpty**(`err`): `boolean`
|
|
406
|
+
|
|
407
|
+
Is the error empty, i.e. does it have no message, source, properties, or cause?
|
|
408
|
+
|
|
409
|
+
#### Parameters
|
|
410
|
+
|
|
411
|
+
##### err
|
|
412
|
+
|
|
413
|
+
[`IError`](../interfaces/IError.md)
|
|
414
|
+
|
|
415
|
+
The error to check for being empty.
|
|
416
|
+
|
|
417
|
+
#### Returns
|
|
418
|
+
|
|
419
|
+
`boolean`
|
|
420
|
+
|
|
421
|
+
True if the error is empty.
|
|
422
|
+
|
|
423
|
+
#### Inherited from
|
|
424
|
+
|
|
425
|
+
[`BaseError`](BaseError.md).[`isEmpty`](BaseError.md#isempty)
|
|
426
|
+
|
|
427
|
+
***
|
|
428
|
+
|
|
429
|
+
### isAggregateError()
|
|
430
|
+
|
|
431
|
+
> `static` **isAggregateError**(`err`): `err is AggregateError`
|
|
432
|
+
|
|
433
|
+
Is the error an aggregate error.
|
|
434
|
+
|
|
435
|
+
#### Parameters
|
|
436
|
+
|
|
437
|
+
##### err
|
|
438
|
+
|
|
439
|
+
`unknown`
|
|
440
|
+
|
|
441
|
+
The error to check for being an aggregate error.
|
|
442
|
+
|
|
443
|
+
#### Returns
|
|
444
|
+
|
|
445
|
+
`err is AggregateError`
|
|
446
|
+
|
|
447
|
+
True if the error is an aggregate error.
|
|
448
|
+
|
|
449
|
+
#### Inherited from
|
|
450
|
+
|
|
451
|
+
[`BaseError`](BaseError.md).[`isAggregateError`](BaseError.md#isaggregateerror)
|
|
452
|
+
|
|
453
|
+
***
|
|
454
|
+
|
|
455
|
+
### fromAggregate()
|
|
456
|
+
|
|
457
|
+
> `static` **fromAggregate**(`err`, `includeStackTrace?`): [`IError`](../interfaces/IError.md)[]
|
|
458
|
+
|
|
459
|
+
Convert the aggregate error to an array of errors.
|
|
460
|
+
|
|
461
|
+
#### Parameters
|
|
462
|
+
|
|
463
|
+
##### err
|
|
464
|
+
|
|
465
|
+
`unknown`
|
|
466
|
+
|
|
467
|
+
The error to convert.
|
|
468
|
+
|
|
469
|
+
##### includeStackTrace?
|
|
470
|
+
|
|
471
|
+
`boolean`
|
|
472
|
+
|
|
473
|
+
Whether to include the error stack in the model, defaults to false.
|
|
474
|
+
|
|
475
|
+
#### Returns
|
|
476
|
+
|
|
477
|
+
[`IError`](../interfaces/IError.md)[]
|
|
478
|
+
|
|
479
|
+
The array of errors.
|
|
480
|
+
|
|
481
|
+
#### Inherited from
|
|
482
|
+
|
|
483
|
+
[`BaseError`](BaseError.md).[`fromAggregate`](BaseError.md#fromaggregate)
|
|
484
|
+
|
|
485
|
+
***
|
|
486
|
+
|
|
361
487
|
### toJsonObject()
|
|
362
488
|
|
|
363
|
-
> **toJsonObject**(): [`IError`](../interfaces/IError.md)
|
|
489
|
+
> **toJsonObject**(`includeStackTrace?`): [`IError`](../interfaces/IError.md)
|
|
364
490
|
|
|
365
491
|
Serialize the error to the error model.
|
|
366
492
|
|
|
493
|
+
#### Parameters
|
|
494
|
+
|
|
495
|
+
##### includeStackTrace?
|
|
496
|
+
|
|
497
|
+
`boolean`
|
|
498
|
+
|
|
499
|
+
Whether to include the error stack in the model, defaults to false.
|
|
500
|
+
|
|
367
501
|
#### Returns
|
|
368
502
|
|
|
369
503
|
[`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,65 @@ 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
|
+
#### Call Signature
|
|
80
|
+
|
|
81
|
+
> `static` **fromObjectOrArray**\<`T`\>(`value`): `T`[]
|
|
82
|
+
|
|
83
|
+
Convert an object or array to an array.
|
|
84
|
+
|
|
85
|
+
##### Type Parameters
|
|
86
|
+
|
|
87
|
+
###### T
|
|
88
|
+
|
|
89
|
+
`T` = `unknown`
|
|
90
|
+
|
|
91
|
+
##### Parameters
|
|
92
|
+
|
|
93
|
+
###### value
|
|
94
|
+
|
|
95
|
+
[`ObjectOrArray`](../type-aliases/ObjectOrArray.md)\<`T`\>
|
|
96
|
+
|
|
97
|
+
The object or array to convert.
|
|
98
|
+
|
|
99
|
+
##### Returns
|
|
100
|
+
|
|
101
|
+
`T`[]
|
|
102
|
+
|
|
103
|
+
The array.
|
|
@@ -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
|
|
|
@@ -4,13 +4,13 @@ Class to help with base58 Encoding/Decoding.
|
|
|
4
4
|
|
|
5
5
|
## Constructors
|
|
6
6
|
|
|
7
|
-
###
|
|
7
|
+
### Constructor
|
|
8
8
|
|
|
9
|
-
> **new Base58**():
|
|
9
|
+
> **new Base58**(): `Base58`
|
|
10
10
|
|
|
11
11
|
#### Returns
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
`Base58`
|
|
14
14
|
|
|
15
15
|
## Methods
|
|
16
16
|
|
|
@@ -22,7 +22,9 @@ Convert the base 58 string to a byte array.
|
|
|
22
22
|
|
|
23
23
|
#### Parameters
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
##### base58
|
|
26
|
+
|
|
27
|
+
`string`
|
|
26
28
|
|
|
27
29
|
The base58 string to convert.
|
|
28
30
|
|
|
@@ -46,7 +48,9 @@ Convert a byte array to base 58.
|
|
|
46
48
|
|
|
47
49
|
#### Parameters
|
|
48
50
|
|
|
49
|
-
|
|
51
|
+
##### bytes
|
|
52
|
+
|
|
53
|
+
`Uint8Array`
|
|
50
54
|
|
|
51
55
|
The byte array to encode.
|
|
52
56
|
|