@twin.org/core 0.0.3-next.21 → 0.0.3-next.23
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 -9
- package/dist/es/encoding/base32.js +1 -1
- package/dist/es/encoding/base32.js.map +1 -1
- package/dist/es/factories/factory.js +1 -13
- package/dist/es/factories/factory.js.map +1 -1
- package/dist/es/helpers/arrayHelper.js.map +1 -1
- package/dist/es/index.js +2 -1
- package/dist/es/index.js.map +1 -1
- package/dist/es/types/objectOrArray.js.map +1 -0
- package/dist/es/types/singleOccurrenceArray.js +2 -0
- package/dist/es/types/singleOccurrenceArray.js.map +1 -0
- package/dist/es/utils/guards.js.map +1 -1
- package/dist/types/encoding/base32.d.ts +1 -1
- package/dist/types/factories/factory.d.ts +1 -5
- package/dist/types/helpers/arrayHelper.d.ts +1 -1
- package/dist/types/index.d.ts +2 -1
- package/dist/types/types/singleOccurrenceArray.d.ts +9 -0
- package/dist/types/utils/guards.d.ts +1 -1
- package/docs/changelog.md +36 -1
- package/docs/examples.md +308 -1
- package/docs/reference/classes/AlreadyExistsError.md +18 -18
- package/docs/reference/classes/ArrayHelper.md +2 -2
- package/docs/reference/classes/AsyncCache.md +6 -6
- package/docs/reference/classes/Base32.md +4 -4
- package/docs/reference/classes/Base58.md +3 -3
- package/docs/reference/classes/Base64.md +4 -4
- package/docs/reference/classes/Base64Url.md +3 -3
- package/docs/reference/classes/BaseError.md +17 -17
- package/docs/reference/classes/BitString.md +6 -6
- package/docs/reference/classes/Coerce.md +11 -11
- package/docs/reference/classes/Compression.md +3 -3
- package/docs/reference/classes/ConflictError.md +18 -18
- package/docs/reference/classes/Converter.md +18 -18
- package/docs/reference/classes/EnvHelper.md +1 -1
- package/docs/reference/classes/ErrorHelper.md +3 -3
- package/docs/reference/classes/Factory.md +21 -31
- package/docs/reference/classes/FilenameHelper.md +1 -1
- package/docs/reference/classes/GeneralError.md +18 -18
- package/docs/reference/classes/GuardError.md +18 -18
- package/docs/reference/classes/Guards.md +31 -31
- package/docs/reference/classes/HexHelper.md +6 -6
- package/docs/reference/classes/I18n.md +14 -14
- package/docs/reference/classes/Is.md +40 -40
- package/docs/reference/classes/JsonHelper.md +8 -8
- package/docs/reference/classes/NotFoundError.md +18 -18
- package/docs/reference/classes/NotImplementedError.md +18 -18
- package/docs/reference/classes/NotSupportedError.md +18 -18
- package/docs/reference/classes/NumberHelper.md +2 -2
- package/docs/reference/classes/ObjectHelper.md +20 -20
- package/docs/reference/classes/RandomHelper.md +6 -6
- package/docs/reference/classes/SharedStore.md +3 -3
- package/docs/reference/classes/StringHelper.md +23 -23
- package/docs/reference/classes/Uint8ArrayHelper.md +1 -1
- package/docs/reference/classes/UnauthorizedError.md +18 -18
- package/docs/reference/classes/UnprocessableError.md +18 -18
- package/docs/reference/classes/Url.md +8 -8
- package/docs/reference/classes/Urn.md +22 -22
- package/docs/reference/classes/Validation.md +25 -25
- package/docs/reference/classes/ValidationError.md +18 -18
- package/docs/reference/index.md +2 -0
- package/docs/reference/interfaces/IComponent.md +4 -4
- package/docs/reference/interfaces/IError.md +6 -6
- package/docs/reference/interfaces/II18nShared.md +4 -4
- package/docs/reference/interfaces/IKeyValue.md +2 -2
- package/docs/reference/interfaces/ILabelledValue.md +2 -2
- package/docs/reference/interfaces/ILocale.md +2 -2
- package/docs/reference/interfaces/ILocalesIndex.md +1 -1
- package/docs/reference/interfaces/IPatchOperation.md +4 -4
- package/docs/reference/interfaces/IUrlParts.md +6 -6
- package/docs/reference/interfaces/IValidationFailure.md +3 -3
- package/docs/reference/type-aliases/SingleOccurrenceArray.md +15 -0
- package/docs/reference/type-aliases/SingleOccurrenceArrayDepthHelper.md +19 -0
- package/docs/reference/variables/CoerceType.md +10 -10
- package/docs/reference/variables/CompressionType.md +2 -2
- package/package.json +4 -4
- package/dist/es/models/objectOrArray.js.map +0 -1
- /package/dist/es/{models → types}/objectOrArray.js +0 -0
- /package/dist/types/{models → types}/objectOrArray.d.ts +0 -0
package/docs/examples.md
CHANGED
|
@@ -1 +1,308 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Core Examples
|
|
2
|
+
|
|
3
|
+
Use these snippets to validate input, transform data and handle errors consistently in shared runtime code.
|
|
4
|
+
|
|
5
|
+
## Is
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
import { Is } from '@twin.org/core';
|
|
9
|
+
|
|
10
|
+
console.log(Is.string('alpha')); // true
|
|
11
|
+
console.log(Is.number(42)); // true
|
|
12
|
+
console.log(Is.array(['a', 'b'])); // true
|
|
13
|
+
console.log(Is.objectValue({ id: 'u-1' })); // true
|
|
14
|
+
console.log(Is.boolean(false)); // true
|
|
15
|
+
console.log(Is.json('{"ok":true}')); // true
|
|
16
|
+
console.log(Is.email('dev@example.org')); // true
|
|
17
|
+
console.log(Is.dateTimeString('2026-03-09T11:32:00Z')); // true
|
|
18
|
+
console.log(Is.stringHex('aabbccdd')); // true
|
|
19
|
+
console.log(Is.uuidV7('019531ce-6f7d-7c08-a6f3-f6f7cf9f41b0')); // true
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Guards
|
|
23
|
+
|
|
24
|
+
```typescript
|
|
25
|
+
import { Guards } from '@twin.org/core';
|
|
26
|
+
import { nameof } from '@twin.org/nameof';
|
|
27
|
+
|
|
28
|
+
const name = 'Ari';
|
|
29
|
+
const profile = {
|
|
30
|
+
age: 31,
|
|
31
|
+
active: true
|
|
32
|
+
};
|
|
33
|
+
const createdAt = new Date('2026-03-09T10:00:00.000Z');
|
|
34
|
+
|
|
35
|
+
Guards.stringValue(this.CLASS_NAME, nameof(name), name);
|
|
36
|
+
Guards.objectValue(this.CLASS_NAME, nameof(profile), profile);
|
|
37
|
+
Guards.integer(this.CLASS_NAME, nameof(profile.age), profile.age);
|
|
38
|
+
Guards.boolean(this.CLASS_NAME, nameof(profile.active), profile.active);
|
|
39
|
+
Guards.date(this.CLASS_NAME, nameof(createdAt), createdAt);
|
|
40
|
+
|
|
41
|
+
console.log(name.toUpperCase()); // ARI
|
|
42
|
+
console.log(profile.age + 1); // 32
|
|
43
|
+
|
|
44
|
+
const amount = 'ten';
|
|
45
|
+
|
|
46
|
+
try {
|
|
47
|
+
Guards.number(this.CLASS_NAME, nameof(amount), amount);
|
|
48
|
+
} catch (error) {
|
|
49
|
+
if (error instanceof GuardError) {
|
|
50
|
+
console.log(error.message); // guard.number
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Validation
|
|
56
|
+
|
|
57
|
+
```typescript
|
|
58
|
+
import type { IValidationFailure } from '@twin.org/core';
|
|
59
|
+
import { Validation } from '@twin.org/core';
|
|
60
|
+
|
|
61
|
+
const failures: IValidationFailure[] = [];
|
|
62
|
+
|
|
63
|
+
Validation.stringValue('customer.name', 'Ari', failures, undefined, {
|
|
64
|
+
minLength: 2,
|
|
65
|
+
maxLength: 30
|
|
66
|
+
});
|
|
67
|
+
Validation.integer('customer.age', 31, failures, undefined, {
|
|
68
|
+
minValue: 18,
|
|
69
|
+
maxValue: 120
|
|
70
|
+
});
|
|
71
|
+
Validation.email('customer.email', 'customer@example.org', failures);
|
|
72
|
+
|
|
73
|
+
console.log(failures.length); // 0
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## ObjectHelper
|
|
77
|
+
|
|
78
|
+
```typescript
|
|
79
|
+
import { ObjectHelper } from '@twin.org/core';
|
|
80
|
+
|
|
81
|
+
const source = {
|
|
82
|
+
id: 'u-01',
|
|
83
|
+
profile: {
|
|
84
|
+
givenName: 'Ari'
|
|
85
|
+
},
|
|
86
|
+
tags: ['admin']
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
ObjectHelper.propertyGet(source, 'profile.givenName'); // 'Ari'
|
|
90
|
+
ObjectHelper.pick(source, ['id', 'tags']); // { id: 'u-01', tags: ['admin'] }
|
|
91
|
+
ObjectHelper.clone(source).id; // 'u-01'
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Converter
|
|
95
|
+
|
|
96
|
+
```typescript
|
|
97
|
+
import { Converter } from '@twin.org/core';
|
|
98
|
+
|
|
99
|
+
const bytes = Converter.utf8ToBytes('twin');
|
|
100
|
+
Converter.bytesToHex(bytes); // '7477696e'
|
|
101
|
+
Converter.bytesToBase64Url(bytes); // 'dHdpbg'
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## Coerce
|
|
105
|
+
|
|
106
|
+
```typescript
|
|
107
|
+
import { Coerce } from '@twin.org/core';
|
|
108
|
+
|
|
109
|
+
Coerce.integer('19'); // 19
|
|
110
|
+
Coerce.boolean('true'); // true
|
|
111
|
+
Coerce.dateTime('2026-03-09T11:32:00Z')?.toISOString(); // '2026-03-09T11:32:00.000Z'
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## StringHelper
|
|
115
|
+
|
|
116
|
+
```typescript
|
|
117
|
+
import { StringHelper } from '@twin.org/core';
|
|
118
|
+
|
|
119
|
+
StringHelper.kebabCase('OrderCreatedEvent'); // 'order-created-event'
|
|
120
|
+
StringHelper.camelCase('order-created-event'); // 'orderCreatedEvent'
|
|
121
|
+
StringHelper.words('PaymentReferenceId'); // ['Payment', 'Reference', 'Id']
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## Error Classes
|
|
125
|
+
|
|
126
|
+
```typescript
|
|
127
|
+
import {
|
|
128
|
+
AlreadyExistsError,
|
|
129
|
+
BaseError,
|
|
130
|
+
ConflictError,
|
|
131
|
+
GeneralError,
|
|
132
|
+
GuardError,
|
|
133
|
+
NotFoundError,
|
|
134
|
+
NotImplementedError,
|
|
135
|
+
NotSupportedError,
|
|
136
|
+
UnauthorizedError,
|
|
137
|
+
UnprocessableError,
|
|
138
|
+
ValidationError
|
|
139
|
+
} from '@twin.org/core';
|
|
140
|
+
|
|
141
|
+
const base = new BaseError(this.CLASS_NAME, 'baseUnexpectedFailure', { module: 'orders' });
|
|
142
|
+
new AlreadyExistsError(this.CLASS_NAME, 'alreadyExistsOrder', { orderId: 'o-1' });
|
|
143
|
+
new ConflictError(this.CLASS_NAME, 'conflictVersionMismatch', { expected: 3, actual: 2 });
|
|
144
|
+
new GeneralError(this.CLASS_NAME, 'generalUnexpectedFailure', { retryable: false });
|
|
145
|
+
new GuardError(this.CLASS_NAME, 'guardValidationFailed', { field: 'name' });
|
|
146
|
+
new NotFoundError(this.CLASS_NAME, 'notFoundOrder', { orderId: 'o-1' });
|
|
147
|
+
new NotImplementedError(this.CLASS_NAME, 'notImplementedFeature', {
|
|
148
|
+
feature: 'export'
|
|
149
|
+
});
|
|
150
|
+
new NotSupportedError(this.CLASS_NAME, 'notSupportedFormat', { format: 'xml' });
|
|
151
|
+
new UnauthorizedError(this.CLASS_NAME, 'unauthorizedInvalidToken', {
|
|
152
|
+
scope: 'orders:write'
|
|
153
|
+
});
|
|
154
|
+
new UnprocessableError(this.CLASS_NAME, 'unprocessableInvalidContent', { field: 'email' });
|
|
155
|
+
new ValidationError(this.CLASS_NAME, 'validationInputFailed', { failures: 2 });
|
|
156
|
+
base.toJsonObject().name; // 'BaseError'
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
## Factory
|
|
160
|
+
|
|
161
|
+
```typescript
|
|
162
|
+
import { Factory } from '@twin.org/core';
|
|
163
|
+
|
|
164
|
+
interface IHasher {
|
|
165
|
+
hash(value: string): string;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
class SimpleHasher implements IHasher {
|
|
169
|
+
public hash(value: string): string {
|
|
170
|
+
return `${value}-hash`;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
const factory = new Factory<IHasher>('hashers');
|
|
175
|
+
factory.register('simple', () => new SimpleHasher());
|
|
176
|
+
|
|
177
|
+
factory.create('simple').hash('abc'); // 'abc-hash'
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
## Encoding and Compression
|
|
181
|
+
|
|
182
|
+
```typescript
|
|
183
|
+
import { Base32, Base58, Base64, Base64Url, Compression, HexHelper } from '@twin.org/core';
|
|
184
|
+
|
|
185
|
+
const bytes = new Uint8Array([1, 2, 3, 4]);
|
|
186
|
+
|
|
187
|
+
Base32.encode(bytes);
|
|
188
|
+
Base58.encode(bytes);
|
|
189
|
+
Base64.encode(bytes);
|
|
190
|
+
Base64Url.encode(bytes);
|
|
191
|
+
Compression.compress(bytes, 'gzip');
|
|
192
|
+
HexHelper.addPrefix('aabbcc'); // '0xaabbcc'
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
## AsyncCache and SharedStore
|
|
196
|
+
|
|
197
|
+
```typescript
|
|
198
|
+
import { AsyncCache, SharedStore } from '@twin.org/core';
|
|
199
|
+
|
|
200
|
+
const cache = new AsyncCache<string, number>({ expirySeconds: 30 });
|
|
201
|
+
await cache.exec('invoice-1', async () => 4200); // 4200
|
|
202
|
+
|
|
203
|
+
SharedStore.set('region', 'eu-west-1');
|
|
204
|
+
SharedStore.get<string>('region'); // 'eu-west-1'
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
## RandomHelper and NumberHelper
|
|
208
|
+
|
|
209
|
+
```typescript
|
|
210
|
+
import { NumberHelper, RandomHelper } from '@twin.org/core';
|
|
211
|
+
|
|
212
|
+
NumberHelper.clamp(150, 0, 100); // 100
|
|
213
|
+
RandomHelper.generate(16).length; // 16
|
|
214
|
+
RandomHelper.generateUuidV7(); // 'xxxxxxxx-xxxx-7xxx-xxxx-xxxxxxxxxxxx'
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
## Url, Urn and BitString
|
|
218
|
+
|
|
219
|
+
```typescript
|
|
220
|
+
import { BitString, Url, Urn } from '@twin.org/core';
|
|
221
|
+
|
|
222
|
+
const url = Url.fromParts({
|
|
223
|
+
scheme: 'https',
|
|
224
|
+
host: 'example.org',
|
|
225
|
+
pathname: '/products'
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
url.toString(); // 'https://example.org/products'
|
|
229
|
+
Urn.fromValidString('urn:example:widget:123').namespaceMethod(); // 'example'
|
|
230
|
+
|
|
231
|
+
const bits = BitString.fromBits([1, 0, 1, 1]);
|
|
232
|
+
bits.getLength(); // 4
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
## JsonHelper
|
|
236
|
+
|
|
237
|
+
```typescript
|
|
238
|
+
import { JsonHelper } from '@twin.org/core';
|
|
239
|
+
|
|
240
|
+
const left = { id: 'u-1', active: true };
|
|
241
|
+
const right = { id: 'u-1', active: false };
|
|
242
|
+
|
|
243
|
+
const patch = JsonHelper.diff(left, right);
|
|
244
|
+
JsonHelper.patch(left, patch); // { id: 'u-1', active: false }
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
## ErrorHelper
|
|
248
|
+
|
|
249
|
+
```typescript
|
|
250
|
+
import { BaseError, ErrorHelper } from '@twin.org/core';
|
|
251
|
+
|
|
252
|
+
const error = new BaseError(this.CLASS_NAME, 'saveFailed', { entityId: 'u-1' });
|
|
253
|
+
const messages = ErrorHelper.formatErrors(error);
|
|
254
|
+
|
|
255
|
+
messages[0]; // 'saveFailed'
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
## Type Utilities
|
|
259
|
+
|
|
260
|
+
```typescript
|
|
261
|
+
import type { ObjectOrArray, SingleOccurrenceArray } from '@twin.org/core';
|
|
262
|
+
|
|
263
|
+
type IdOrIds = ObjectOrArray<string>;
|
|
264
|
+
|
|
265
|
+
const singleId: IdOrIds = 'id-1';
|
|
266
|
+
const manyIds: IdOrIds = ['id-1', 'id-2'];
|
|
267
|
+
|
|
268
|
+
const withOneNumber: SingleOccurrenceArray<string, number> = ['alpha', 7, 'beta'];
|
|
269
|
+
const numberOnly: SingleOccurrenceArray<string, number> = [7];
|
|
270
|
+
|
|
271
|
+
interface IFoo {
|
|
272
|
+
foo: boolean;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
interface IBar {
|
|
276
|
+
bar: string;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
const mixedObjects: SingleOccurrenceArray<IFoo, IBar> = [
|
|
280
|
+
{ foo: true },
|
|
281
|
+
{ bar: 'marker' },
|
|
282
|
+
{ foo: false }
|
|
283
|
+
];
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
## Array, Uint8Array, Filename and Env Helpers
|
|
287
|
+
|
|
288
|
+
```typescript
|
|
289
|
+
import { ArrayHelper, EnvHelper, FilenameHelper, Uint8ArrayHelper } from '@twin.org/core';
|
|
290
|
+
|
|
291
|
+
ArrayHelper.matches([1, 2, 3], [1, 2, 3]); // true
|
|
292
|
+
Uint8ArrayHelper.concat(new Uint8Array([1, 2]), new Uint8Array([3, 4]));
|
|
293
|
+
FilenameHelper.safeFilename('Q1 Report: Europe/West.csv'); // 'Q1-Report-Europe-West.csv'
|
|
294
|
+
EnvHelper.envToJson('API_KEY=abc\nLOG_LEVEL=debug'); // { API_KEY: 'abc', LOG_LEVEL: 'debug' }
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
## I18n
|
|
298
|
+
|
|
299
|
+
```typescript
|
|
300
|
+
import { I18n } from '@twin.org/core';
|
|
301
|
+
|
|
302
|
+
I18n.setLocale('en');
|
|
303
|
+
I18n.addDictionary('en', {
|
|
304
|
+
greeting: 'Hello {name}'
|
|
305
|
+
});
|
|
306
|
+
|
|
307
|
+
I18n.formatMessage('greeting', { name: 'Ari' }); // 'Hello Ari'
|
|
308
|
+
```
|
|
@@ -54,7 +54,7 @@ The cause of the error if we have wrapped another error.
|
|
|
54
54
|
|
|
55
55
|
## Properties
|
|
56
56
|
|
|
57
|
-
### CLASS\_NAME
|
|
57
|
+
### CLASS\_NAME {#class_name}
|
|
58
58
|
|
|
59
59
|
> `readonly` `static` **CLASS\_NAME**: `string`
|
|
60
60
|
|
|
@@ -62,7 +62,7 @@ Runtime name for the class.
|
|
|
62
62
|
|
|
63
63
|
***
|
|
64
64
|
|
|
65
|
-
### source?
|
|
65
|
+
### source? {#source}
|
|
66
66
|
|
|
67
67
|
> `optional` **source**: `string`
|
|
68
68
|
|
|
@@ -74,7 +74,7 @@ The source of the error.
|
|
|
74
74
|
|
|
75
75
|
***
|
|
76
76
|
|
|
77
|
-
### properties?
|
|
77
|
+
### properties? {#properties}
|
|
78
78
|
|
|
79
79
|
> `optional` **properties**: `object`
|
|
80
80
|
|
|
@@ -90,7 +90,7 @@ Any additional information for the error.
|
|
|
90
90
|
|
|
91
91
|
***
|
|
92
92
|
|
|
93
|
-
### cause?
|
|
93
|
+
### cause? {#cause}
|
|
94
94
|
|
|
95
95
|
> `optional` **cause**: [`IError`](../interfaces/IError.md)
|
|
96
96
|
|
|
@@ -102,7 +102,7 @@ The cause of the error.
|
|
|
102
102
|
|
|
103
103
|
## Methods
|
|
104
104
|
|
|
105
|
-
### fromError()
|
|
105
|
+
### fromError() {#fromerror}
|
|
106
106
|
|
|
107
107
|
> `static` **fromError**(`err`): [`BaseError`](BaseError.md)
|
|
108
108
|
|
|
@@ -128,7 +128,7 @@ The new instance.
|
|
|
128
128
|
|
|
129
129
|
***
|
|
130
130
|
|
|
131
|
-
### flatten()
|
|
131
|
+
### flatten() {#flatten}
|
|
132
132
|
|
|
133
133
|
> `static` **flatten**(`err`): [`IError`](../interfaces/IError.md)[]
|
|
134
134
|
|
|
@@ -154,7 +154,7 @@ The list of all internal errors.
|
|
|
154
154
|
|
|
155
155
|
***
|
|
156
156
|
|
|
157
|
-
### expand()
|
|
157
|
+
### expand() {#expand}
|
|
158
158
|
|
|
159
159
|
> `static` **expand**(`errors`): [`IError`](../interfaces/IError.md) \| `undefined`
|
|
160
160
|
|
|
@@ -180,7 +180,7 @@ The first level error.
|
|
|
180
180
|
|
|
181
181
|
***
|
|
182
182
|
|
|
183
|
-
### isErrorName()
|
|
183
|
+
### isErrorName() {#iserrorname}
|
|
184
184
|
|
|
185
185
|
> `static` **isErrorName**(`error`, `name`): `error is BaseError`
|
|
186
186
|
|
|
@@ -212,7 +212,7 @@ True if the error has the name.
|
|
|
212
212
|
|
|
213
213
|
***
|
|
214
214
|
|
|
215
|
-
### isErrorMessage()
|
|
215
|
+
### isErrorMessage() {#iserrormessage}
|
|
216
216
|
|
|
217
217
|
> `static` **isErrorMessage**(`error`, `message`): `error is BaseError`
|
|
218
218
|
|
|
@@ -244,7 +244,7 @@ True if the error has the name.
|
|
|
244
244
|
|
|
245
245
|
***
|
|
246
246
|
|
|
247
|
-
### isErrorCode()
|
|
247
|
+
### isErrorCode() {#iserrorcode}
|
|
248
248
|
|
|
249
249
|
> `static` **isErrorCode**(`error`, `code`): `boolean`
|
|
250
250
|
|
|
@@ -276,7 +276,7 @@ True if the error has the code.
|
|
|
276
276
|
|
|
277
277
|
***
|
|
278
278
|
|
|
279
|
-
### someErrorName()
|
|
279
|
+
### someErrorName() {#someerrorname}
|
|
280
280
|
|
|
281
281
|
> `static` **someErrorName**(`error`, `name`): `error is BaseError`
|
|
282
282
|
|
|
@@ -308,7 +308,7 @@ True if the error has the name.
|
|
|
308
308
|
|
|
309
309
|
***
|
|
310
310
|
|
|
311
|
-
### someErrorMessage()
|
|
311
|
+
### someErrorMessage() {#someerrormessage}
|
|
312
312
|
|
|
313
313
|
> `static` **someErrorMessage**(`error`, `message`): `error is BaseError`
|
|
314
314
|
|
|
@@ -340,7 +340,7 @@ True if the error has the name.
|
|
|
340
340
|
|
|
341
341
|
***
|
|
342
342
|
|
|
343
|
-
### someErrorClass()
|
|
343
|
+
### someErrorClass() {#someerrorclass}
|
|
344
344
|
|
|
345
345
|
> `static` **someErrorClass**(`error`, `cls`): `error is BaseError`
|
|
346
346
|
|
|
@@ -372,7 +372,7 @@ True if the error has the specific class.
|
|
|
372
372
|
|
|
373
373
|
***
|
|
374
374
|
|
|
375
|
-
### someErrorCode()
|
|
375
|
+
### someErrorCode() {#someerrorcode}
|
|
376
376
|
|
|
377
377
|
> `static` **someErrorCode**(`error`, `code`): `error is BaseError`
|
|
378
378
|
|
|
@@ -404,7 +404,7 @@ True if the error has the name.
|
|
|
404
404
|
|
|
405
405
|
***
|
|
406
406
|
|
|
407
|
-
### isEmpty()
|
|
407
|
+
### isEmpty() {#isempty}
|
|
408
408
|
|
|
409
409
|
> `static` **isEmpty**(`err`): `boolean`
|
|
410
410
|
|
|
@@ -430,7 +430,7 @@ True if the error is empty.
|
|
|
430
430
|
|
|
431
431
|
***
|
|
432
432
|
|
|
433
|
-
### isAggregateError()
|
|
433
|
+
### isAggregateError() {#isaggregateerror}
|
|
434
434
|
|
|
435
435
|
> `static` **isAggregateError**(`err`): `err is AggregateError`
|
|
436
436
|
|
|
@@ -456,7 +456,7 @@ True if the error is an aggregate error.
|
|
|
456
456
|
|
|
457
457
|
***
|
|
458
458
|
|
|
459
|
-
### fromAggregate()
|
|
459
|
+
### fromAggregate() {#fromaggregate}
|
|
460
460
|
|
|
461
461
|
> `static` **fromAggregate**(`err`, `includeStackTrace?`): [`IError`](../interfaces/IError.md)[]
|
|
462
462
|
|
|
@@ -488,7 +488,7 @@ The array of errors.
|
|
|
488
488
|
|
|
489
489
|
***
|
|
490
490
|
|
|
491
|
-
### toJsonObject()
|
|
491
|
+
### toJsonObject() {#tojsonobject}
|
|
492
492
|
|
|
493
493
|
> **toJsonObject**(`includeStackTrace?`): [`IError`](../interfaces/IError.md)
|
|
494
494
|
|
|
@@ -14,7 +14,7 @@ Class to help with arrays.
|
|
|
14
14
|
|
|
15
15
|
## Methods
|
|
16
16
|
|
|
17
|
-
### matches()
|
|
17
|
+
### matches() {#matches}
|
|
18
18
|
|
|
19
19
|
> `static` **matches**(`arr1`, `arr2`): `boolean`
|
|
20
20
|
|
|
@@ -42,7 +42,7 @@ True if both arrays are empty of have the same values.
|
|
|
42
42
|
|
|
43
43
|
***
|
|
44
44
|
|
|
45
|
-
### fromObjectOrArray()
|
|
45
|
+
### fromObjectOrArray() {#fromobjectorarray}
|
|
46
46
|
|
|
47
47
|
Convert an object or array to an array.
|
|
48
48
|
|
|
@@ -14,7 +14,7 @@ Cache the results from asynchronous requests.
|
|
|
14
14
|
|
|
15
15
|
## Methods
|
|
16
16
|
|
|
17
|
-
### exec()
|
|
17
|
+
### exec() {#exec}
|
|
18
18
|
|
|
19
19
|
> `static` **exec**\<`T`\>(`key`, `ttlMs`, `requestMethod`, `cacheFailures?`): `Promise`\<`T`\> \| `undefined`
|
|
20
20
|
|
|
@@ -60,7 +60,7 @@ The response.
|
|
|
60
60
|
|
|
61
61
|
***
|
|
62
62
|
|
|
63
|
-
### get()
|
|
63
|
+
### get() {#get}
|
|
64
64
|
|
|
65
65
|
> `static` **get**\<`T`\>(`key`): `Promise`\<`T` \| `undefined`\>
|
|
66
66
|
|
|
@@ -88,7 +88,7 @@ The item from the cache if it exists.
|
|
|
88
88
|
|
|
89
89
|
***
|
|
90
90
|
|
|
91
|
-
### set()
|
|
91
|
+
### set() {#set}
|
|
92
92
|
|
|
93
93
|
> `static` **set**\<`T`\>(`key`, `value`, `ttlMs?`): `Promise`\<`void`\>
|
|
94
94
|
|
|
@@ -128,7 +128,7 @@ Nothing.
|
|
|
128
128
|
|
|
129
129
|
***
|
|
130
130
|
|
|
131
|
-
### remove()
|
|
131
|
+
### remove() {#remove}
|
|
132
132
|
|
|
133
133
|
> `static` **remove**(`key`): `void`
|
|
134
134
|
|
|
@@ -148,7 +148,7 @@ The key to remove from the cache.
|
|
|
148
148
|
|
|
149
149
|
***
|
|
150
150
|
|
|
151
|
-
### clearCache()
|
|
151
|
+
### clearCache() {#clearcache}
|
|
152
152
|
|
|
153
153
|
> `static` **clearCache**(`prefix?`): `void`
|
|
154
154
|
|
|
@@ -168,7 +168,7 @@ Optional prefix to clear only entries with that prefix.
|
|
|
168
168
|
|
|
169
169
|
***
|
|
170
170
|
|
|
171
|
-
### cleanupExpired()
|
|
171
|
+
### cleanupExpired() {#cleanupexpired}
|
|
172
172
|
|
|
173
173
|
> `static` **cleanupExpired**(): `void`
|
|
174
174
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Class: Base32
|
|
2
2
|
|
|
3
|
-
Class to help with
|
|
3
|
+
Class to help with base32 Encoding/Decoding.
|
|
4
4
|
|
|
5
5
|
## Constructors
|
|
6
6
|
|
|
@@ -14,7 +14,7 @@ Class to help with base63 Encoding/Decoding.
|
|
|
14
14
|
|
|
15
15
|
## Properties
|
|
16
16
|
|
|
17
|
-
### CLASS\_NAME
|
|
17
|
+
### CLASS\_NAME {#class_name}
|
|
18
18
|
|
|
19
19
|
> `readonly` `static` **CLASS\_NAME**: `string`
|
|
20
20
|
|
|
@@ -22,7 +22,7 @@ Runtime name for the class.
|
|
|
22
22
|
|
|
23
23
|
## Methods
|
|
24
24
|
|
|
25
|
-
### decode()
|
|
25
|
+
### decode() {#decode}
|
|
26
26
|
|
|
27
27
|
> `static` **decode**(`base32`): `Uint8Array`
|
|
28
28
|
|
|
@@ -48,7 +48,7 @@ If the input string contains a character not in the Base32 alphabet.
|
|
|
48
48
|
|
|
49
49
|
***
|
|
50
50
|
|
|
51
|
-
### encode()
|
|
51
|
+
### encode() {#encode}
|
|
52
52
|
|
|
53
53
|
> `static` **encode**(`bytes`): `string`
|
|
54
54
|
|
|
@@ -14,7 +14,7 @@ Class to help with base58 Encoding/Decoding.
|
|
|
14
14
|
|
|
15
15
|
## Properties
|
|
16
16
|
|
|
17
|
-
### CLASS\_NAME
|
|
17
|
+
### CLASS\_NAME {#class_name}
|
|
18
18
|
|
|
19
19
|
> `readonly` `static` **CLASS\_NAME**: `string`
|
|
20
20
|
|
|
@@ -22,7 +22,7 @@ Runtime name for the class.
|
|
|
22
22
|
|
|
23
23
|
## Methods
|
|
24
24
|
|
|
25
|
-
### decode()
|
|
25
|
+
### decode() {#decode}
|
|
26
26
|
|
|
27
27
|
> `static` **decode**(`base58`): `Uint8Array`
|
|
28
28
|
|
|
@@ -48,7 +48,7 @@ If the input string contains a character not in the Base58 alphabet.
|
|
|
48
48
|
|
|
49
49
|
***
|
|
50
50
|
|
|
51
|
-
### encode()
|
|
51
|
+
### encode() {#encode}
|
|
52
52
|
|
|
53
53
|
> `static` **encode**(`bytes`): `string`
|
|
54
54
|
|
|
@@ -15,7 +15,7 @@ Sourced from https://github.com/beatgammit/base64-js.
|
|
|
15
15
|
|
|
16
16
|
## Properties
|
|
17
17
|
|
|
18
|
-
### CLASS\_NAME
|
|
18
|
+
### CLASS\_NAME {#class_name}
|
|
19
19
|
|
|
20
20
|
> `readonly` `static` **CLASS\_NAME**: `string`
|
|
21
21
|
|
|
@@ -23,7 +23,7 @@ Runtime name for the class.
|
|
|
23
23
|
|
|
24
24
|
## Methods
|
|
25
25
|
|
|
26
|
-
### byteLength()
|
|
26
|
+
### byteLength() {#bytelength}
|
|
27
27
|
|
|
28
28
|
> `static` **byteLength**(`base64`): `number`
|
|
29
29
|
|
|
@@ -45,7 +45,7 @@ The byte length of the data.
|
|
|
45
45
|
|
|
46
46
|
***
|
|
47
47
|
|
|
48
|
-
### decode()
|
|
48
|
+
### decode() {#decode}
|
|
49
49
|
|
|
50
50
|
> `static` **decode**(`base64`): `Uint8Array`
|
|
51
51
|
|
|
@@ -67,7 +67,7 @@ The byte array.
|
|
|
67
67
|
|
|
68
68
|
***
|
|
69
69
|
|
|
70
|
-
### encode()
|
|
70
|
+
### encode() {#encode}
|
|
71
71
|
|
|
72
72
|
> `static` **encode**(`bytes`): `string`
|
|
73
73
|
|
|
@@ -15,7 +15,7 @@ https://www.rfc-editor.org/rfc/rfc4648#section-5.
|
|
|
15
15
|
|
|
16
16
|
## Properties
|
|
17
17
|
|
|
18
|
-
### CLASS\_NAME
|
|
18
|
+
### CLASS\_NAME {#class_name}
|
|
19
19
|
|
|
20
20
|
> `readonly` `static` **CLASS\_NAME**: `string`
|
|
21
21
|
|
|
@@ -23,7 +23,7 @@ Runtime name for the class.
|
|
|
23
23
|
|
|
24
24
|
## Methods
|
|
25
25
|
|
|
26
|
-
### decode()
|
|
26
|
+
### decode() {#decode}
|
|
27
27
|
|
|
28
28
|
> `static` **decode**(`base64Url`): `Uint8Array`
|
|
29
29
|
|
|
@@ -45,7 +45,7 @@ The byte array.
|
|
|
45
45
|
|
|
46
46
|
***
|
|
47
47
|
|
|
48
|
-
### encode()
|
|
48
|
+
### encode() {#encode}
|
|
49
49
|
|
|
50
50
|
> `static` **encode**(`bytes`): `string`
|
|
51
51
|
|