@twin.org/core 0.0.1-next.1
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/LICENSE +201 -0
- package/README.md +29 -0
- package/dist/cjs/index.cjs +4221 -0
- package/dist/esm/index.mjs +4184 -0
- package/dist/types/encoding/base32.d.ts +18 -0
- package/dist/types/encoding/base64.d.ts +24 -0
- package/dist/types/encoding/base64Url.d.ts +18 -0
- package/dist/types/errors/alreadyExistsError.d.ts +18 -0
- package/dist/types/errors/baseError.d.ts +103 -0
- package/dist/types/errors/conflictError.d.ts +19 -0
- package/dist/types/errors/generalError.d.ts +20 -0
- package/dist/types/errors/guardError.d.ts +19 -0
- package/dist/types/errors/notFoundError.d.ts +18 -0
- package/dist/types/errors/notImplementedError.d.ts +16 -0
- package/dist/types/errors/notSupportedError.d.ts +17 -0
- package/dist/types/errors/unauthorizedError.d.ts +17 -0
- package/dist/types/errors/unprocessableError.d.ts +20 -0
- package/dist/types/errors/validationError.d.ts +18 -0
- package/dist/types/factories/componentFactory.d.ts +6 -0
- package/dist/types/factories/factory.d.ts +67 -0
- package/dist/types/helpers/arrayHelper.d.ts +12 -0
- package/dist/types/helpers/errorHelper.d.ts +24 -0
- package/dist/types/helpers/filenameHelper.d.ts +11 -0
- package/dist/types/helpers/hexHelper.d.ts +30 -0
- package/dist/types/helpers/jsonHelper.d.ts +29 -0
- package/dist/types/helpers/objectHelper.d.ts +74 -0
- package/dist/types/helpers/randomHelper.d.ts +11 -0
- package/dist/types/helpers/stringHelper.d.ts +90 -0
- package/dist/types/index.d.ts +46 -0
- package/dist/types/models/IComponent.d.ts +29 -0
- package/dist/types/models/IError.d.ts +31 -0
- package/dist/types/models/IKeyValue.d.ts +13 -0
- package/dist/types/models/ILabelledValue.d.ts +13 -0
- package/dist/types/models/ILocale.d.ts +13 -0
- package/dist/types/models/ILocaleDictionary.d.ts +6 -0
- package/dist/types/models/ILocalesIndex.d.ts +10 -0
- package/dist/types/models/IPatchOperation.d.ts +21 -0
- package/dist/types/models/IUrlParts.d.ts +29 -0
- package/dist/types/models/IValidationFailure.d.ts +23 -0
- package/dist/types/models/compressionType.d.ts +17 -0
- package/dist/types/types/bitString.d.ts +41 -0
- package/dist/types/types/url.d.ts +56 -0
- package/dist/types/types/urn.d.ts +93 -0
- package/dist/types/utils/asyncCache.d.ts +33 -0
- package/dist/types/utils/coerce.d.ts +61 -0
- package/dist/types/utils/compression.d.ts +20 -0
- package/dist/types/utils/converter.d.ts +85 -0
- package/dist/types/utils/guards.d.ts +190 -0
- package/dist/types/utils/i18n.d.ts +81 -0
- package/dist/types/utils/is.d.ts +205 -0
- package/dist/types/utils/validation.d.ts +245 -0
- package/docs/changelog.md +5 -0
- package/docs/examples.md +1 -0
- package/docs/reference/classes/AlreadyExistsError.md +375 -0
- package/docs/reference/classes/ArrayHelper.md +37 -0
- package/docs/reference/classes/AsyncCache.md +117 -0
- package/docs/reference/classes/Base32.md +57 -0
- package/docs/reference/classes/Base64.md +74 -0
- package/docs/reference/classes/Base64Url.md +54 -0
- package/docs/reference/classes/BaseError.md +344 -0
- package/docs/reference/classes/BitString.md +123 -0
- package/docs/reference/classes/Coerce.md +209 -0
- package/docs/reference/classes/Compression.md +61 -0
- package/docs/reference/classes/ConflictError.md +379 -0
- package/docs/reference/classes/Converter.md +285 -0
- package/docs/reference/classes/ErrorHelper.md +73 -0
- package/docs/reference/classes/Factory.md +221 -0
- package/docs/reference/classes/FilenameHelper.md +33 -0
- package/docs/reference/classes/GeneralError.md +375 -0
- package/docs/reference/classes/GuardError.md +379 -0
- package/docs/reference/classes/Guards.md +711 -0
- package/docs/reference/classes/HexHelper.md +97 -0
- package/docs/reference/classes/I18n.md +237 -0
- package/docs/reference/classes/Is.md +693 -0
- package/docs/reference/classes/JsonHelper.md +92 -0
- package/docs/reference/classes/NotFoundError.md +375 -0
- package/docs/reference/classes/NotImplementedError.md +367 -0
- package/docs/reference/classes/NotSupportedError.md +371 -0
- package/docs/reference/classes/ObjectHelper.md +287 -0
- package/docs/reference/classes/RandomHelper.md +33 -0
- package/docs/reference/classes/StringHelper.md +270 -0
- package/docs/reference/classes/UnauthorizedError.md +371 -0
- package/docs/reference/classes/UnprocessableError.md +375 -0
- package/docs/reference/classes/Url.md +167 -0
- package/docs/reference/classes/Urn.md +295 -0
- package/docs/reference/classes/Validation.md +821 -0
- package/docs/reference/classes/ValidationError.md +371 -0
- package/docs/reference/index.md +60 -0
- package/docs/reference/interfaces/IComponent.md +79 -0
- package/docs/reference/interfaces/IError.md +55 -0
- package/docs/reference/interfaces/IKeyValue.md +23 -0
- package/docs/reference/interfaces/ILabelledValue.md +23 -0
- package/docs/reference/interfaces/ILocale.md +19 -0
- package/docs/reference/interfaces/ILocaleDictionary.md +7 -0
- package/docs/reference/interfaces/ILocalesIndex.md +11 -0
- package/docs/reference/interfaces/IPatchOperation.md +35 -0
- package/docs/reference/interfaces/IUrlParts.md +51 -0
- package/docs/reference/interfaces/IValidationFailure.md +39 -0
- package/docs/reference/type-aliases/CompressionType.md +5 -0
- package/docs/reference/variables/ComponentFactory.md +5 -0
- package/docs/reference/variables/CompressionType.md +19 -0
- package/locales/en.json +98 -0
- package/package.json +65 -0
|
@@ -0,0 +1,379 @@
|
|
|
1
|
+
# Class: ConflictError
|
|
2
|
+
|
|
3
|
+
Class to handle errors which are triggered by conflicting data.
|
|
4
|
+
|
|
5
|
+
## Extends
|
|
6
|
+
|
|
7
|
+
- [`BaseError`](BaseError.md)
|
|
8
|
+
|
|
9
|
+
## Constructors
|
|
10
|
+
|
|
11
|
+
### new ConflictError()
|
|
12
|
+
|
|
13
|
+
> **new ConflictError**(`source`, `message`, `conflictId`?, `conflicts`?, `inner`?): [`ConflictError`](ConflictError.md)
|
|
14
|
+
|
|
15
|
+
Create a new instance of ConflictError.
|
|
16
|
+
|
|
17
|
+
#### Parameters
|
|
18
|
+
|
|
19
|
+
• **source**: `string`
|
|
20
|
+
|
|
21
|
+
The source of the error.
|
|
22
|
+
|
|
23
|
+
• **message**: `string`
|
|
24
|
+
|
|
25
|
+
The message as a code.
|
|
26
|
+
|
|
27
|
+
• **conflictId?**: `string`
|
|
28
|
+
|
|
29
|
+
The id that has conflicts.
|
|
30
|
+
|
|
31
|
+
• **conflicts?**: `string`[]
|
|
32
|
+
|
|
33
|
+
The conflicts that occurred.
|
|
34
|
+
|
|
35
|
+
• **inner?**: `unknown`
|
|
36
|
+
|
|
37
|
+
The inner error if we have wrapped another error.
|
|
38
|
+
|
|
39
|
+
#### Returns
|
|
40
|
+
|
|
41
|
+
[`ConflictError`](ConflictError.md)
|
|
42
|
+
|
|
43
|
+
#### Overrides
|
|
44
|
+
|
|
45
|
+
[`BaseError`](BaseError.md).[`constructor`](BaseError.md#constructors)
|
|
46
|
+
|
|
47
|
+
## Properties
|
|
48
|
+
|
|
49
|
+
### source?
|
|
50
|
+
|
|
51
|
+
> `optional` **source**: `string`
|
|
52
|
+
|
|
53
|
+
The source of the error.
|
|
54
|
+
|
|
55
|
+
#### Inherited from
|
|
56
|
+
|
|
57
|
+
[`BaseError`](BaseError.md).[`source`](BaseError.md#source)
|
|
58
|
+
|
|
59
|
+
***
|
|
60
|
+
|
|
61
|
+
### properties?
|
|
62
|
+
|
|
63
|
+
> `optional` **properties**: `object`
|
|
64
|
+
|
|
65
|
+
Any additional information for the error.
|
|
66
|
+
|
|
67
|
+
#### Index Signature
|
|
68
|
+
|
|
69
|
+
\[`id`: `string`\]: `unknown`
|
|
70
|
+
|
|
71
|
+
#### Inherited from
|
|
72
|
+
|
|
73
|
+
[`BaseError`](BaseError.md).[`properties`](BaseError.md#properties)
|
|
74
|
+
|
|
75
|
+
***
|
|
76
|
+
|
|
77
|
+
### inner?
|
|
78
|
+
|
|
79
|
+
> `optional` **inner**: [`IError`](../interfaces/IError.md)
|
|
80
|
+
|
|
81
|
+
The inner error if there was one.
|
|
82
|
+
|
|
83
|
+
#### Inherited from
|
|
84
|
+
|
|
85
|
+
[`BaseError`](BaseError.md).[`inner`](BaseError.md#inner)
|
|
86
|
+
|
|
87
|
+
***
|
|
88
|
+
|
|
89
|
+
### CLASS\_NAME
|
|
90
|
+
|
|
91
|
+
> `readonly` `static` **CLASS\_NAME**: `string`
|
|
92
|
+
|
|
93
|
+
Runtime name for the class.
|
|
94
|
+
|
|
95
|
+
## Methods
|
|
96
|
+
|
|
97
|
+
### fromError()
|
|
98
|
+
|
|
99
|
+
> `static` **fromError**(`err`): [`BaseError`](BaseError.md)
|
|
100
|
+
|
|
101
|
+
Construct an error from an existing one.
|
|
102
|
+
|
|
103
|
+
#### Parameters
|
|
104
|
+
|
|
105
|
+
• **err**: `unknown`
|
|
106
|
+
|
|
107
|
+
The existing error.
|
|
108
|
+
|
|
109
|
+
#### Returns
|
|
110
|
+
|
|
111
|
+
[`BaseError`](BaseError.md)
|
|
112
|
+
|
|
113
|
+
The new instance.
|
|
114
|
+
|
|
115
|
+
#### Inherited from
|
|
116
|
+
|
|
117
|
+
[`BaseError`](BaseError.md).[`fromError`](BaseError.md#fromerror)
|
|
118
|
+
|
|
119
|
+
***
|
|
120
|
+
|
|
121
|
+
### flatten()
|
|
122
|
+
|
|
123
|
+
> `static` **flatten**(`err`): [`IError`](../interfaces/IError.md)[]
|
|
124
|
+
|
|
125
|
+
Flatten an error tree.
|
|
126
|
+
|
|
127
|
+
#### Parameters
|
|
128
|
+
|
|
129
|
+
• **err**: `unknown`
|
|
130
|
+
|
|
131
|
+
The starting error.
|
|
132
|
+
|
|
133
|
+
#### Returns
|
|
134
|
+
|
|
135
|
+
[`IError`](../interfaces/IError.md)[]
|
|
136
|
+
|
|
137
|
+
The list of all internal errors.
|
|
138
|
+
|
|
139
|
+
#### Inherited from
|
|
140
|
+
|
|
141
|
+
[`BaseError`](BaseError.md).[`flatten`](BaseError.md#flatten)
|
|
142
|
+
|
|
143
|
+
***
|
|
144
|
+
|
|
145
|
+
### expand()
|
|
146
|
+
|
|
147
|
+
> `static` **expand**(`errors`): `undefined` \| [`IError`](../interfaces/IError.md)
|
|
148
|
+
|
|
149
|
+
Expand an error tree.
|
|
150
|
+
|
|
151
|
+
#### Parameters
|
|
152
|
+
|
|
153
|
+
• **errors**: `undefined` \| [`IError`](../interfaces/IError.md)[]
|
|
154
|
+
|
|
155
|
+
The list of errors to expand.
|
|
156
|
+
|
|
157
|
+
#### Returns
|
|
158
|
+
|
|
159
|
+
`undefined` \| [`IError`](../interfaces/IError.md)
|
|
160
|
+
|
|
161
|
+
The first level error.
|
|
162
|
+
|
|
163
|
+
#### Inherited from
|
|
164
|
+
|
|
165
|
+
[`BaseError`](BaseError.md).[`expand`](BaseError.md#expand)
|
|
166
|
+
|
|
167
|
+
***
|
|
168
|
+
|
|
169
|
+
### isErrorName()
|
|
170
|
+
|
|
171
|
+
> `static` **isErrorName**(`error`, `name`): `error is BaseError`
|
|
172
|
+
|
|
173
|
+
Test to see if the error has the specified error name.
|
|
174
|
+
|
|
175
|
+
#### Parameters
|
|
176
|
+
|
|
177
|
+
• **error**: `unknown`
|
|
178
|
+
|
|
179
|
+
The error to test.
|
|
180
|
+
|
|
181
|
+
• **name**: `string` \| `RegExp`
|
|
182
|
+
|
|
183
|
+
The name to check for.
|
|
184
|
+
|
|
185
|
+
#### Returns
|
|
186
|
+
|
|
187
|
+
`error is BaseError`
|
|
188
|
+
|
|
189
|
+
True if the error has the name.
|
|
190
|
+
|
|
191
|
+
#### Inherited from
|
|
192
|
+
|
|
193
|
+
[`BaseError`](BaseError.md).[`isErrorName`](BaseError.md#iserrorname)
|
|
194
|
+
|
|
195
|
+
***
|
|
196
|
+
|
|
197
|
+
### isErrorMessage()
|
|
198
|
+
|
|
199
|
+
> `static` **isErrorMessage**(`error`, `message`): `error is BaseError`
|
|
200
|
+
|
|
201
|
+
Test to see if the error has the specified error message.
|
|
202
|
+
|
|
203
|
+
#### Parameters
|
|
204
|
+
|
|
205
|
+
• **error**: `unknown`
|
|
206
|
+
|
|
207
|
+
The error to test.
|
|
208
|
+
|
|
209
|
+
• **message**: `string` \| `RegExp`
|
|
210
|
+
|
|
211
|
+
The message to check for.
|
|
212
|
+
|
|
213
|
+
#### Returns
|
|
214
|
+
|
|
215
|
+
`error is BaseError`
|
|
216
|
+
|
|
217
|
+
True if the error has the name.
|
|
218
|
+
|
|
219
|
+
#### Inherited from
|
|
220
|
+
|
|
221
|
+
[`BaseError`](BaseError.md).[`isErrorMessage`](BaseError.md#iserrormessage)
|
|
222
|
+
|
|
223
|
+
***
|
|
224
|
+
|
|
225
|
+
### isErrorCode()
|
|
226
|
+
|
|
227
|
+
> `static` **isErrorCode**(`error`, `code`): `boolean`
|
|
228
|
+
|
|
229
|
+
Test to see if the error has the specified error code.
|
|
230
|
+
|
|
231
|
+
#### Parameters
|
|
232
|
+
|
|
233
|
+
• **error**: `unknown`
|
|
234
|
+
|
|
235
|
+
The error to test.
|
|
236
|
+
|
|
237
|
+
• **code**: `string` \| `RegExp`
|
|
238
|
+
|
|
239
|
+
The code to check for.
|
|
240
|
+
|
|
241
|
+
#### Returns
|
|
242
|
+
|
|
243
|
+
`boolean`
|
|
244
|
+
|
|
245
|
+
True if the error has the code.
|
|
246
|
+
|
|
247
|
+
#### Inherited from
|
|
248
|
+
|
|
249
|
+
[`BaseError`](BaseError.md).[`isErrorCode`](BaseError.md#iserrorcode)
|
|
250
|
+
|
|
251
|
+
***
|
|
252
|
+
|
|
253
|
+
### someErrorName()
|
|
254
|
+
|
|
255
|
+
> `static` **someErrorName**(`error`, `name`): `error is BaseError`
|
|
256
|
+
|
|
257
|
+
Test to see if any of the errors or children have the given error name.
|
|
258
|
+
|
|
259
|
+
#### Parameters
|
|
260
|
+
|
|
261
|
+
• **error**: `unknown`
|
|
262
|
+
|
|
263
|
+
The error to test.
|
|
264
|
+
|
|
265
|
+
• **name**: `string` \| `RegExp`
|
|
266
|
+
|
|
267
|
+
The name to check for.
|
|
268
|
+
|
|
269
|
+
#### Returns
|
|
270
|
+
|
|
271
|
+
`error is BaseError`
|
|
272
|
+
|
|
273
|
+
True if the error has the name.
|
|
274
|
+
|
|
275
|
+
#### Inherited from
|
|
276
|
+
|
|
277
|
+
[`BaseError`](BaseError.md).[`someErrorName`](BaseError.md#someerrorname)
|
|
278
|
+
|
|
279
|
+
***
|
|
280
|
+
|
|
281
|
+
### someErrorMessage()
|
|
282
|
+
|
|
283
|
+
> `static` **someErrorMessage**(`error`, `message`): `error is BaseError`
|
|
284
|
+
|
|
285
|
+
Test to see if any of the errors or children have the given error message.
|
|
286
|
+
|
|
287
|
+
#### Parameters
|
|
288
|
+
|
|
289
|
+
• **error**: `unknown`
|
|
290
|
+
|
|
291
|
+
The error to test.
|
|
292
|
+
|
|
293
|
+
• **message**: `string` \| `RegExp`
|
|
294
|
+
|
|
295
|
+
The message to check for.
|
|
296
|
+
|
|
297
|
+
#### Returns
|
|
298
|
+
|
|
299
|
+
`error is BaseError`
|
|
300
|
+
|
|
301
|
+
True if the error has the name.
|
|
302
|
+
|
|
303
|
+
#### Inherited from
|
|
304
|
+
|
|
305
|
+
[`BaseError`](BaseError.md).[`someErrorMessage`](BaseError.md#someerrormessage)
|
|
306
|
+
|
|
307
|
+
***
|
|
308
|
+
|
|
309
|
+
### someErrorClass()
|
|
310
|
+
|
|
311
|
+
> `static` **someErrorClass**(`error`, `cls`): `error is BaseError`
|
|
312
|
+
|
|
313
|
+
Test to see if any of the errors or children are from a specific class.
|
|
314
|
+
|
|
315
|
+
#### Parameters
|
|
316
|
+
|
|
317
|
+
• **error**: `unknown`
|
|
318
|
+
|
|
319
|
+
The error to test.
|
|
320
|
+
|
|
321
|
+
• **cls**: `string`
|
|
322
|
+
|
|
323
|
+
The class to check for.
|
|
324
|
+
|
|
325
|
+
#### Returns
|
|
326
|
+
|
|
327
|
+
`error is BaseError`
|
|
328
|
+
|
|
329
|
+
True if the error has the specific class.
|
|
330
|
+
|
|
331
|
+
#### Inherited from
|
|
332
|
+
|
|
333
|
+
[`BaseError`](BaseError.md).[`someErrorClass`](BaseError.md#someerrorclass)
|
|
334
|
+
|
|
335
|
+
***
|
|
336
|
+
|
|
337
|
+
### someErrorCode()
|
|
338
|
+
|
|
339
|
+
> `static` **someErrorCode**(`error`, `code`): `error is BaseError`
|
|
340
|
+
|
|
341
|
+
Test to see if any of the errors or children have the given error code.
|
|
342
|
+
|
|
343
|
+
#### Parameters
|
|
344
|
+
|
|
345
|
+
• **error**: `unknown`
|
|
346
|
+
|
|
347
|
+
The error to test.
|
|
348
|
+
|
|
349
|
+
• **code**: `string` \| `RegExp`
|
|
350
|
+
|
|
351
|
+
The code to check for.
|
|
352
|
+
|
|
353
|
+
#### Returns
|
|
354
|
+
|
|
355
|
+
`error is BaseError`
|
|
356
|
+
|
|
357
|
+
True if the error has the name.
|
|
358
|
+
|
|
359
|
+
#### Inherited from
|
|
360
|
+
|
|
361
|
+
[`BaseError`](BaseError.md).[`someErrorCode`](BaseError.md#someerrorcode)
|
|
362
|
+
|
|
363
|
+
***
|
|
364
|
+
|
|
365
|
+
### toJsonObject()
|
|
366
|
+
|
|
367
|
+
> **toJsonObject**(): [`IError`](../interfaces/IError.md)
|
|
368
|
+
|
|
369
|
+
Serialize the error to the error model.
|
|
370
|
+
|
|
371
|
+
#### Returns
|
|
372
|
+
|
|
373
|
+
[`IError`](../interfaces/IError.md)
|
|
374
|
+
|
|
375
|
+
The error model.
|
|
376
|
+
|
|
377
|
+
#### Inherited from
|
|
378
|
+
|
|
379
|
+
[`BaseError`](BaseError.md).[`toJsonObject`](BaseError.md#tojsonobject)
|
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
# Class: Converter
|
|
2
|
+
|
|
3
|
+
Convert arrays to and from different formats.
|
|
4
|
+
|
|
5
|
+
## Constructors
|
|
6
|
+
|
|
7
|
+
### new Converter()
|
|
8
|
+
|
|
9
|
+
> **new Converter**(): [`Converter`](Converter.md)
|
|
10
|
+
|
|
11
|
+
#### Returns
|
|
12
|
+
|
|
13
|
+
[`Converter`](Converter.md)
|
|
14
|
+
|
|
15
|
+
## Methods
|
|
16
|
+
|
|
17
|
+
### bytesToUtf8()
|
|
18
|
+
|
|
19
|
+
> `static` **bytesToUtf8**(`array`, `startIndex`?, `length`?): `string`
|
|
20
|
+
|
|
21
|
+
Encode a raw array to UTF8 string.
|
|
22
|
+
|
|
23
|
+
#### Parameters
|
|
24
|
+
|
|
25
|
+
• **array**: `ArrayLike`\<`number`\>
|
|
26
|
+
|
|
27
|
+
The bytes to encode.
|
|
28
|
+
|
|
29
|
+
• **startIndex?**: `number`
|
|
30
|
+
|
|
31
|
+
The index to start in the bytes.
|
|
32
|
+
|
|
33
|
+
• **length?**: `number`
|
|
34
|
+
|
|
35
|
+
The length of bytes to read.
|
|
36
|
+
|
|
37
|
+
#### Returns
|
|
38
|
+
|
|
39
|
+
`string`
|
|
40
|
+
|
|
41
|
+
The array formatted as UTF8.
|
|
42
|
+
|
|
43
|
+
***
|
|
44
|
+
|
|
45
|
+
### utf8ToBytes()
|
|
46
|
+
|
|
47
|
+
> `static` **utf8ToBytes**(`utf8`): `Uint8Array`
|
|
48
|
+
|
|
49
|
+
Convert a UTF8 string to raw array.
|
|
50
|
+
|
|
51
|
+
#### Parameters
|
|
52
|
+
|
|
53
|
+
• **utf8**: `string`
|
|
54
|
+
|
|
55
|
+
The text to decode.
|
|
56
|
+
|
|
57
|
+
#### Returns
|
|
58
|
+
|
|
59
|
+
`Uint8Array`
|
|
60
|
+
|
|
61
|
+
The array.
|
|
62
|
+
|
|
63
|
+
***
|
|
64
|
+
|
|
65
|
+
### bytesToHex()
|
|
66
|
+
|
|
67
|
+
> `static` **bytesToHex**(`array`, `includePrefix`, `startIndex`?, `length`?, `reverse`?): `string`
|
|
68
|
+
|
|
69
|
+
Encode a raw array to hex string.
|
|
70
|
+
|
|
71
|
+
#### Parameters
|
|
72
|
+
|
|
73
|
+
• **array**: `ArrayLike`\<`number`\>
|
|
74
|
+
|
|
75
|
+
The bytes to encode.
|
|
76
|
+
|
|
77
|
+
• **includePrefix**: `boolean` = `false`
|
|
78
|
+
|
|
79
|
+
Include the 0x prefix on the returned hex.
|
|
80
|
+
|
|
81
|
+
• **startIndex?**: `number`
|
|
82
|
+
|
|
83
|
+
The index to start in the bytes.
|
|
84
|
+
|
|
85
|
+
• **length?**: `number`
|
|
86
|
+
|
|
87
|
+
The length of bytes to read.
|
|
88
|
+
|
|
89
|
+
• **reverse?**: `boolean`
|
|
90
|
+
|
|
91
|
+
Reverse the combine direction.
|
|
92
|
+
|
|
93
|
+
#### Returns
|
|
94
|
+
|
|
95
|
+
`string`
|
|
96
|
+
|
|
97
|
+
The array formatted as hex.
|
|
98
|
+
|
|
99
|
+
***
|
|
100
|
+
|
|
101
|
+
### hexToBytes()
|
|
102
|
+
|
|
103
|
+
> `static` **hexToBytes**(`hex`, `reverse`?): `Uint8Array`
|
|
104
|
+
|
|
105
|
+
Decode a hex string to raw array.
|
|
106
|
+
|
|
107
|
+
#### Parameters
|
|
108
|
+
|
|
109
|
+
• **hex**: `string`
|
|
110
|
+
|
|
111
|
+
The hex to decode.
|
|
112
|
+
|
|
113
|
+
• **reverse?**: `boolean`
|
|
114
|
+
|
|
115
|
+
Store the characters in reverse.
|
|
116
|
+
|
|
117
|
+
#### Returns
|
|
118
|
+
|
|
119
|
+
`Uint8Array`
|
|
120
|
+
|
|
121
|
+
The array.
|
|
122
|
+
|
|
123
|
+
***
|
|
124
|
+
|
|
125
|
+
### utf8ToHex()
|
|
126
|
+
|
|
127
|
+
> `static` **utf8ToHex**(`utf8`, `includePrefix`): `string`
|
|
128
|
+
|
|
129
|
+
Convert the UTF8 to hex.
|
|
130
|
+
|
|
131
|
+
#### Parameters
|
|
132
|
+
|
|
133
|
+
• **utf8**: `string`
|
|
134
|
+
|
|
135
|
+
The text to convert.
|
|
136
|
+
|
|
137
|
+
• **includePrefix**: `boolean` = `false`
|
|
138
|
+
|
|
139
|
+
Include the 0x prefix on the returned hex.
|
|
140
|
+
|
|
141
|
+
#### Returns
|
|
142
|
+
|
|
143
|
+
`string`
|
|
144
|
+
|
|
145
|
+
The hex version of the bytes.
|
|
146
|
+
|
|
147
|
+
***
|
|
148
|
+
|
|
149
|
+
### hexToUtf8()
|
|
150
|
+
|
|
151
|
+
> `static` **hexToUtf8**(`hex`): `string`
|
|
152
|
+
|
|
153
|
+
Convert the hex text to text.
|
|
154
|
+
|
|
155
|
+
#### Parameters
|
|
156
|
+
|
|
157
|
+
• **hex**: `string`
|
|
158
|
+
|
|
159
|
+
The hex to convert.
|
|
160
|
+
|
|
161
|
+
#### Returns
|
|
162
|
+
|
|
163
|
+
`string`
|
|
164
|
+
|
|
165
|
+
The UTF8 version of the bytes.
|
|
166
|
+
|
|
167
|
+
***
|
|
168
|
+
|
|
169
|
+
### bytesToBinary()
|
|
170
|
+
|
|
171
|
+
> `static` **bytesToBinary**(`bytes`): `string`
|
|
172
|
+
|
|
173
|
+
Convert bytes to binary string.
|
|
174
|
+
|
|
175
|
+
#### Parameters
|
|
176
|
+
|
|
177
|
+
• **bytes**: `Uint8Array`
|
|
178
|
+
|
|
179
|
+
The bytes to convert.
|
|
180
|
+
|
|
181
|
+
#### Returns
|
|
182
|
+
|
|
183
|
+
`string`
|
|
184
|
+
|
|
185
|
+
A binary string of the bytes.
|
|
186
|
+
|
|
187
|
+
***
|
|
188
|
+
|
|
189
|
+
### binaryToBytes()
|
|
190
|
+
|
|
191
|
+
> `static` **binaryToBytes**(`binary`): `Uint8Array`
|
|
192
|
+
|
|
193
|
+
Convert a binary string to bytes.
|
|
194
|
+
|
|
195
|
+
#### Parameters
|
|
196
|
+
|
|
197
|
+
• **binary**: `string`
|
|
198
|
+
|
|
199
|
+
The binary string.
|
|
200
|
+
|
|
201
|
+
#### Returns
|
|
202
|
+
|
|
203
|
+
`Uint8Array`
|
|
204
|
+
|
|
205
|
+
The bytes.
|
|
206
|
+
|
|
207
|
+
***
|
|
208
|
+
|
|
209
|
+
### bytesToBase64()
|
|
210
|
+
|
|
211
|
+
> `static` **bytesToBase64**(`bytes`): `string`
|
|
212
|
+
|
|
213
|
+
Convert bytes to base64 string.
|
|
214
|
+
|
|
215
|
+
#### Parameters
|
|
216
|
+
|
|
217
|
+
• **bytes**: `Uint8Array`
|
|
218
|
+
|
|
219
|
+
The bytes to convert.
|
|
220
|
+
|
|
221
|
+
#### Returns
|
|
222
|
+
|
|
223
|
+
`string`
|
|
224
|
+
|
|
225
|
+
A base64 string of the bytes.
|
|
226
|
+
|
|
227
|
+
***
|
|
228
|
+
|
|
229
|
+
### base64ToBytes()
|
|
230
|
+
|
|
231
|
+
> `static` **base64ToBytes**(`base64`): `Uint8Array`
|
|
232
|
+
|
|
233
|
+
Convert a base64 string to bytes.
|
|
234
|
+
|
|
235
|
+
#### Parameters
|
|
236
|
+
|
|
237
|
+
• **base64**: `string`
|
|
238
|
+
|
|
239
|
+
The base64 string.
|
|
240
|
+
|
|
241
|
+
#### Returns
|
|
242
|
+
|
|
243
|
+
`Uint8Array`
|
|
244
|
+
|
|
245
|
+
The bytes.
|
|
246
|
+
|
|
247
|
+
***
|
|
248
|
+
|
|
249
|
+
### bytesToBase64Url()
|
|
250
|
+
|
|
251
|
+
> `static` **bytesToBase64Url**(`bytes`): `string`
|
|
252
|
+
|
|
253
|
+
Convert bytes to base64 url string.
|
|
254
|
+
|
|
255
|
+
#### Parameters
|
|
256
|
+
|
|
257
|
+
• **bytes**: `Uint8Array`
|
|
258
|
+
|
|
259
|
+
The bytes to convert.
|
|
260
|
+
|
|
261
|
+
#### Returns
|
|
262
|
+
|
|
263
|
+
`string`
|
|
264
|
+
|
|
265
|
+
A base64 url string of the bytes.
|
|
266
|
+
|
|
267
|
+
***
|
|
268
|
+
|
|
269
|
+
### base64UrlToBytes()
|
|
270
|
+
|
|
271
|
+
> `static` **base64UrlToBytes**(`base64Url`): `Uint8Array`
|
|
272
|
+
|
|
273
|
+
Convert a base64 url string to bytes.
|
|
274
|
+
|
|
275
|
+
#### Parameters
|
|
276
|
+
|
|
277
|
+
• **base64Url**: `string`
|
|
278
|
+
|
|
279
|
+
The base64 url string.
|
|
280
|
+
|
|
281
|
+
#### Returns
|
|
282
|
+
|
|
283
|
+
`Uint8Array`
|
|
284
|
+
|
|
285
|
+
The bytes.
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# Class: ErrorHelper
|
|
2
|
+
|
|
3
|
+
Error helper functions.
|
|
4
|
+
|
|
5
|
+
## Constructors
|
|
6
|
+
|
|
7
|
+
### new ErrorHelper()
|
|
8
|
+
|
|
9
|
+
> **new ErrorHelper**(): [`ErrorHelper`](ErrorHelper.md)
|
|
10
|
+
|
|
11
|
+
#### Returns
|
|
12
|
+
|
|
13
|
+
[`ErrorHelper`](ErrorHelper.md)
|
|
14
|
+
|
|
15
|
+
## Methods
|
|
16
|
+
|
|
17
|
+
### formatErrors()
|
|
18
|
+
|
|
19
|
+
> `static` **formatErrors**(`error`): `string`[]
|
|
20
|
+
|
|
21
|
+
Format Errors and returns just their messages.
|
|
22
|
+
|
|
23
|
+
#### Parameters
|
|
24
|
+
|
|
25
|
+
• **error**: `unknown`
|
|
26
|
+
|
|
27
|
+
The error to format.
|
|
28
|
+
|
|
29
|
+
#### Returns
|
|
30
|
+
|
|
31
|
+
`string`[]
|
|
32
|
+
|
|
33
|
+
The error formatted including any inner errors.
|
|
34
|
+
|
|
35
|
+
***
|
|
36
|
+
|
|
37
|
+
### localizeErrors()
|
|
38
|
+
|
|
39
|
+
> `static` **localizeErrors**(`error`): [`IError`](../interfaces/IError.md)[]
|
|
40
|
+
|
|
41
|
+
Localize the content of an error and any inner errors.
|
|
42
|
+
|
|
43
|
+
#### Parameters
|
|
44
|
+
|
|
45
|
+
• **error**: `unknown`
|
|
46
|
+
|
|
47
|
+
The error to format.
|
|
48
|
+
|
|
49
|
+
#### Returns
|
|
50
|
+
|
|
51
|
+
[`IError`](../interfaces/IError.md)[]
|
|
52
|
+
|
|
53
|
+
The localized version of the errors flattened.
|
|
54
|
+
|
|
55
|
+
***
|
|
56
|
+
|
|
57
|
+
### formatValidationErrors()
|
|
58
|
+
|
|
59
|
+
> `static` **formatValidationErrors**(`error`): `undefined` \| `string`
|
|
60
|
+
|
|
61
|
+
Localize the content of an error and any inner errors.
|
|
62
|
+
|
|
63
|
+
#### Parameters
|
|
64
|
+
|
|
65
|
+
• **error**: [`IError`](../interfaces/IError.md)
|
|
66
|
+
|
|
67
|
+
The error to format.
|
|
68
|
+
|
|
69
|
+
#### Returns
|
|
70
|
+
|
|
71
|
+
`undefined` \| `string`
|
|
72
|
+
|
|
73
|
+
The localized version of the errors flattened.
|