@twin.org/core 0.0.1-next.32 → 0.0.1-next.34
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 +35 -10
- package/dist/esm/index.mjs +35 -11
- package/dist/types/helpers/uint8ArrayHelper.d.ts +11 -0
- package/dist/types/index.d.ts +1 -0
- package/docs/changelog.md +1 -1
- package/docs/reference/classes/Uint8ArrayHelper.md +35 -0
- package/docs/reference/index.md +1 -0
- package/package.json +1 -1
package/dist/cjs/index.cjs
CHANGED
|
@@ -3412,6 +3412,32 @@ class RandomHelper {
|
|
|
3412
3412
|
}
|
|
3413
3413
|
}
|
|
3414
3414
|
|
|
3415
|
+
// Copyright 2024 IOTA Stiftung.
|
|
3416
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
3417
|
+
/**
|
|
3418
|
+
* Class to help with uint8 arrays.
|
|
3419
|
+
*/
|
|
3420
|
+
class Uint8ArrayHelper {
|
|
3421
|
+
/**
|
|
3422
|
+
* Concatenate multiple arrays.
|
|
3423
|
+
* @param arrays The array to concatenate.
|
|
3424
|
+
* @returns The combined array.
|
|
3425
|
+
*/
|
|
3426
|
+
static concat(arrays) {
|
|
3427
|
+
let totalLength = 0;
|
|
3428
|
+
for (const array of arrays) {
|
|
3429
|
+
totalLength += array.length;
|
|
3430
|
+
}
|
|
3431
|
+
const concatBytes = new Uint8Array(totalLength);
|
|
3432
|
+
let offset = 0;
|
|
3433
|
+
for (const array of arrays) {
|
|
3434
|
+
concatBytes.set(array, offset);
|
|
3435
|
+
offset += array.length;
|
|
3436
|
+
}
|
|
3437
|
+
return concatBytes;
|
|
3438
|
+
}
|
|
3439
|
+
}
|
|
3440
|
+
|
|
3415
3441
|
// Copyright 2024 IOTA Stiftung.
|
|
3416
3442
|
// SPDX-License-Identifier: Apache-2.0.
|
|
3417
3443
|
/**
|
|
@@ -3962,11 +3988,10 @@ class Compression {
|
|
|
3962
3988
|
Guards.uint8Array(Compression._CLASS_NAME, "bytes", bytes);
|
|
3963
3989
|
Guards.arrayOneOf(Compression._CLASS_NAME, "type", type, Object.values(CompressionType));
|
|
3964
3990
|
const blob = new Blob([bytes]);
|
|
3965
|
-
const
|
|
3966
|
-
const
|
|
3967
|
-
const compressedBlob = await new Response(
|
|
3968
|
-
const
|
|
3969
|
-
const compressedBytes = new Uint8Array(ab);
|
|
3991
|
+
const compressionStream = new CompressionStream(type);
|
|
3992
|
+
const compressionPipe = blob.stream().pipeThrough(compressionStream);
|
|
3993
|
+
const compressedBlob = await new Response(compressionPipe).blob();
|
|
3994
|
+
const compressedBytes = await compressedBlob.bytes();
|
|
3970
3995
|
// GZIP header contains a byte which specifies the OS the
|
|
3971
3996
|
// compression was performed on. We set this to 3 (Unix) to ensure
|
|
3972
3997
|
// that we produce consistent results.
|
|
@@ -3985,11 +4010,10 @@ class Compression {
|
|
|
3985
4010
|
Guards.uint8Array(Compression._CLASS_NAME, "compressedBytes", compressedBytes);
|
|
3986
4011
|
Guards.arrayOneOf(Compression._CLASS_NAME, "type", type, Object.values(CompressionType));
|
|
3987
4012
|
const blob = new Blob([compressedBytes]);
|
|
3988
|
-
const
|
|
3989
|
-
const
|
|
3990
|
-
const decompressedBlob = await new Response(
|
|
3991
|
-
|
|
3992
|
-
return new Uint8Array(ab);
|
|
4013
|
+
const decompressionStream = new DecompressionStream(type);
|
|
4014
|
+
const decompressionPipe = blob.stream().pipeThrough(decompressionStream);
|
|
4015
|
+
const decompressedBlob = await new Response(decompressionPipe).blob();
|
|
4016
|
+
return decompressedBlob.bytes();
|
|
3993
4017
|
}
|
|
3994
4018
|
}
|
|
3995
4019
|
|
|
@@ -4799,6 +4823,7 @@ exports.NotSupportedError = NotSupportedError;
|
|
|
4799
4823
|
exports.ObjectHelper = ObjectHelper;
|
|
4800
4824
|
exports.RandomHelper = RandomHelper;
|
|
4801
4825
|
exports.StringHelper = StringHelper;
|
|
4826
|
+
exports.Uint8ArrayHelper = Uint8ArrayHelper;
|
|
4802
4827
|
exports.UnauthorizedError = UnauthorizedError;
|
|
4803
4828
|
exports.UnprocessableError = UnprocessableError;
|
|
4804
4829
|
exports.Url = Url;
|
package/dist/esm/index.mjs
CHANGED
|
@@ -3410,6 +3410,32 @@ class RandomHelper {
|
|
|
3410
3410
|
}
|
|
3411
3411
|
}
|
|
3412
3412
|
|
|
3413
|
+
// Copyright 2024 IOTA Stiftung.
|
|
3414
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
3415
|
+
/**
|
|
3416
|
+
* Class to help with uint8 arrays.
|
|
3417
|
+
*/
|
|
3418
|
+
class Uint8ArrayHelper {
|
|
3419
|
+
/**
|
|
3420
|
+
* Concatenate multiple arrays.
|
|
3421
|
+
* @param arrays The array to concatenate.
|
|
3422
|
+
* @returns The combined array.
|
|
3423
|
+
*/
|
|
3424
|
+
static concat(arrays) {
|
|
3425
|
+
let totalLength = 0;
|
|
3426
|
+
for (const array of arrays) {
|
|
3427
|
+
totalLength += array.length;
|
|
3428
|
+
}
|
|
3429
|
+
const concatBytes = new Uint8Array(totalLength);
|
|
3430
|
+
let offset = 0;
|
|
3431
|
+
for (const array of arrays) {
|
|
3432
|
+
concatBytes.set(array, offset);
|
|
3433
|
+
offset += array.length;
|
|
3434
|
+
}
|
|
3435
|
+
return concatBytes;
|
|
3436
|
+
}
|
|
3437
|
+
}
|
|
3438
|
+
|
|
3413
3439
|
// Copyright 2024 IOTA Stiftung.
|
|
3414
3440
|
// SPDX-License-Identifier: Apache-2.0.
|
|
3415
3441
|
/**
|
|
@@ -3960,11 +3986,10 @@ class Compression {
|
|
|
3960
3986
|
Guards.uint8Array(Compression._CLASS_NAME, "bytes", bytes);
|
|
3961
3987
|
Guards.arrayOneOf(Compression._CLASS_NAME, "type", type, Object.values(CompressionType));
|
|
3962
3988
|
const blob = new Blob([bytes]);
|
|
3963
|
-
const
|
|
3964
|
-
const
|
|
3965
|
-
const compressedBlob = await new Response(
|
|
3966
|
-
const
|
|
3967
|
-
const compressedBytes = new Uint8Array(ab);
|
|
3989
|
+
const compressionStream = new CompressionStream(type);
|
|
3990
|
+
const compressionPipe = blob.stream().pipeThrough(compressionStream);
|
|
3991
|
+
const compressedBlob = await new Response(compressionPipe).blob();
|
|
3992
|
+
const compressedBytes = await compressedBlob.bytes();
|
|
3968
3993
|
// GZIP header contains a byte which specifies the OS the
|
|
3969
3994
|
// compression was performed on. We set this to 3 (Unix) to ensure
|
|
3970
3995
|
// that we produce consistent results.
|
|
@@ -3983,11 +4008,10 @@ class Compression {
|
|
|
3983
4008
|
Guards.uint8Array(Compression._CLASS_NAME, "compressedBytes", compressedBytes);
|
|
3984
4009
|
Guards.arrayOneOf(Compression._CLASS_NAME, "type", type, Object.values(CompressionType));
|
|
3985
4010
|
const blob = new Blob([compressedBytes]);
|
|
3986
|
-
const
|
|
3987
|
-
const
|
|
3988
|
-
const decompressedBlob = await new Response(
|
|
3989
|
-
|
|
3990
|
-
return new Uint8Array(ab);
|
|
4011
|
+
const decompressionStream = new DecompressionStream(type);
|
|
4012
|
+
const decompressionPipe = blob.stream().pipeThrough(decompressionStream);
|
|
4013
|
+
const decompressedBlob = await new Response(decompressionPipe).blob();
|
|
4014
|
+
return decompressedBlob.bytes();
|
|
3991
4015
|
}
|
|
3992
4016
|
}
|
|
3993
4017
|
|
|
@@ -4764,4 +4788,4 @@ class Validation {
|
|
|
4764
4788
|
}
|
|
4765
4789
|
}
|
|
4766
4790
|
|
|
4767
|
-
export { AlreadyExistsError, ArrayHelper, AsyncCache, Base32, Base58, Base64, Base64Url, BaseError, BitString, Coerce, CoerceType, ComponentFactory, Compression, CompressionType, ConflictError, Converter, EnvHelper, ErrorHelper, Factory, FilenameHelper, GeneralError, GuardError, Guards, HexHelper, I18n, Is, JsonHelper, NotFoundError, NotImplementedError, NotSupportedError, ObjectHelper, RandomHelper, StringHelper, UnauthorizedError, UnprocessableError, Url, Urn, Validation, ValidationError };
|
|
4791
|
+
export { AlreadyExistsError, ArrayHelper, AsyncCache, Base32, Base58, Base64, Base64Url, BaseError, BitString, Coerce, CoerceType, ComponentFactory, Compression, CompressionType, ConflictError, Converter, EnvHelper, ErrorHelper, Factory, FilenameHelper, GeneralError, GuardError, Guards, HexHelper, I18n, Is, JsonHelper, NotFoundError, NotImplementedError, NotSupportedError, ObjectHelper, RandomHelper, StringHelper, Uint8ArrayHelper, UnauthorizedError, UnprocessableError, Url, Urn, Validation, ValidationError };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Class to help with uint8 arrays.
|
|
3
|
+
*/
|
|
4
|
+
export declare class Uint8ArrayHelper {
|
|
5
|
+
/**
|
|
6
|
+
* Concatenate multiple arrays.
|
|
7
|
+
* @param arrays The array to concatenate.
|
|
8
|
+
* @returns The combined array.
|
|
9
|
+
*/
|
|
10
|
+
static concat(arrays: Uint8Array[]): Uint8Array;
|
|
11
|
+
}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -24,6 +24,7 @@ export * from "./helpers/jsonHelper";
|
|
|
24
24
|
export * from "./helpers/objectHelper";
|
|
25
25
|
export * from "./helpers/randomHelper";
|
|
26
26
|
export * from "./helpers/stringHelper";
|
|
27
|
+
export * from "./helpers/uint8ArrayHelper";
|
|
27
28
|
export * from "./models/coerceType";
|
|
28
29
|
export * from "./models/compressionType";
|
|
29
30
|
export * from "./models/IComponent";
|
package/docs/changelog.md
CHANGED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Class: Uint8ArrayHelper
|
|
2
|
+
|
|
3
|
+
Class to help with uint8 arrays.
|
|
4
|
+
|
|
5
|
+
## Constructors
|
|
6
|
+
|
|
7
|
+
### new Uint8ArrayHelper()
|
|
8
|
+
|
|
9
|
+
> **new Uint8ArrayHelper**(): [`Uint8ArrayHelper`](Uint8ArrayHelper.md)
|
|
10
|
+
|
|
11
|
+
#### Returns
|
|
12
|
+
|
|
13
|
+
[`Uint8ArrayHelper`](Uint8ArrayHelper.md)
|
|
14
|
+
|
|
15
|
+
## Methods
|
|
16
|
+
|
|
17
|
+
### concat()
|
|
18
|
+
|
|
19
|
+
> `static` **concat**(`arrays`): `Uint8Array`
|
|
20
|
+
|
|
21
|
+
Concatenate multiple arrays.
|
|
22
|
+
|
|
23
|
+
#### Parameters
|
|
24
|
+
|
|
25
|
+
##### arrays
|
|
26
|
+
|
|
27
|
+
`Uint8Array`[]
|
|
28
|
+
|
|
29
|
+
The array to concatenate.
|
|
30
|
+
|
|
31
|
+
#### Returns
|
|
32
|
+
|
|
33
|
+
`Uint8Array`
|
|
34
|
+
|
|
35
|
+
The combined array.
|
package/docs/reference/index.md
CHANGED
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
- [ObjectHelper](classes/ObjectHelper.md)
|
|
28
28
|
- [RandomHelper](classes/RandomHelper.md)
|
|
29
29
|
- [StringHelper](classes/StringHelper.md)
|
|
30
|
+
- [Uint8ArrayHelper](classes/Uint8ArrayHelper.md)
|
|
30
31
|
- [BitString](classes/BitString.md)
|
|
31
32
|
- [Url](classes/Url.md)
|
|
32
33
|
- [Urn](classes/Urn.md)
|