@qrkit/bc-ur 2.0.0-beta.9-qrkit.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 +21 -0
- package/README.md +996 -0
- package/dist/commonjs/classes/FountainDecoder.d.ts +125 -0
- package/dist/commonjs/classes/FountainDecoder.js +453 -0
- package/dist/commonjs/classes/FountainDecoder.js.map +1 -0
- package/dist/commonjs/classes/FountainEncoder.d.ts +63 -0
- package/dist/commonjs/classes/FountainEncoder.js +168 -0
- package/dist/commonjs/classes/FountainEncoder.js.map +1 -0
- package/dist/commonjs/classes/RegistryItem.d.ts +104 -0
- package/dist/commonjs/classes/RegistryItem.js +172 -0
- package/dist/commonjs/classes/RegistryItem.js.map +1 -0
- package/dist/commonjs/classes/UR.d.ts +89 -0
- package/dist/commonjs/classes/UR.js +243 -0
- package/dist/commonjs/classes/UR.js.map +1 -0
- package/dist/commonjs/classes/UrFountainDecoder.d.ts +15 -0
- package/dist/commonjs/classes/UrFountainDecoder.js +127 -0
- package/dist/commonjs/classes/UrFountainDecoder.js.map +1 -0
- package/dist/commonjs/classes/UrFountainEncoder.d.ts +42 -0
- package/dist/commonjs/classes/UrFountainEncoder.js +92 -0
- package/dist/commonjs/classes/UrFountainEncoder.js.map +1 -0
- package/dist/commonjs/classes/key.helper.d.ts +27 -0
- package/dist/commonjs/classes/key.helper.js +70 -0
- package/dist/commonjs/classes/key.helper.js.map +1 -0
- package/dist/commonjs/encodingMethods/BytewordEncoding.d.ts +11 -0
- package/dist/commonjs/encodingMethods/BytewordEncoding.js +23 -0
- package/dist/commonjs/encodingMethods/BytewordEncoding.js.map +1 -0
- package/dist/commonjs/encodingMethods/CborEncoding.d.ts +44 -0
- package/dist/commonjs/encodingMethods/CborEncoding.js +151 -0
- package/dist/commonjs/encodingMethods/CborEncoding.js.map +1 -0
- package/dist/commonjs/encodingMethods/HexEncoding.d.ts +8 -0
- package/dist/commonjs/encodingMethods/HexEncoding.js +24 -0
- package/dist/commonjs/encodingMethods/HexEncoding.js.map +1 -0
- package/dist/commonjs/encodingMethods/UrEncoding.d.ts +10 -0
- package/dist/commonjs/encodingMethods/UrEncoding.js +19 -0
- package/dist/commonjs/encodingMethods/UrEncoding.js.map +1 -0
- package/dist/commonjs/encodingMethods/bytewords.d.ts +27 -0
- package/dist/commonjs/encodingMethods/bytewords.js +152 -0
- package/dist/commonjs/encodingMethods/bytewords.js.map +1 -0
- package/dist/commonjs/encodingMethods/index.d.ts +19 -0
- package/dist/commonjs/encodingMethods/index.js +27 -0
- package/dist/commonjs/encodingMethods/index.js.map +1 -0
- package/dist/commonjs/encodingMethods/pipeline.d.ts +19 -0
- package/dist/commonjs/encodingMethods/pipeline.js +80 -0
- package/dist/commonjs/encodingMethods/pipeline.js.map +1 -0
- package/dist/commonjs/enums/EncodingMethodName.d.ts +10 -0
- package/dist/commonjs/enums/EncodingMethodName.js +15 -0
- package/dist/commonjs/enums/EncodingMethodName.js.map +1 -0
- package/dist/commonjs/errors.d.ts +15 -0
- package/dist/commonjs/errors.js +39 -0
- package/dist/commonjs/errors.js.map +1 -0
- package/dist/commonjs/helpers/aliasSampling.d.ts +6 -0
- package/dist/commonjs/helpers/aliasSampling.js +73 -0
- package/dist/commonjs/helpers/aliasSampling.js.map +1 -0
- package/dist/commonjs/helpers/crc32.d.ts +1 -0
- package/dist/commonjs/helpers/crc32.js +19 -0
- package/dist/commonjs/helpers/crc32.js.map +1 -0
- package/dist/commonjs/helpers/fountainUtils.d.ts +40 -0
- package/dist/commonjs/helpers/fountainUtils.js +124 -0
- package/dist/commonjs/helpers/fountainUtils.js.map +1 -0
- package/dist/commonjs/helpers/sha256.d.ts +1 -0
- package/dist/commonjs/helpers/sha256.js +78 -0
- package/dist/commonjs/helpers/sha256.js.map +1 -0
- package/dist/commonjs/helpers/type.helper.d.ts +3 -0
- package/dist/commonjs/helpers/type.helper.js +3 -0
- package/dist/commonjs/helpers/type.helper.js.map +1 -0
- package/dist/commonjs/helpers/uintArrayHelper.d.ts +287 -0
- package/dist/commonjs/helpers/uintArrayHelper.js +545 -0
- package/dist/commonjs/helpers/uintArrayHelper.js.map +1 -0
- package/dist/commonjs/helpers/utils.d.ts +55 -0
- package/dist/commonjs/helpers/utils.js +123 -0
- package/dist/commonjs/helpers/utils.js.map +1 -0
- package/dist/commonjs/index-react-native.d.ts +9 -0
- package/dist/commonjs/index-react-native.js +15 -0
- package/dist/commonjs/index-react-native.js.map +1 -0
- package/dist/commonjs/index.d.ts +21 -0
- package/dist/commonjs/index.js +34 -0
- package/dist/commonjs/index.js.map +1 -0
- package/dist/commonjs/interfaces/IEncodingMethod.d.ts +9 -0
- package/dist/commonjs/interfaces/IEncodingMethod.js +3 -0
- package/dist/commonjs/interfaces/IEncodingMethod.js.map +1 -0
- package/dist/commonjs/package.json +3 -0
- package/dist/commonjs/registry.d.ts +26 -0
- package/dist/commonjs/registry.js +118 -0
- package/dist/commonjs/registry.js.map +1 -0
- package/dist/commonjs/test.utils.d.ts +31 -0
- package/dist/commonjs/test.utils.js +88 -0
- package/dist/commonjs/test.utils.js.map +1 -0
- package/dist/commonjs/wrappers/cbor2-cjs.cjs.map +1 -0
- package/dist/commonjs/wrappers/cbor2.d.ts +2 -0
- package/dist/commonjs/wrappers/cbor2.js +14 -0
- package/dist/commonjs/wrappers/cbor2Wrapper.d.ts +14 -0
- package/dist/commonjs/wrappers/cbor2Wrapper.js +49 -0
- package/dist/commonjs/wrappers/cbor2Wrapper.js.map +1 -0
- package/dist/commonjs/xoshiro.d.ts +12 -0
- package/dist/commonjs/xoshiro.js +52 -0
- package/dist/commonjs/xoshiro.js.map +1 -0
- package/dist/esm/classes/FountainDecoder.d.ts +125 -0
- package/dist/esm/classes/FountainDecoder.js +447 -0
- package/dist/esm/classes/FountainDecoder.js.map +1 -0
- package/dist/esm/classes/FountainEncoder.d.ts +63 -0
- package/dist/esm/classes/FountainEncoder.js +164 -0
- package/dist/esm/classes/FountainEncoder.js.map +1 -0
- package/dist/esm/classes/RegistryItem.d.ts +104 -0
- package/dist/esm/classes/RegistryItem.js +166 -0
- package/dist/esm/classes/RegistryItem.js.map +1 -0
- package/dist/esm/classes/UR.d.ts +89 -0
- package/dist/esm/classes/UR.js +239 -0
- package/dist/esm/classes/UR.js.map +1 -0
- package/dist/esm/classes/UrFountainDecoder.d.ts +15 -0
- package/dist/esm/classes/UrFountainDecoder.js +123 -0
- package/dist/esm/classes/UrFountainDecoder.js.map +1 -0
- package/dist/esm/classes/UrFountainEncoder.d.ts +42 -0
- package/dist/esm/classes/UrFountainEncoder.js +88 -0
- package/dist/esm/classes/UrFountainEncoder.js.map +1 -0
- package/dist/esm/classes/key.helper.d.ts +27 -0
- package/dist/esm/classes/key.helper.js +66 -0
- package/dist/esm/classes/key.helper.js.map +1 -0
- package/dist/esm/encodingMethods/BytewordEncoding.d.ts +11 -0
- package/dist/esm/encodingMethods/BytewordEncoding.js +19 -0
- package/dist/esm/encodingMethods/BytewordEncoding.js.map +1 -0
- package/dist/esm/encodingMethods/CborEncoding.d.ts +44 -0
- package/dist/esm/encodingMethods/CborEncoding.js +147 -0
- package/dist/esm/encodingMethods/CborEncoding.js.map +1 -0
- package/dist/esm/encodingMethods/HexEncoding.d.ts +8 -0
- package/dist/esm/encodingMethods/HexEncoding.js +20 -0
- package/dist/esm/encodingMethods/HexEncoding.js.map +1 -0
- package/dist/esm/encodingMethods/UrEncoding.d.ts +10 -0
- package/dist/esm/encodingMethods/UrEncoding.js +15 -0
- package/dist/esm/encodingMethods/UrEncoding.js.map +1 -0
- package/dist/esm/encodingMethods/bytewords.d.ts +27 -0
- package/dist/esm/encodingMethods/bytewords.js +147 -0
- package/dist/esm/encodingMethods/bytewords.js.map +1 -0
- package/dist/esm/encodingMethods/index.d.ts +19 -0
- package/dist/esm/encodingMethods/index.js +24 -0
- package/dist/esm/encodingMethods/index.js.map +1 -0
- package/dist/esm/encodingMethods/pipeline.d.ts +19 -0
- package/dist/esm/encodingMethods/pipeline.js +76 -0
- package/dist/esm/encodingMethods/pipeline.js.map +1 -0
- package/dist/esm/enums/EncodingMethodName.d.ts +10 -0
- package/dist/esm/enums/EncodingMethodName.js +12 -0
- package/dist/esm/enums/EncodingMethodName.js.map +1 -0
- package/dist/esm/errors.d.ts +15 -0
- package/dist/esm/errors.js +31 -0
- package/dist/esm/errors.js.map +1 -0
- package/dist/esm/helpers/aliasSampling.d.ts +6 -0
- package/dist/esm/helpers/aliasSampling.js +70 -0
- package/dist/esm/helpers/aliasSampling.js.map +1 -0
- package/dist/esm/helpers/crc32.d.ts +1 -0
- package/dist/esm/helpers/crc32.js +16 -0
- package/dist/esm/helpers/crc32.js.map +1 -0
- package/dist/esm/helpers/fountainUtils.d.ts +40 -0
- package/dist/esm/helpers/fountainUtils.js +114 -0
- package/dist/esm/helpers/fountainUtils.js.map +1 -0
- package/dist/esm/helpers/sha256.d.ts +1 -0
- package/dist/esm/helpers/sha256.js +75 -0
- package/dist/esm/helpers/sha256.js.map +1 -0
- package/dist/esm/helpers/type.helper.d.ts +3 -0
- package/dist/esm/helpers/type.helper.js +2 -0
- package/dist/esm/helpers/type.helper.js.map +1 -0
- package/dist/esm/helpers/uintArrayHelper.d.ts +287 -0
- package/dist/esm/helpers/uintArrayHelper.js +526 -0
- package/dist/esm/helpers/uintArrayHelper.js.map +1 -0
- package/dist/esm/helpers/utils.d.ts +55 -0
- package/dist/esm/helpers/utils.js +102 -0
- package/dist/esm/helpers/utils.js.map +1 -0
- package/dist/esm/index-react-native.d.ts +9 -0
- package/dist/esm/index-react-native.js +12 -0
- package/dist/esm/index-react-native.js.map +1 -0
- package/dist/esm/index.d.ts +21 -0
- package/dist/esm/index.js +16 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/interfaces/IEncodingMethod.d.ts +9 -0
- package/dist/esm/interfaces/IEncodingMethod.js +2 -0
- package/dist/esm/interfaces/IEncodingMethod.js.map +1 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/registry.d.ts +26 -0
- package/dist/esm/registry.js +114 -0
- package/dist/esm/registry.js.map +1 -0
- package/dist/esm/test.utils.d.ts +31 -0
- package/dist/esm/test.utils.js +83 -0
- package/dist/esm/test.utils.js.map +1 -0
- package/dist/esm/wrappers/cbor2-deno.d.mts +2 -0
- package/dist/esm/wrappers/cbor2-deno.mjs +5 -0
- package/dist/esm/wrappers/cbor2-deno.mjs.map +1 -0
- package/dist/esm/wrappers/cbor2.d.ts +2 -0
- package/dist/esm/wrappers/cbor2.js +5 -0
- package/dist/esm/wrappers/cbor2.js.map +1 -0
- package/dist/esm/wrappers/cbor2Wrapper.d.ts +5 -0
- package/dist/esm/wrappers/cbor2Wrapper.js +6 -0
- package/dist/esm/wrappers/cbor2Wrapper.js.map +1 -0
- package/dist/esm/xoshiro.d.ts +12 -0
- package/dist/esm/xoshiro.js +47 -0
- package/dist/esm/xoshiro.js.map +1 -0
- package/dist/web/bytewords.js +335 -0
- package/index.html +98 -0
- package/package.json +94 -0
- package/src/classes/FountainDecoder.ts +539 -0
- package/src/classes/FountainEncoder.ts +211 -0
- package/src/classes/RegistryItem.ts +240 -0
- package/src/classes/UR.ts +308 -0
- package/src/classes/UrFountainDecoder.ts +142 -0
- package/src/classes/UrFountainEncoder.ts +103 -0
- package/src/classes/key.helper.ts +85 -0
- package/src/encodingMethods/BytewordEncoding.ts +23 -0
- package/src/encodingMethods/CborEncoding.ts +196 -0
- package/src/encodingMethods/HexEncoding.ts +23 -0
- package/src/encodingMethods/UrEncoding.ts +19 -0
- package/src/encodingMethods/bytewords.ts +215 -0
- package/src/encodingMethods/index.ts +26 -0
- package/src/encodingMethods/pipeline.ts +103 -0
- package/src/enums/EncodingMethodName.ts +10 -0
- package/src/errors.ts +34 -0
- package/src/helpers/aliasSampling.ts +87 -0
- package/src/helpers/crc32.ts +19 -0
- package/src/helpers/fountainUtils.ts +157 -0
- package/src/helpers/sha256.ts +88 -0
- package/src/helpers/type.helper.ts +1 -0
- package/src/helpers/uintArrayHelper.ts +611 -0
- package/src/helpers/utils.ts +135 -0
- package/src/index-react-native.ts +12 -0
- package/src/index.ts +44 -0
- package/src/interfaces/IEncodingMethod.ts +10 -0
- package/src/registry.ts +146 -0
- package/src/test.utils.ts +105 -0
- package/src/wrappers/cbor2-cjs.cts +6 -0
- package/src/wrappers/cbor2-deno.mts +6 -0
- package/src/wrappers/cbor2.ts +7 -0
- package/src/wrappers/cbor2Wrapper.ts +14 -0
- package/src/xoshiro.ts +66 -0
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
export type TypedArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array | BigInt64Array | BigUint64Array;
|
|
2
|
+
/**
|
|
3
|
+
Check if the given value is an instance of `Uint8Array`.
|
|
4
|
+
|
|
5
|
+
Replacement for [`Buffer.isBuffer()`](https://nodejs.org/api/buffer.html#static-method-bufferisbufferobj).
|
|
6
|
+
|
|
7
|
+
@example
|
|
8
|
+
```
|
|
9
|
+
import {isUint8Array} from 'uint8array-extras';
|
|
10
|
+
|
|
11
|
+
console.log(isUint8Array(new Uint8Array()));
|
|
12
|
+
//=> true
|
|
13
|
+
|
|
14
|
+
console.log(isUint8Array(Buffer.from('x')));
|
|
15
|
+
//=> true
|
|
16
|
+
|
|
17
|
+
console.log(isUint8Array(new ArrayBuffer(10)));
|
|
18
|
+
//=> false
|
|
19
|
+
```
|
|
20
|
+
*/
|
|
21
|
+
export declare function isUint8Array(value: unknown): value is Uint8Array;
|
|
22
|
+
/**
|
|
23
|
+
Throw a `TypeError` if the given value is not an instance of `Uint8Array`.
|
|
24
|
+
|
|
25
|
+
@example
|
|
26
|
+
```
|
|
27
|
+
import {assertUint8Array} from 'uint8array-extras';
|
|
28
|
+
|
|
29
|
+
try {
|
|
30
|
+
assertUint8Array(new ArrayBuffer(10)); // Throws a TypeError
|
|
31
|
+
} catch (error) {
|
|
32
|
+
console.error(error.message);
|
|
33
|
+
}
|
|
34
|
+
```
|
|
35
|
+
*/
|
|
36
|
+
export declare function assertUint8Array(value: unknown): asserts value is Uint8Array;
|
|
37
|
+
/**
|
|
38
|
+
Convert a value to a `Uint8Array` without copying its data.
|
|
39
|
+
|
|
40
|
+
This can be useful for converting a `Buffer` to a pure `Uint8Array`. `Buffer` is already an `Uint8Array` subclass, but [`Buffer` alters some behavior](https://sindresorhus.com/blog/goodbye-nodejs-buffer), so it can be useful to cast it to a pure `Uint8Array` before returning it.
|
|
41
|
+
|
|
42
|
+
Tip: If you want a copy, just call `.slice()` on the return value.
|
|
43
|
+
*/
|
|
44
|
+
export declare function toUint8Array(value: TypedArray | ArrayBuffer | DataView): Uint8Array;
|
|
45
|
+
/**
|
|
46
|
+
Concatenate the given arrays into a new array.
|
|
47
|
+
|
|
48
|
+
If `arrays` is empty, it will return a zero-sized `Uint8Array`.
|
|
49
|
+
|
|
50
|
+
If `totalLength` is not specified, it is calculated from summing the lengths of the given arrays.
|
|
51
|
+
|
|
52
|
+
Replacement for [`Buffer.concat()`](https://nodejs.org/api/buffer.html#static-method-bufferconcatlist-totallength).
|
|
53
|
+
|
|
54
|
+
@example
|
|
55
|
+
```
|
|
56
|
+
import {concatUint8Arrays} from 'uint8array-extras';
|
|
57
|
+
|
|
58
|
+
const a = new Uint8Array([1, 2, 3]);
|
|
59
|
+
const b = new Uint8Array([4, 5, 6]);
|
|
60
|
+
|
|
61
|
+
console.log(concatUint8Arrays([a, b]));
|
|
62
|
+
//=> Uint8Array [1, 2, 3, 4, 5, 6]
|
|
63
|
+
```
|
|
64
|
+
*/
|
|
65
|
+
export declare function concatUint8Arrays(arrays: Uint8Array[], totalLength?: number): Uint8Array;
|
|
66
|
+
/**
|
|
67
|
+
Check if two arrays are identical by verifying that they contain the same bytes in the same sequence.
|
|
68
|
+
|
|
69
|
+
Replacement for [`Buffer#equals()`](https://nodejs.org/api/buffer.html#bufequalsotherbuffer).
|
|
70
|
+
|
|
71
|
+
@example
|
|
72
|
+
```
|
|
73
|
+
import {areUint8ArraysEqual} from 'uint8array-extras';
|
|
74
|
+
|
|
75
|
+
const a = new Uint8Array([1, 2, 3]);
|
|
76
|
+
const b = new Uint8Array([1, 2, 3]);
|
|
77
|
+
const c = new Uint8Array([4, 5, 6]);
|
|
78
|
+
|
|
79
|
+
console.log(areUint8ArraysEqual(a, b));
|
|
80
|
+
//=> true
|
|
81
|
+
|
|
82
|
+
console.log(areUint8ArraysEqual(a, c));
|
|
83
|
+
//=> false
|
|
84
|
+
```
|
|
85
|
+
*/
|
|
86
|
+
export declare function areUint8ArraysEqual(a: Uint8Array, b: Uint8Array): boolean;
|
|
87
|
+
/**
|
|
88
|
+
Compare two arrays and indicate their relative order or equality. Useful for sorting.
|
|
89
|
+
|
|
90
|
+
Replacement for [`Buffer.compare()`](https://nodejs.org/api/buffer.html#static-method-buffercomparebuf1-buf2).
|
|
91
|
+
|
|
92
|
+
@example
|
|
93
|
+
```
|
|
94
|
+
import {compareUint8Arrays} from 'uint8array-extras';
|
|
95
|
+
|
|
96
|
+
const array1 = new Uint8Array([1, 2, 3]);
|
|
97
|
+
const array2 = new Uint8Array([4, 5, 6]);
|
|
98
|
+
const array3 = new Uint8Array([7, 8, 9]);
|
|
99
|
+
|
|
100
|
+
[array3, array1, array2].sort(compareUint8Arrays);
|
|
101
|
+
//=> [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
|
|
102
|
+
```
|
|
103
|
+
*/
|
|
104
|
+
export declare function compareUint8Arrays(a: Uint8Array, b: Uint8Array): -1 | 0 | 1;
|
|
105
|
+
/**
|
|
106
|
+
Convert a `Uint8Array` to a string.
|
|
107
|
+
|
|
108
|
+
@param encoding - The [encoding](https://developer.mozilla.org/en-US/docs/Web/API/Encoding_API/Encodings) to convert from. Default: `'utf8'`
|
|
109
|
+
|
|
110
|
+
Replacement for [`Buffer#toString()`](https://nodejs.org/api/buffer.html#buftostringencoding-start-end). For the `encoding` parameter, `latin1` should be used instead of `binary` and `utf-16le` instead of `utf16le`.
|
|
111
|
+
|
|
112
|
+
@example
|
|
113
|
+
```
|
|
114
|
+
import {uint8ArrayToString} from 'uint8array-extras';
|
|
115
|
+
|
|
116
|
+
const byteArray = new Uint8Array([72, 101, 108, 108, 111]);
|
|
117
|
+
console.log(uint8ArrayToString(byteArray));
|
|
118
|
+
//=> 'Hello'
|
|
119
|
+
|
|
120
|
+
const zh = new Uint8Array([167, 65, 166, 110]);
|
|
121
|
+
console.log(uint8ArrayToString(zh, 'big5'));
|
|
122
|
+
//=> '你好'
|
|
123
|
+
|
|
124
|
+
const ja = new Uint8Array([130, 177, 130, 241, 130, 201, 130, 191, 130, 205]);
|
|
125
|
+
console.log(uint8ArrayToString(ja, 'shift-jis'));
|
|
126
|
+
//=> 'こんにちは'
|
|
127
|
+
```
|
|
128
|
+
*/
|
|
129
|
+
export declare function uint8ArrayToString(array: Uint8Array | ArrayBuffer, encoding?: string): string;
|
|
130
|
+
/**
|
|
131
|
+
Convert a string to a `Uint8Array` (using UTF-8 encoding).
|
|
132
|
+
|
|
133
|
+
Replacement for [`Buffer.from('Hello')`](https://nodejs.org/api/buffer.html#static-method-bufferfromstring-encoding).
|
|
134
|
+
|
|
135
|
+
@example
|
|
136
|
+
```
|
|
137
|
+
import {stringToUint8Array} from 'uint8array-extras';
|
|
138
|
+
|
|
139
|
+
console.log(stringToUint8Array('Hello'));
|
|
140
|
+
//=> Uint8Array [72, 101, 108, 108, 111]
|
|
141
|
+
```
|
|
142
|
+
*/
|
|
143
|
+
export declare function stringToUint8Array(string: string): Uint8Array;
|
|
144
|
+
/**
|
|
145
|
+
Convert a `Uint8Array` to a Base64-encoded string.
|
|
146
|
+
|
|
147
|
+
Specify `{urlSafe: true}` to get a [Base64URL](https://base64.guru/standards/base64url)-encoded string.
|
|
148
|
+
|
|
149
|
+
Replacement for [`Buffer#toString('base64')`](https://nodejs.org/api/buffer.html#buftostringencoding-start-end).
|
|
150
|
+
|
|
151
|
+
@example
|
|
152
|
+
```
|
|
153
|
+
import {uint8ArrayToBase64} from 'uint8array-extras';
|
|
154
|
+
|
|
155
|
+
const byteArray = new Uint8Array([72, 101, 108, 108, 111]);
|
|
156
|
+
|
|
157
|
+
console.log(uint8ArrayToBase64(byteArray));
|
|
158
|
+
//=> 'SGVsbG8='
|
|
159
|
+
```
|
|
160
|
+
*/
|
|
161
|
+
export declare function uint8ArrayToBase64(array: Uint8Array, { urlSafe }?: {
|
|
162
|
+
urlSafe?: boolean;
|
|
163
|
+
}): string;
|
|
164
|
+
/**
|
|
165
|
+
Convert a Base64-encoded or [Base64URL](https://base64.guru/standards/base64url)-encoded string to a `Uint8Array`.
|
|
166
|
+
|
|
167
|
+
Replacement for [`Buffer.from('SGVsbG8=', 'base64')`](https://nodejs.org/api/buffer.html#static-method-bufferfromstring-encoding).
|
|
168
|
+
|
|
169
|
+
@example
|
|
170
|
+
```
|
|
171
|
+
import {base64ToUint8Array} from 'uint8array-extras';
|
|
172
|
+
|
|
173
|
+
console.log(base64ToUint8Array('SGVsbG8='));
|
|
174
|
+
//=> Uint8Array [72, 101, 108, 108, 111]
|
|
175
|
+
```
|
|
176
|
+
*/
|
|
177
|
+
export declare function base64ToUint8Array(base64String: string): Uint8Array;
|
|
178
|
+
/**
|
|
179
|
+
Encode a string to Base64-encoded string.
|
|
180
|
+
|
|
181
|
+
Specify `{urlSafe: true}` to get a [Base64URL](https://base64.guru/standards/base64url)-encoded string.
|
|
182
|
+
|
|
183
|
+
Replacement for `Buffer.from('Hello').toString('base64')` and [`btoa()`](https://developer.mozilla.org/en-US/docs/Web/API/btoa).
|
|
184
|
+
|
|
185
|
+
@example
|
|
186
|
+
```
|
|
187
|
+
import {stringToBase64} from 'uint8array-extras';
|
|
188
|
+
|
|
189
|
+
console.log(stringToBase64('Hello'));
|
|
190
|
+
//=> 'SGVsbG8='
|
|
191
|
+
```
|
|
192
|
+
*/
|
|
193
|
+
export declare function stringToBase64(string: string, { urlSafe }?: {
|
|
194
|
+
urlSafe?: boolean;
|
|
195
|
+
}): string;
|
|
196
|
+
/**
|
|
197
|
+
Decode a Base64-encoded or [Base64URL](https://base64.guru/standards/base64url)-encoded string to a string.
|
|
198
|
+
|
|
199
|
+
Replacement for `Buffer.from('SGVsbG8=', 'base64').toString()` and [`atob()`](https://developer.mozilla.org/en-US/docs/Web/API/atob).
|
|
200
|
+
|
|
201
|
+
@example
|
|
202
|
+
```
|
|
203
|
+
import {base64ToString} from 'uint8array-extras';
|
|
204
|
+
|
|
205
|
+
console.log(base64ToString('SGVsbG8='));
|
|
206
|
+
//=> 'Hello'
|
|
207
|
+
```
|
|
208
|
+
*/
|
|
209
|
+
export declare function base64ToString(base64String: string): string;
|
|
210
|
+
/**
|
|
211
|
+
Convert a `Uint8Array` to a Hex string.
|
|
212
|
+
|
|
213
|
+
Replacement for [`Buffer#toString('hex')`](https://nodejs.org/api/buffer.html#buftostringencoding-start-end).
|
|
214
|
+
|
|
215
|
+
@example
|
|
216
|
+
```
|
|
217
|
+
import {uint8ArrayToHex} from 'uint8array-extras';
|
|
218
|
+
|
|
219
|
+
const byteArray = new Uint8Array([72, 101, 108, 108, 111]);
|
|
220
|
+
|
|
221
|
+
console.log(uint8ArrayToHex(byteArray));
|
|
222
|
+
//=> '48656c6c6f'
|
|
223
|
+
```
|
|
224
|
+
*/
|
|
225
|
+
export declare function uint8ArrayToHex(array: Uint8Array): string;
|
|
226
|
+
/**
|
|
227
|
+
Convert a Hex string to a `Uint8Array`.
|
|
228
|
+
|
|
229
|
+
Replacement for [`Buffer.from('48656c6c6f', 'hex')`](https://nodejs.org/api/buffer.html#static-method-bufferfromstring-encoding).
|
|
230
|
+
|
|
231
|
+
@example
|
|
232
|
+
```
|
|
233
|
+
import {hexToUint8Array} from 'uint8array-extras';
|
|
234
|
+
|
|
235
|
+
console.log(hexToUint8Array('48656c6c6f'));
|
|
236
|
+
//=> Uint8Array [72, 101, 108, 108, 111]
|
|
237
|
+
```
|
|
238
|
+
*/
|
|
239
|
+
export declare function hexToUint8Array(hexString: string): Uint8Array;
|
|
240
|
+
/**
|
|
241
|
+
Read `DataView#byteLength` number of bytes from the given view, up to 48-bit.
|
|
242
|
+
|
|
243
|
+
Replacement for [`Buffer#readUintBE`](https://nodejs.org/api/buffer.html#bufreadintbeoffset-bytelength)
|
|
244
|
+
|
|
245
|
+
@example
|
|
246
|
+
```
|
|
247
|
+
import {getUintBE} from 'uint8array-extras';
|
|
248
|
+
|
|
249
|
+
const byteArray = new Uint8Array([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]);
|
|
250
|
+
|
|
251
|
+
console.log(getUintBE(new DataView(byteArray.buffer)));
|
|
252
|
+
//=> 20015998341291
|
|
253
|
+
```
|
|
254
|
+
*/
|
|
255
|
+
export declare function getUintBE(view: DataView): number;
|
|
256
|
+
/**
|
|
257
|
+
Find the index of the first occurrence of the given sequence of bytes (`value`) within the given `Uint8Array` (`array`).
|
|
258
|
+
|
|
259
|
+
Replacement for [`Buffer#indexOf`](https://nodejs.org/api/buffer.html#bufindexofvalue-byteoffset-encoding). `Uint8Array#indexOf` only takes a number which is different from Buffer's `indexOf` implementation.
|
|
260
|
+
|
|
261
|
+
@example
|
|
262
|
+
```
|
|
263
|
+
import {indexOf} from 'uint8array-extras';
|
|
264
|
+
|
|
265
|
+
const byteArray = new Uint8Array([0x12, 0x34, 0x56, 0x78, 0x90, 0xab, 0xcd, 0xef]);
|
|
266
|
+
|
|
267
|
+
console.log(indexOf(byteArray, new Uint8Array([0x78, 0x90])));
|
|
268
|
+
//=> 3
|
|
269
|
+
```
|
|
270
|
+
*/
|
|
271
|
+
export declare function indexOf(array: Uint8Array, value: Uint8Array): number;
|
|
272
|
+
/**
|
|
273
|
+
Checks if the given sequence of bytes (`value`) is within the given `Uint8Array` (`array`).
|
|
274
|
+
|
|
275
|
+
Returns true if the value is included, otherwise false.
|
|
276
|
+
|
|
277
|
+
Replacement for [`Buffer#includes`](https://nodejs.org/api/buffer.html#bufincludesvalue-byteoffset-encoding). `Uint8Array#includes` only takes a number which is different from Buffer's `includes` implementation.
|
|
278
|
+
|
|
279
|
+
import {includes} from 'uint8array-extras';
|
|
280
|
+
|
|
281
|
+
const byteArray = new Uint8Array([0x12, 0x34, 0x56, 0x78, 0x90, 0xab, 0xcd, 0xef]);
|
|
282
|
+
|
|
283
|
+
console.log(includes(byteArray, new Uint8Array([0x78, 0x90])));
|
|
284
|
+
//=> true
|
|
285
|
+
```
|
|
286
|
+
*/
|
|
287
|
+
export declare function includes(array: Uint8Array, value: Uint8Array): boolean;
|