@airgap/coinlib-core 0.13.8-beta.8 → 0.13.8
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/dependencies/src/@stablelib/binary-1.0.1/packages/binary/binary.d.ts +230 -0
- package/dependencies/src/@stablelib/binary-1.0.1/packages/binary/binary.js +471 -0
- package/dependencies/src/@stablelib/binary-1.0.1/packages/binary/binary.js.map +1 -0
- package/dependencies/src/@stablelib/blake2b-1.0.1/packages/blake2b/blake2b.d.ts +76 -0
- package/dependencies/src/@stablelib/blake2b-1.0.1/packages/blake2b/blake2b.js +455 -0
- package/dependencies/src/@stablelib/blake2b-1.0.1/packages/blake2b/blake2b.js.map +1 -0
- package/dependencies/src/@stablelib/ed25519-1.0.3/packages/ed25519/ed25519.d.ts +27 -0
- package/dependencies/src/@stablelib/ed25519-1.0.3/packages/ed25519/ed25519.js +848 -0
- package/dependencies/src/@stablelib/ed25519-1.0.3/packages/ed25519/ed25519.js.map +1 -0
- package/dependencies/src/@stablelib/hash-1.0.1/packages/hash/hash.d.ts +22 -0
- package/dependencies/src/@stablelib/hash-1.0.1/packages/hash/hash.js +14 -0
- package/dependencies/src/@stablelib/hash-1.0.1/packages/hash/hash.js.map +1 -0
- package/dependencies/src/@stablelib/int-1.0.1/packages/int/int.d.ts +29 -0
- package/dependencies/src/@stablelib/int-1.0.1/packages/int/int.js +63 -0
- package/dependencies/src/@stablelib/int-1.0.1/packages/int/int.js.map +1 -0
- package/dependencies/src/@stablelib/random-1.0.2/packages/random/random.d.ts +36 -0
- package/dependencies/src/@stablelib/random-1.0.2/packages/random/random.js +87 -0
- package/dependencies/src/@stablelib/random-1.0.2/packages/random/random.js.map +1 -0
- package/dependencies/src/@stablelib/random-1.0.2/packages/random/source/browser.d.ts +8 -0
- package/dependencies/src/@stablelib/random-1.0.2/packages/random/source/browser.js +33 -0
- package/dependencies/src/@stablelib/random-1.0.2/packages/random/source/browser.js.map +1 -0
- package/dependencies/src/@stablelib/random-1.0.2/packages/random/source/index.d.ts +11 -0
- package/dependencies/src/@stablelib/random-1.0.2/packages/random/source/index.js +5 -0
- package/dependencies/src/@stablelib/random-1.0.2/packages/random/source/index.js.map +1 -0
- package/dependencies/src/@stablelib/random-1.0.2/packages/random/source/node.d.ts +8 -0
- package/dependencies/src/@stablelib/random-1.0.2/packages/random/source/node.js +43 -0
- package/dependencies/src/@stablelib/random-1.0.2/packages/random/source/node.js.map +1 -0
- package/dependencies/src/@stablelib/random-1.0.2/packages/random/source/system.d.ts +8 -0
- package/dependencies/src/@stablelib/random-1.0.2/packages/random/source/system.js +37 -0
- package/dependencies/src/@stablelib/random-1.0.2/packages/random/source/system.js.map +1 -0
- package/dependencies/src/@stablelib/sha512/packages/sha512/sha512.d.ts +73 -0
- package/dependencies/src/@stablelib/sha512/packages/sha512/sha512.js +552 -0
- package/dependencies/src/@stablelib/sha512/packages/sha512/sha512.js.map +1 -0
- package/dependencies/src/@stablelib/sha512-1.0.1/packages/sha512/sha512.d.ts +73 -0
- package/dependencies/src/@stablelib/sha512-1.0.1/packages/sha512/sha512.js +552 -0
- package/dependencies/src/@stablelib/sha512-1.0.1/packages/sha512/sha512.js.map +1 -0
- package/dependencies/src/@stablelib/wipe-1.0.1/packages/wipe/wipe.d.ts +18 -0
- package/dependencies/src/@stablelib/wipe-1.0.1/packages/wipe/wipe.js +29 -0
- package/dependencies/src/@stablelib/wipe-1.0.1/packages/wipe/wipe.js.map +1 -0
- package/dependencies/src/@taquito/{local-forging-8.0.1-beta.1 → local-forging-15.0.1}/packages/taquito-local-forging/src/codec.d.ts +22 -4
- package/dependencies/src/@taquito/{local-forging-8.0.1-beta.1 → local-forging-15.0.1}/packages/taquito-local-forging/src/codec.js +104 -13
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/codec.js.map +1 -0
- package/dependencies/src/@taquito/{local-forging-8.0.1-beta.1 → local-forging-15.0.1}/packages/taquito-local-forging/src/constants.d.ts +17 -1
- package/dependencies/src/@taquito/{local-forging-8.0.1-beta.1 → local-forging-15.0.1}/packages/taquito-local-forging/src/constants.js +44 -6
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/constants.js.map +1 -0
- package/dependencies/src/@taquito/{local-forging-8.0.1-beta.1 → local-forging-15.0.1}/packages/taquito-local-forging/src/decoder.d.ts +1 -1
- package/dependencies/src/@taquito/{local-forging-8.0.1-beta.1 → local-forging-15.0.1}/packages/taquito-local-forging/src/decoder.js +30 -0
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/decoder.js.map +1 -0
- package/dependencies/src/@taquito/{local-forging-8.0.1-beta.1 → local-forging-15.0.1}/packages/taquito-local-forging/src/encoder.d.ts +0 -0
- package/dependencies/src/@taquito/{local-forging-8.0.1-beta.1 → local-forging-15.0.1}/packages/taquito-local-forging/src/encoder.js +28 -0
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/encoder.js.map +1 -0
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/error.d.ts +89 -0
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/error.js +169 -0
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/error.js.map +1 -0
- package/dependencies/src/@taquito/{local-forging-8.0.1-beta.1/packages/taquito/src/forger → local-forging-15.0.1/packages/taquito-local-forging/src}/interface.d.ts +1 -1
- package/dependencies/src/@taquito/{local-forging-8.0.1-beta.1/packages/taquito/src/forger → local-forging-15.0.1/packages/taquito-local-forging/src}/interface.js +0 -0
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/interface.js.map +1 -0
- package/dependencies/src/@taquito/{local-forging-8.0.1-beta.1 → local-forging-15.0.1}/packages/taquito-local-forging/src/michelson/codec.d.ts +6 -5
- package/dependencies/src/@taquito/{local-forging-8.0.1-beta.1 → local-forging-15.0.1}/packages/taquito-local-forging/src/michelson/codec.js +62 -19
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/michelson/codec.js.map +1 -0
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/proto14-kathmandu/codec-proto14.d.ts +15 -0
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/proto14-kathmandu/codec-proto14.js +80 -0
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/proto14-kathmandu/codec-proto14.js.map +1 -0
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/proto14-kathmandu/constants-proto14.d.ts +12 -0
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/proto14-kathmandu/constants-proto14.js +184 -0
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/proto14-kathmandu/constants-proto14.js.map +1 -0
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/proto14-kathmandu/decoder-proto14.d.ts +5 -0
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/proto14-kathmandu/decoder-proto14.js +81 -0
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/proto14-kathmandu/decoder-proto14.js.map +1 -0
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/proto14-kathmandu/encoder-proto14.d.ts +4 -0
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/proto14-kathmandu/encoder-proto14.js +76 -0
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/proto14-kathmandu/encoder-proto14.js.map +1 -0
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/proto14-kathmandu/michelson/codec-proto14.d.ts +14 -0
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/proto14-kathmandu/michelson/codec-proto14.js +150 -0
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/proto14-kathmandu/michelson/codec-proto14.js.map +1 -0
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/protocols.d.ts +17 -0
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/protocols.js +41 -0
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/protocols.js.map +1 -0
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/schema/operation.d.ts +150 -0
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/schema/operation.js +217 -0
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/schema/operation.js.map +1 -0
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/taquito-local-forging.d.ts +26 -0
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/taquito-local-forging.js +115 -0
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/taquito-local-forging.js.map +1 -0
- package/dependencies/src/@taquito/{local-forging-8.0.1-beta.1 → local-forging-15.0.1}/packages/taquito-local-forging/src/uint8array-consumer.d.ts +0 -0
- package/dependencies/src/@taquito/{local-forging-8.0.1-beta.1 → local-forging-15.0.1}/packages/taquito-local-forging/src/uint8array-consumer.js +2 -1
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/uint8array-consumer.js.map +1 -0
- package/dependencies/src/@taquito/{local-forging-8.0.1-beta.1 → local-forging-15.0.1}/packages/taquito-local-forging/src/utils.d.ts +0 -0
- package/dependencies/src/@taquito/{local-forging-8.0.1-beta.1 → local-forging-15.0.1}/packages/taquito-local-forging/src/utils.js +0 -0
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/utils.js.map +1 -0
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/validator.d.ts +13 -0
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/validator.js +52 -0
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/validator.js.map +1 -0
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/version.d.ts +4 -0
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/version.js +9 -0
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/version.js.map +1 -0
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-rpc/src/opkind.d.ts +34 -0
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-rpc/src/opkind.js +39 -0
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-rpc/src/opkind.js.map +1 -0
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-rpc/src/types.d.ts +1590 -0
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-rpc/src/types.js +35 -0
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-rpc/src/types.js.map +1 -0
- package/dependencies/src/@taquito/{utils-8.0.1-beta.1 → utils-15.0.1}/packages/taquito-utils/src/constants.d.ts +27 -3
- package/dependencies/src/@taquito/{utils-8.0.1-beta.1 → utils-15.0.1}/packages/taquito-utils/src/constants.js +40 -1
- package/dependencies/src/@taquito/utils-15.0.1/packages/taquito-utils/src/constants.js.map +1 -0
- package/dependencies/src/@taquito/utils-15.0.1/packages/taquito-utils/src/errors.d.ts +145 -0
- package/dependencies/src/@taquito/utils-15.0.1/packages/taquito-utils/src/errors.js +270 -0
- package/dependencies/src/@taquito/utils-15.0.1/packages/taquito-utils/src/errors.js.map +1 -0
- package/dependencies/src/@taquito/utils-15.0.1/packages/taquito-utils/src/format.d.ts +4 -0
- package/dependencies/src/@taquito/utils-15.0.1/packages/taquito-utils/src/format.js +33 -0
- package/dependencies/src/@taquito/utils-15.0.1/packages/taquito-utils/src/format.js.map +1 -0
- package/dependencies/src/@taquito/utils-15.0.1/packages/taquito-utils/src/taquito-utils.d.ts +163 -0
- package/dependencies/src/@taquito/utils-15.0.1/packages/taquito-utils/src/taquito-utils.js +438 -0
- package/dependencies/src/@taquito/utils-15.0.1/packages/taquito-utils/src/taquito-utils.js.map +1 -0
- package/dependencies/src/@taquito/{utils-8.0.1-beta.1 → utils-15.0.1}/packages/taquito-utils/src/validators.d.ts +63 -9
- package/dependencies/src/@taquito/{utils-8.0.1-beta.1 → utils-15.0.1}/packages/taquito-utils/src/validators.js +85 -8
- package/dependencies/src/@taquito/utils-15.0.1/packages/taquito-utils/src/validators.js.map +1 -0
- package/dependencies/src/@taquito/utils-15.0.1/packages/taquito-utils/src/verify-signature.d.ts +24 -0
- package/dependencies/src/@taquito/utils-15.0.1/packages/taquito-utils/src/verify-signature.js +126 -0
- package/dependencies/src/@taquito/utils-15.0.1/packages/taquito-utils/src/verify-signature.js.map +1 -0
- package/dependencies/src/@taquito/utils-15.0.1/packages/taquito-utils/src/version.d.ts +4 -0
- package/dependencies/src/@taquito/utils-15.0.1/packages/taquito-utils/src/version.js +9 -0
- package/dependencies/src/@taquito/utils-15.0.1/packages/taquito-utils/src/version.js.map +1 -0
- package/dependencies/src/typedarray-to-buffer-4.0.0/index.js +17 -0
- package/package.json +2 -1
- package/dependencies/src/@taquito/local-forging-8.0.1-beta.1/packages/taquito/src/forger/interface.js.map +0 -1
- package/dependencies/src/@taquito/local-forging-8.0.1-beta.1/packages/taquito-local-forging/src/codec.js.map +0 -1
- package/dependencies/src/@taquito/local-forging-8.0.1-beta.1/packages/taquito-local-forging/src/constants.js.map +0 -1
- package/dependencies/src/@taquito/local-forging-8.0.1-beta.1/packages/taquito-local-forging/src/decoder.js.map +0 -1
- package/dependencies/src/@taquito/local-forging-8.0.1-beta.1/packages/taquito-local-forging/src/encoder.js.map +0 -1
- package/dependencies/src/@taquito/local-forging-8.0.1-beta.1/packages/taquito-local-forging/src/michelson/codec.js.map +0 -1
- package/dependencies/src/@taquito/local-forging-8.0.1-beta.1/packages/taquito-local-forging/src/schema/operation.d.ts +0 -86
- package/dependencies/src/@taquito/local-forging-8.0.1-beta.1/packages/taquito-local-forging/src/schema/operation.js +0 -149
- package/dependencies/src/@taquito/local-forging-8.0.1-beta.1/packages/taquito-local-forging/src/schema/operation.js.map +0 -1
- package/dependencies/src/@taquito/local-forging-8.0.1-beta.1/packages/taquito-local-forging/src/taquito-local-forging.d.ts +0 -16
- package/dependencies/src/@taquito/local-forging-8.0.1-beta.1/packages/taquito-local-forging/src/taquito-local-forging.js +0 -51
- package/dependencies/src/@taquito/local-forging-8.0.1-beta.1/packages/taquito-local-forging/src/taquito-local-forging.js.map +0 -1
- package/dependencies/src/@taquito/local-forging-8.0.1-beta.1/packages/taquito-local-forging/src/uint8array-consumer.js.map +0 -1
- package/dependencies/src/@taquito/local-forging-8.0.1-beta.1/packages/taquito-local-forging/src/utils.js.map +0 -1
- package/dependencies/src/@taquito/local-forging-8.0.1-beta.1/packages/taquito-rpc/src/opkind.d.ts +0 -13
- package/dependencies/src/@taquito/local-forging-8.0.1-beta.1/packages/taquito-rpc/src/opkind.js +0 -18
- package/dependencies/src/@taquito/local-forging-8.0.1-beta.1/packages/taquito-rpc/src/opkind.js.map +0 -1
- package/dependencies/src/@taquito/local-forging-8.0.1-beta.1/packages/taquito-rpc/src/types.d.ts +0 -598
- package/dependencies/src/@taquito/local-forging-8.0.1-beta.1/packages/taquito-rpc/src/types.js +0 -3
- package/dependencies/src/@taquito/local-forging-8.0.1-beta.1/packages/taquito-rpc/src/types.js.map +0 -1
- package/dependencies/src/@taquito/utils-8.0.1-beta.1/packages/taquito-utils/src/constants.js.map +0 -1
- package/dependencies/src/@taquito/utils-8.0.1-beta.1/packages/taquito-utils/src/taquito-utils.d.ts +0 -83
- package/dependencies/src/@taquito/utils-8.0.1-beta.1/packages/taquito-utils/src/taquito-utils.js +0 -245
- package/dependencies/src/@taquito/utils-8.0.1-beta.1/packages/taquito-utils/src/taquito-utils.js.map +0 -1
- package/dependencies/src/@taquito/utils-8.0.1-beta.1/packages/taquito-utils/src/validators.js.map +0 -1
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reads 2 bytes from array starting at offset as big-endian
|
|
3
|
+
* signed 16-bit integer and returns it.
|
|
4
|
+
*/
|
|
5
|
+
export declare function readInt16BE(array: Uint8Array, offset?: number): number;
|
|
6
|
+
/**
|
|
7
|
+
* Reads 2 bytes from array starting at offset as big-endian
|
|
8
|
+
* unsigned 16-bit integer and returns it.
|
|
9
|
+
*/
|
|
10
|
+
export declare function readUint16BE(array: Uint8Array, offset?: number): number;
|
|
11
|
+
/**
|
|
12
|
+
* Reads 2 bytes from array starting at offset as little-endian
|
|
13
|
+
* signed 16-bit integer and returns it.
|
|
14
|
+
*/
|
|
15
|
+
export declare function readInt16LE(array: Uint8Array, offset?: number): number;
|
|
16
|
+
/**
|
|
17
|
+
* Reads 2 bytes from array starting at offset as little-endian
|
|
18
|
+
* unsigned 16-bit integer and returns it.
|
|
19
|
+
*/
|
|
20
|
+
export declare function readUint16LE(array: Uint8Array, offset?: number): number;
|
|
21
|
+
/**
|
|
22
|
+
* Writes 2-byte big-endian representation of 16-bit unsigned
|
|
23
|
+
* value to byte array starting at offset.
|
|
24
|
+
*
|
|
25
|
+
* If byte array is not given, creates a new 2-byte one.
|
|
26
|
+
*
|
|
27
|
+
* Returns the output byte array.
|
|
28
|
+
*/
|
|
29
|
+
export declare function writeUint16BE(value: number, out?: Uint8Array, offset?: number): Uint8Array;
|
|
30
|
+
export declare const writeInt16BE: typeof writeUint16BE;
|
|
31
|
+
/**
|
|
32
|
+
* Writes 2-byte little-endian representation of 16-bit unsigned
|
|
33
|
+
* value to array starting at offset.
|
|
34
|
+
*
|
|
35
|
+
* If byte array is not given, creates a new 2-byte one.
|
|
36
|
+
*
|
|
37
|
+
* Returns the output byte array.
|
|
38
|
+
*/
|
|
39
|
+
export declare function writeUint16LE(value: number, out?: Uint8Array, offset?: number): Uint8Array;
|
|
40
|
+
export declare const writeInt16LE: typeof writeUint16LE;
|
|
41
|
+
/**
|
|
42
|
+
* Reads 4 bytes from array starting at offset as big-endian
|
|
43
|
+
* signed 32-bit integer and returns it.
|
|
44
|
+
*/
|
|
45
|
+
export declare function readInt32BE(array: Uint8Array, offset?: number): number;
|
|
46
|
+
/**
|
|
47
|
+
* Reads 4 bytes from array starting at offset as big-endian
|
|
48
|
+
* unsigned 32-bit integer and returns it.
|
|
49
|
+
*/
|
|
50
|
+
export declare function readUint32BE(array: Uint8Array, offset?: number): number;
|
|
51
|
+
/**
|
|
52
|
+
* Reads 4 bytes from array starting at offset as little-endian
|
|
53
|
+
* signed 32-bit integer and returns it.
|
|
54
|
+
*/
|
|
55
|
+
export declare function readInt32LE(array: Uint8Array, offset?: number): number;
|
|
56
|
+
/**
|
|
57
|
+
* Reads 4 bytes from array starting at offset as little-endian
|
|
58
|
+
* unsigned 32-bit integer and returns it.
|
|
59
|
+
*/
|
|
60
|
+
export declare function readUint32LE(array: Uint8Array, offset?: number): number;
|
|
61
|
+
/**
|
|
62
|
+
* Writes 4-byte big-endian representation of 32-bit unsigned
|
|
63
|
+
* value to byte array starting at offset.
|
|
64
|
+
*
|
|
65
|
+
* If byte array is not given, creates a new 4-byte one.
|
|
66
|
+
*
|
|
67
|
+
* Returns the output byte array.
|
|
68
|
+
*/
|
|
69
|
+
export declare function writeUint32BE(value: number, out?: Uint8Array, offset?: number): Uint8Array;
|
|
70
|
+
export declare const writeInt32BE: typeof writeUint32BE;
|
|
71
|
+
/**
|
|
72
|
+
* Writes 4-byte little-endian representation of 32-bit unsigned
|
|
73
|
+
* value to array starting at offset.
|
|
74
|
+
*
|
|
75
|
+
* If byte array is not given, creates a new 4-byte one.
|
|
76
|
+
*
|
|
77
|
+
* Returns the output byte array.
|
|
78
|
+
*/
|
|
79
|
+
export declare function writeUint32LE(value: number, out?: Uint8Array, offset?: number): Uint8Array;
|
|
80
|
+
export declare const writeInt32LE: typeof writeUint32LE;
|
|
81
|
+
/**
|
|
82
|
+
* Reads 8 bytes from array starting at offset as big-endian
|
|
83
|
+
* signed 64-bit integer and returns it.
|
|
84
|
+
*
|
|
85
|
+
* IMPORTANT: due to JavaScript limitation, supports exact
|
|
86
|
+
* numbers in range -9007199254740991 to 9007199254740991.
|
|
87
|
+
* If the number stored in the byte array is outside this range,
|
|
88
|
+
* the result is not exact.
|
|
89
|
+
*/
|
|
90
|
+
export declare function readInt64BE(array: Uint8Array, offset?: number): number;
|
|
91
|
+
/**
|
|
92
|
+
* Reads 8 bytes from array starting at offset as big-endian
|
|
93
|
+
* unsigned 64-bit integer and returns it.
|
|
94
|
+
*
|
|
95
|
+
* IMPORTANT: due to JavaScript limitation, supports values up to 2^53-1.
|
|
96
|
+
*/
|
|
97
|
+
export declare function readUint64BE(array: Uint8Array, offset?: number): number;
|
|
98
|
+
/**
|
|
99
|
+
* Reads 8 bytes from array starting at offset as little-endian
|
|
100
|
+
* signed 64-bit integer and returns it.
|
|
101
|
+
*
|
|
102
|
+
* IMPORTANT: due to JavaScript limitation, supports exact
|
|
103
|
+
* numbers in range -9007199254740991 to 9007199254740991.
|
|
104
|
+
* If the number stored in the byte array is outside this range,
|
|
105
|
+
* the result is not exact.
|
|
106
|
+
*/
|
|
107
|
+
export declare function readInt64LE(array: Uint8Array, offset?: number): number;
|
|
108
|
+
/**
|
|
109
|
+
* Reads 8 bytes from array starting at offset as little-endian
|
|
110
|
+
* unsigned 64-bit integer and returns it.
|
|
111
|
+
*
|
|
112
|
+
* IMPORTANT: due to JavaScript limitation, supports values up to 2^53-1.
|
|
113
|
+
*/
|
|
114
|
+
export declare function readUint64LE(array: Uint8Array, offset?: number): number;
|
|
115
|
+
/**
|
|
116
|
+
* Writes 8-byte big-endian representation of 64-bit unsigned
|
|
117
|
+
* value to byte array starting at offset.
|
|
118
|
+
*
|
|
119
|
+
* Due to JavaScript limitation, supports values up to 2^53-1.
|
|
120
|
+
*
|
|
121
|
+
* If byte array is not given, creates a new 8-byte one.
|
|
122
|
+
*
|
|
123
|
+
* Returns the output byte array.
|
|
124
|
+
*/
|
|
125
|
+
export declare function writeUint64BE(value: number, out?: Uint8Array, offset?: number): Uint8Array;
|
|
126
|
+
export declare const writeInt64BE: typeof writeUint64BE;
|
|
127
|
+
/**
|
|
128
|
+
* Writes 8-byte little-endian representation of 64-bit unsigned
|
|
129
|
+
* value to byte array starting at offset.
|
|
130
|
+
*
|
|
131
|
+
* Due to JavaScript limitation, supports values up to 2^53-1.
|
|
132
|
+
*
|
|
133
|
+
* If byte array is not given, creates a new 8-byte one.
|
|
134
|
+
*
|
|
135
|
+
* Returns the output byte array.
|
|
136
|
+
*/
|
|
137
|
+
export declare function writeUint64LE(value: number, out?: Uint8Array, offset?: number): Uint8Array;
|
|
138
|
+
export declare const writeInt64LE: typeof writeUint64LE;
|
|
139
|
+
/**
|
|
140
|
+
* Reads bytes from array starting at offset as big-endian
|
|
141
|
+
* unsigned bitLen-bit integer and returns it.
|
|
142
|
+
*
|
|
143
|
+
* Supports bit lengths divisible by 8, up to 48.
|
|
144
|
+
*/
|
|
145
|
+
export declare function readUintBE(bitLength: number, array: Uint8Array, offset?: number): number;
|
|
146
|
+
/**
|
|
147
|
+
* Reads bytes from array starting at offset as little-endian
|
|
148
|
+
* unsigned bitLen-bit integer and returns it.
|
|
149
|
+
*
|
|
150
|
+
* Supports bit lengths divisible by 8, up to 48.
|
|
151
|
+
*/
|
|
152
|
+
export declare function readUintLE(bitLength: number, array: Uint8Array, offset?: number): number;
|
|
153
|
+
/**
|
|
154
|
+
* Writes a big-endian representation of bitLen-bit unsigned
|
|
155
|
+
* value to array starting at offset.
|
|
156
|
+
*
|
|
157
|
+
* Supports bit lengths divisible by 8, up to 48.
|
|
158
|
+
*
|
|
159
|
+
* If byte array is not given, creates a new one.
|
|
160
|
+
*
|
|
161
|
+
* Returns the output byte array.
|
|
162
|
+
*/
|
|
163
|
+
export declare function writeUintBE(bitLength: number, value: number, out?: Uint8Array, offset?: number): Uint8Array;
|
|
164
|
+
/**
|
|
165
|
+
* Writes a little-endian representation of bitLen-bit unsigned
|
|
166
|
+
* value to array starting at offset.
|
|
167
|
+
*
|
|
168
|
+
* Supports bit lengths divisible by 8, up to 48.
|
|
169
|
+
*
|
|
170
|
+
* If byte array is not given, creates a new one.
|
|
171
|
+
*
|
|
172
|
+
* Returns the output byte array.
|
|
173
|
+
*/
|
|
174
|
+
export declare function writeUintLE(bitLength: number, value: number, out?: Uint8Array, offset?: number): Uint8Array;
|
|
175
|
+
/**
|
|
176
|
+
* Reads 4 bytes from array starting at offset as big-endian
|
|
177
|
+
* 32-bit floating-point number and returns it.
|
|
178
|
+
*/
|
|
179
|
+
export declare function readFloat32BE(array: Uint8Array, offset?: number): number;
|
|
180
|
+
/**
|
|
181
|
+
* Reads 4 bytes from array starting at offset as little-endian
|
|
182
|
+
* 32-bit floating-point number and returns it.
|
|
183
|
+
*/
|
|
184
|
+
export declare function readFloat32LE(array: Uint8Array, offset?: number): number;
|
|
185
|
+
/**
|
|
186
|
+
* Reads 8 bytes from array starting at offset as big-endian
|
|
187
|
+
* 64-bit floating-point number ("double") and returns it.
|
|
188
|
+
*/
|
|
189
|
+
export declare function readFloat64BE(array: Uint8Array, offset?: number): number;
|
|
190
|
+
/**
|
|
191
|
+
* Reads 8 bytes from array starting at offset as little-endian
|
|
192
|
+
* 64-bit floating-point number ("double") and returns it.
|
|
193
|
+
*/
|
|
194
|
+
export declare function readFloat64LE(array: Uint8Array, offset?: number): number;
|
|
195
|
+
/**
|
|
196
|
+
* Writes 4-byte big-endian floating-point representation of value
|
|
197
|
+
* to byte array starting at offset.
|
|
198
|
+
*
|
|
199
|
+
* If byte array is not given, creates a new 4-byte one.
|
|
200
|
+
*
|
|
201
|
+
* Returns the output byte array.
|
|
202
|
+
*/
|
|
203
|
+
export declare function writeFloat32BE(value: number, out?: Uint8Array, offset?: number): Uint8Array;
|
|
204
|
+
/**
|
|
205
|
+
* Writes 4-byte little-endian floating-point representation of value
|
|
206
|
+
* to byte array starting at offset.
|
|
207
|
+
*
|
|
208
|
+
* If byte array is not given, creates a new 4-byte one.
|
|
209
|
+
*
|
|
210
|
+
* Returns the output byte array.
|
|
211
|
+
*/
|
|
212
|
+
export declare function writeFloat32LE(value: number, out?: Uint8Array, offset?: number): Uint8Array;
|
|
213
|
+
/**
|
|
214
|
+
* Writes 8-byte big-endian floating-point representation of value
|
|
215
|
+
* to byte array starting at offset.
|
|
216
|
+
*
|
|
217
|
+
* If byte array is not given, creates a new 8-byte one.
|
|
218
|
+
*
|
|
219
|
+
* Returns the output byte array.
|
|
220
|
+
*/
|
|
221
|
+
export declare function writeFloat64BE(value: number, out?: Uint8Array, offset?: number): Uint8Array;
|
|
222
|
+
/**
|
|
223
|
+
* Writes 8-byte little-endian floating-point representation of value
|
|
224
|
+
* to byte array starting at offset.
|
|
225
|
+
*
|
|
226
|
+
* If byte array is not given, creates a new 8-byte one.
|
|
227
|
+
*
|
|
228
|
+
* Returns the output byte array.
|
|
229
|
+
*/
|
|
230
|
+
export declare function writeFloat64LE(value: number, out?: Uint8Array, offset?: number): Uint8Array;
|
|
@@ -0,0 +1,471 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (C) 2016 Dmitry Chestnykh
|
|
3
|
+
// MIT License. See LICENSE file for details.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.writeFloat64LE = exports.writeFloat64BE = exports.writeFloat32LE = exports.writeFloat32BE = exports.readFloat64LE = exports.readFloat64BE = exports.readFloat32LE = exports.readFloat32BE = exports.writeUintLE = exports.writeUintBE = exports.readUintLE = exports.readUintBE = exports.writeInt64LE = exports.writeUint64LE = exports.writeInt64BE = exports.writeUint64BE = exports.readUint64LE = exports.readInt64LE = exports.readUint64BE = exports.readInt64BE = exports.writeInt32LE = exports.writeUint32LE = exports.writeInt32BE = exports.writeUint32BE = exports.readUint32LE = exports.readInt32LE = exports.readUint32BE = exports.readInt32BE = exports.writeInt16LE = exports.writeUint16LE = exports.writeInt16BE = exports.writeUint16BE = exports.readUint16LE = exports.readInt16LE = exports.readUint16BE = exports.readInt16BE = void 0;
|
|
6
|
+
/**
|
|
7
|
+
* Package binary provides functions for encoding and decoding numbers in byte arrays.
|
|
8
|
+
*/
|
|
9
|
+
var int_1 = require("../../../../@stablelib/int-1.0.1/packages/int/int");
|
|
10
|
+
// TODO(dchest): add asserts for correct value ranges and array offsets.
|
|
11
|
+
/**
|
|
12
|
+
* Reads 2 bytes from array starting at offset as big-endian
|
|
13
|
+
* signed 16-bit integer and returns it.
|
|
14
|
+
*/
|
|
15
|
+
function readInt16BE(array, offset) {
|
|
16
|
+
if (offset === void 0) { offset = 0; }
|
|
17
|
+
return (((array[offset + 0] << 8) | array[offset + 1]) << 16) >> 16;
|
|
18
|
+
}
|
|
19
|
+
exports.readInt16BE = readInt16BE;
|
|
20
|
+
/**
|
|
21
|
+
* Reads 2 bytes from array starting at offset as big-endian
|
|
22
|
+
* unsigned 16-bit integer and returns it.
|
|
23
|
+
*/
|
|
24
|
+
function readUint16BE(array, offset) {
|
|
25
|
+
if (offset === void 0) { offset = 0; }
|
|
26
|
+
return ((array[offset + 0] << 8) | array[offset + 1]) >>> 0;
|
|
27
|
+
}
|
|
28
|
+
exports.readUint16BE = readUint16BE;
|
|
29
|
+
/**
|
|
30
|
+
* Reads 2 bytes from array starting at offset as little-endian
|
|
31
|
+
* signed 16-bit integer and returns it.
|
|
32
|
+
*/
|
|
33
|
+
function readInt16LE(array, offset) {
|
|
34
|
+
if (offset === void 0) { offset = 0; }
|
|
35
|
+
return (((array[offset + 1] << 8) | array[offset]) << 16) >> 16;
|
|
36
|
+
}
|
|
37
|
+
exports.readInt16LE = readInt16LE;
|
|
38
|
+
/**
|
|
39
|
+
* Reads 2 bytes from array starting at offset as little-endian
|
|
40
|
+
* unsigned 16-bit integer and returns it.
|
|
41
|
+
*/
|
|
42
|
+
function readUint16LE(array, offset) {
|
|
43
|
+
if (offset === void 0) { offset = 0; }
|
|
44
|
+
return ((array[offset + 1] << 8) | array[offset]) >>> 0;
|
|
45
|
+
}
|
|
46
|
+
exports.readUint16LE = readUint16LE;
|
|
47
|
+
/**
|
|
48
|
+
* Writes 2-byte big-endian representation of 16-bit unsigned
|
|
49
|
+
* value to byte array starting at offset.
|
|
50
|
+
*
|
|
51
|
+
* If byte array is not given, creates a new 2-byte one.
|
|
52
|
+
*
|
|
53
|
+
* Returns the output byte array.
|
|
54
|
+
*/
|
|
55
|
+
function writeUint16BE(value, out, offset) {
|
|
56
|
+
if (out === void 0) { out = new Uint8Array(2); }
|
|
57
|
+
if (offset === void 0) { offset = 0; }
|
|
58
|
+
out[offset + 0] = value >>> 8;
|
|
59
|
+
out[offset + 1] = value >>> 0;
|
|
60
|
+
return out;
|
|
61
|
+
}
|
|
62
|
+
exports.writeUint16BE = writeUint16BE;
|
|
63
|
+
exports.writeInt16BE = writeUint16BE;
|
|
64
|
+
/**
|
|
65
|
+
* Writes 2-byte little-endian representation of 16-bit unsigned
|
|
66
|
+
* value to array starting at offset.
|
|
67
|
+
*
|
|
68
|
+
* If byte array is not given, creates a new 2-byte one.
|
|
69
|
+
*
|
|
70
|
+
* Returns the output byte array.
|
|
71
|
+
*/
|
|
72
|
+
function writeUint16LE(value, out, offset) {
|
|
73
|
+
if (out === void 0) { out = new Uint8Array(2); }
|
|
74
|
+
if (offset === void 0) { offset = 0; }
|
|
75
|
+
out[offset + 0] = value >>> 0;
|
|
76
|
+
out[offset + 1] = value >>> 8;
|
|
77
|
+
return out;
|
|
78
|
+
}
|
|
79
|
+
exports.writeUint16LE = writeUint16LE;
|
|
80
|
+
exports.writeInt16LE = writeUint16LE;
|
|
81
|
+
/**
|
|
82
|
+
* Reads 4 bytes from array starting at offset as big-endian
|
|
83
|
+
* signed 32-bit integer and returns it.
|
|
84
|
+
*/
|
|
85
|
+
function readInt32BE(array, offset) {
|
|
86
|
+
if (offset === void 0) { offset = 0; }
|
|
87
|
+
return (array[offset] << 24) |
|
|
88
|
+
(array[offset + 1] << 16) |
|
|
89
|
+
(array[offset + 2] << 8) |
|
|
90
|
+
array[offset + 3];
|
|
91
|
+
}
|
|
92
|
+
exports.readInt32BE = readInt32BE;
|
|
93
|
+
/**
|
|
94
|
+
* Reads 4 bytes from array starting at offset as big-endian
|
|
95
|
+
* unsigned 32-bit integer and returns it.
|
|
96
|
+
*/
|
|
97
|
+
function readUint32BE(array, offset) {
|
|
98
|
+
if (offset === void 0) { offset = 0; }
|
|
99
|
+
return ((array[offset] << 24) |
|
|
100
|
+
(array[offset + 1] << 16) |
|
|
101
|
+
(array[offset + 2] << 8) |
|
|
102
|
+
array[offset + 3]) >>> 0;
|
|
103
|
+
}
|
|
104
|
+
exports.readUint32BE = readUint32BE;
|
|
105
|
+
/**
|
|
106
|
+
* Reads 4 bytes from array starting at offset as little-endian
|
|
107
|
+
* signed 32-bit integer and returns it.
|
|
108
|
+
*/
|
|
109
|
+
function readInt32LE(array, offset) {
|
|
110
|
+
if (offset === void 0) { offset = 0; }
|
|
111
|
+
return (array[offset + 3] << 24) |
|
|
112
|
+
(array[offset + 2] << 16) |
|
|
113
|
+
(array[offset + 1] << 8) |
|
|
114
|
+
array[offset];
|
|
115
|
+
}
|
|
116
|
+
exports.readInt32LE = readInt32LE;
|
|
117
|
+
/**
|
|
118
|
+
* Reads 4 bytes from array starting at offset as little-endian
|
|
119
|
+
* unsigned 32-bit integer and returns it.
|
|
120
|
+
*/
|
|
121
|
+
function readUint32LE(array, offset) {
|
|
122
|
+
if (offset === void 0) { offset = 0; }
|
|
123
|
+
return ((array[offset + 3] << 24) |
|
|
124
|
+
(array[offset + 2] << 16) |
|
|
125
|
+
(array[offset + 1] << 8) |
|
|
126
|
+
array[offset]) >>> 0;
|
|
127
|
+
}
|
|
128
|
+
exports.readUint32LE = readUint32LE;
|
|
129
|
+
/**
|
|
130
|
+
* Writes 4-byte big-endian representation of 32-bit unsigned
|
|
131
|
+
* value to byte array starting at offset.
|
|
132
|
+
*
|
|
133
|
+
* If byte array is not given, creates a new 4-byte one.
|
|
134
|
+
*
|
|
135
|
+
* Returns the output byte array.
|
|
136
|
+
*/
|
|
137
|
+
function writeUint32BE(value, out, offset) {
|
|
138
|
+
if (out === void 0) { out = new Uint8Array(4); }
|
|
139
|
+
if (offset === void 0) { offset = 0; }
|
|
140
|
+
out[offset + 0] = value >>> 24;
|
|
141
|
+
out[offset + 1] = value >>> 16;
|
|
142
|
+
out[offset + 2] = value >>> 8;
|
|
143
|
+
out[offset + 3] = value >>> 0;
|
|
144
|
+
return out;
|
|
145
|
+
}
|
|
146
|
+
exports.writeUint32BE = writeUint32BE;
|
|
147
|
+
exports.writeInt32BE = writeUint32BE;
|
|
148
|
+
/**
|
|
149
|
+
* Writes 4-byte little-endian representation of 32-bit unsigned
|
|
150
|
+
* value to array starting at offset.
|
|
151
|
+
*
|
|
152
|
+
* If byte array is not given, creates a new 4-byte one.
|
|
153
|
+
*
|
|
154
|
+
* Returns the output byte array.
|
|
155
|
+
*/
|
|
156
|
+
function writeUint32LE(value, out, offset) {
|
|
157
|
+
if (out === void 0) { out = new Uint8Array(4); }
|
|
158
|
+
if (offset === void 0) { offset = 0; }
|
|
159
|
+
out[offset + 0] = value >>> 0;
|
|
160
|
+
out[offset + 1] = value >>> 8;
|
|
161
|
+
out[offset + 2] = value >>> 16;
|
|
162
|
+
out[offset + 3] = value >>> 24;
|
|
163
|
+
return out;
|
|
164
|
+
}
|
|
165
|
+
exports.writeUint32LE = writeUint32LE;
|
|
166
|
+
exports.writeInt32LE = writeUint32LE;
|
|
167
|
+
/**
|
|
168
|
+
* Reads 8 bytes from array starting at offset as big-endian
|
|
169
|
+
* signed 64-bit integer and returns it.
|
|
170
|
+
*
|
|
171
|
+
* IMPORTANT: due to JavaScript limitation, supports exact
|
|
172
|
+
* numbers in range -9007199254740991 to 9007199254740991.
|
|
173
|
+
* If the number stored in the byte array is outside this range,
|
|
174
|
+
* the result is not exact.
|
|
175
|
+
*/
|
|
176
|
+
function readInt64BE(array, offset) {
|
|
177
|
+
if (offset === void 0) { offset = 0; }
|
|
178
|
+
var hi = readInt32BE(array, offset);
|
|
179
|
+
var lo = readInt32BE(array, offset + 4);
|
|
180
|
+
return hi * 0x100000000 + lo - ((lo >> 31) * 0x100000000);
|
|
181
|
+
}
|
|
182
|
+
exports.readInt64BE = readInt64BE;
|
|
183
|
+
/**
|
|
184
|
+
* Reads 8 bytes from array starting at offset as big-endian
|
|
185
|
+
* unsigned 64-bit integer and returns it.
|
|
186
|
+
*
|
|
187
|
+
* IMPORTANT: due to JavaScript limitation, supports values up to 2^53-1.
|
|
188
|
+
*/
|
|
189
|
+
function readUint64BE(array, offset) {
|
|
190
|
+
if (offset === void 0) { offset = 0; }
|
|
191
|
+
var hi = readUint32BE(array, offset);
|
|
192
|
+
var lo = readUint32BE(array, offset + 4);
|
|
193
|
+
return hi * 0x100000000 + lo;
|
|
194
|
+
}
|
|
195
|
+
exports.readUint64BE = readUint64BE;
|
|
196
|
+
/**
|
|
197
|
+
* Reads 8 bytes from array starting at offset as little-endian
|
|
198
|
+
* signed 64-bit integer and returns it.
|
|
199
|
+
*
|
|
200
|
+
* IMPORTANT: due to JavaScript limitation, supports exact
|
|
201
|
+
* numbers in range -9007199254740991 to 9007199254740991.
|
|
202
|
+
* If the number stored in the byte array is outside this range,
|
|
203
|
+
* the result is not exact.
|
|
204
|
+
*/
|
|
205
|
+
function readInt64LE(array, offset) {
|
|
206
|
+
if (offset === void 0) { offset = 0; }
|
|
207
|
+
var lo = readInt32LE(array, offset);
|
|
208
|
+
var hi = readInt32LE(array, offset + 4);
|
|
209
|
+
return hi * 0x100000000 + lo - ((lo >> 31) * 0x100000000);
|
|
210
|
+
}
|
|
211
|
+
exports.readInt64LE = readInt64LE;
|
|
212
|
+
/**
|
|
213
|
+
* Reads 8 bytes from array starting at offset as little-endian
|
|
214
|
+
* unsigned 64-bit integer and returns it.
|
|
215
|
+
*
|
|
216
|
+
* IMPORTANT: due to JavaScript limitation, supports values up to 2^53-1.
|
|
217
|
+
*/
|
|
218
|
+
function readUint64LE(array, offset) {
|
|
219
|
+
if (offset === void 0) { offset = 0; }
|
|
220
|
+
var lo = readUint32LE(array, offset);
|
|
221
|
+
var hi = readUint32LE(array, offset + 4);
|
|
222
|
+
return hi * 0x100000000 + lo;
|
|
223
|
+
}
|
|
224
|
+
exports.readUint64LE = readUint64LE;
|
|
225
|
+
/**
|
|
226
|
+
* Writes 8-byte big-endian representation of 64-bit unsigned
|
|
227
|
+
* value to byte array starting at offset.
|
|
228
|
+
*
|
|
229
|
+
* Due to JavaScript limitation, supports values up to 2^53-1.
|
|
230
|
+
*
|
|
231
|
+
* If byte array is not given, creates a new 8-byte one.
|
|
232
|
+
*
|
|
233
|
+
* Returns the output byte array.
|
|
234
|
+
*/
|
|
235
|
+
function writeUint64BE(value, out, offset) {
|
|
236
|
+
if (out === void 0) { out = new Uint8Array(8); }
|
|
237
|
+
if (offset === void 0) { offset = 0; }
|
|
238
|
+
writeUint32BE(value / 0x100000000 >>> 0, out, offset);
|
|
239
|
+
writeUint32BE(value >>> 0, out, offset + 4);
|
|
240
|
+
return out;
|
|
241
|
+
}
|
|
242
|
+
exports.writeUint64BE = writeUint64BE;
|
|
243
|
+
exports.writeInt64BE = writeUint64BE;
|
|
244
|
+
/**
|
|
245
|
+
* Writes 8-byte little-endian representation of 64-bit unsigned
|
|
246
|
+
* value to byte array starting at offset.
|
|
247
|
+
*
|
|
248
|
+
* Due to JavaScript limitation, supports values up to 2^53-1.
|
|
249
|
+
*
|
|
250
|
+
* If byte array is not given, creates a new 8-byte one.
|
|
251
|
+
*
|
|
252
|
+
* Returns the output byte array.
|
|
253
|
+
*/
|
|
254
|
+
function writeUint64LE(value, out, offset) {
|
|
255
|
+
if (out === void 0) { out = new Uint8Array(8); }
|
|
256
|
+
if (offset === void 0) { offset = 0; }
|
|
257
|
+
writeUint32LE(value >>> 0, out, offset);
|
|
258
|
+
writeUint32LE(value / 0x100000000 >>> 0, out, offset + 4);
|
|
259
|
+
return out;
|
|
260
|
+
}
|
|
261
|
+
exports.writeUint64LE = writeUint64LE;
|
|
262
|
+
exports.writeInt64LE = writeUint64LE;
|
|
263
|
+
/**
|
|
264
|
+
* Reads bytes from array starting at offset as big-endian
|
|
265
|
+
* unsigned bitLen-bit integer and returns it.
|
|
266
|
+
*
|
|
267
|
+
* Supports bit lengths divisible by 8, up to 48.
|
|
268
|
+
*/
|
|
269
|
+
function readUintBE(bitLength, array, offset) {
|
|
270
|
+
if (offset === void 0) { offset = 0; }
|
|
271
|
+
// TODO(dchest): implement support for bitLengths non-divisible by 8
|
|
272
|
+
if (bitLength % 8 !== 0) {
|
|
273
|
+
throw new Error("readUintBE supports only bitLengths divisible by 8");
|
|
274
|
+
}
|
|
275
|
+
if (bitLength / 8 > array.length - offset) {
|
|
276
|
+
throw new Error("readUintBE: array is too short for the given bitLength");
|
|
277
|
+
}
|
|
278
|
+
var result = 0;
|
|
279
|
+
var mul = 1;
|
|
280
|
+
for (var i = bitLength / 8 + offset - 1; i >= offset; i--) {
|
|
281
|
+
result += array[i] * mul;
|
|
282
|
+
mul *= 256;
|
|
283
|
+
}
|
|
284
|
+
return result;
|
|
285
|
+
}
|
|
286
|
+
exports.readUintBE = readUintBE;
|
|
287
|
+
/**
|
|
288
|
+
* Reads bytes from array starting at offset as little-endian
|
|
289
|
+
* unsigned bitLen-bit integer and returns it.
|
|
290
|
+
*
|
|
291
|
+
* Supports bit lengths divisible by 8, up to 48.
|
|
292
|
+
*/
|
|
293
|
+
function readUintLE(bitLength, array, offset) {
|
|
294
|
+
if (offset === void 0) { offset = 0; }
|
|
295
|
+
// TODO(dchest): implement support for bitLengths non-divisible by 8
|
|
296
|
+
if (bitLength % 8 !== 0) {
|
|
297
|
+
throw new Error("readUintLE supports only bitLengths divisible by 8");
|
|
298
|
+
}
|
|
299
|
+
if (bitLength / 8 > array.length - offset) {
|
|
300
|
+
throw new Error("readUintLE: array is too short for the given bitLength");
|
|
301
|
+
}
|
|
302
|
+
var result = 0;
|
|
303
|
+
var mul = 1;
|
|
304
|
+
for (var i = offset; i < offset + bitLength / 8; i++) {
|
|
305
|
+
result += array[i] * mul;
|
|
306
|
+
mul *= 256;
|
|
307
|
+
}
|
|
308
|
+
return result;
|
|
309
|
+
}
|
|
310
|
+
exports.readUintLE = readUintLE;
|
|
311
|
+
/**
|
|
312
|
+
* Writes a big-endian representation of bitLen-bit unsigned
|
|
313
|
+
* value to array starting at offset.
|
|
314
|
+
*
|
|
315
|
+
* Supports bit lengths divisible by 8, up to 48.
|
|
316
|
+
*
|
|
317
|
+
* If byte array is not given, creates a new one.
|
|
318
|
+
*
|
|
319
|
+
* Returns the output byte array.
|
|
320
|
+
*/
|
|
321
|
+
function writeUintBE(bitLength, value, out, offset) {
|
|
322
|
+
if (out === void 0) { out = new Uint8Array(bitLength / 8); }
|
|
323
|
+
if (offset === void 0) { offset = 0; }
|
|
324
|
+
// TODO(dchest): implement support for bitLengths non-divisible by 8
|
|
325
|
+
if (bitLength % 8 !== 0) {
|
|
326
|
+
throw new Error("writeUintBE supports only bitLengths divisible by 8");
|
|
327
|
+
}
|
|
328
|
+
if (!(0, int_1.isSafeInteger)(value)) {
|
|
329
|
+
throw new Error("writeUintBE value must be an integer");
|
|
330
|
+
}
|
|
331
|
+
var div = 1;
|
|
332
|
+
for (var i = bitLength / 8 + offset - 1; i >= offset; i--) {
|
|
333
|
+
out[i] = (value / div) & 0xff;
|
|
334
|
+
div *= 256;
|
|
335
|
+
}
|
|
336
|
+
return out;
|
|
337
|
+
}
|
|
338
|
+
exports.writeUintBE = writeUintBE;
|
|
339
|
+
/**
|
|
340
|
+
* Writes a little-endian representation of bitLen-bit unsigned
|
|
341
|
+
* value to array starting at offset.
|
|
342
|
+
*
|
|
343
|
+
* Supports bit lengths divisible by 8, up to 48.
|
|
344
|
+
*
|
|
345
|
+
* If byte array is not given, creates a new one.
|
|
346
|
+
*
|
|
347
|
+
* Returns the output byte array.
|
|
348
|
+
*/
|
|
349
|
+
function writeUintLE(bitLength, value, out, offset) {
|
|
350
|
+
if (out === void 0) { out = new Uint8Array(bitLength / 8); }
|
|
351
|
+
if (offset === void 0) { offset = 0; }
|
|
352
|
+
// TODO(dchest): implement support for bitLengths non-divisible by 8
|
|
353
|
+
if (bitLength % 8 !== 0) {
|
|
354
|
+
throw new Error("writeUintLE supports only bitLengths divisible by 8");
|
|
355
|
+
}
|
|
356
|
+
if (!(0, int_1.isSafeInteger)(value)) {
|
|
357
|
+
throw new Error("writeUintLE value must be an integer");
|
|
358
|
+
}
|
|
359
|
+
var div = 1;
|
|
360
|
+
for (var i = offset; i < offset + bitLength / 8; i++) {
|
|
361
|
+
out[i] = (value / div) & 0xff;
|
|
362
|
+
div *= 256;
|
|
363
|
+
}
|
|
364
|
+
return out;
|
|
365
|
+
}
|
|
366
|
+
exports.writeUintLE = writeUintLE;
|
|
367
|
+
/**
|
|
368
|
+
* Reads 4 bytes from array starting at offset as big-endian
|
|
369
|
+
* 32-bit floating-point number and returns it.
|
|
370
|
+
*/
|
|
371
|
+
function readFloat32BE(array, offset) {
|
|
372
|
+
if (offset === void 0) { offset = 0; }
|
|
373
|
+
var view = new DataView(array.buffer, array.byteOffset, array.byteLength);
|
|
374
|
+
return view.getFloat32(offset);
|
|
375
|
+
}
|
|
376
|
+
exports.readFloat32BE = readFloat32BE;
|
|
377
|
+
/**
|
|
378
|
+
* Reads 4 bytes from array starting at offset as little-endian
|
|
379
|
+
* 32-bit floating-point number and returns it.
|
|
380
|
+
*/
|
|
381
|
+
function readFloat32LE(array, offset) {
|
|
382
|
+
if (offset === void 0) { offset = 0; }
|
|
383
|
+
var view = new DataView(array.buffer, array.byteOffset, array.byteLength);
|
|
384
|
+
return view.getFloat32(offset, true);
|
|
385
|
+
}
|
|
386
|
+
exports.readFloat32LE = readFloat32LE;
|
|
387
|
+
/**
|
|
388
|
+
* Reads 8 bytes from array starting at offset as big-endian
|
|
389
|
+
* 64-bit floating-point number ("double") and returns it.
|
|
390
|
+
*/
|
|
391
|
+
function readFloat64BE(array, offset) {
|
|
392
|
+
if (offset === void 0) { offset = 0; }
|
|
393
|
+
var view = new DataView(array.buffer, array.byteOffset, array.byteLength);
|
|
394
|
+
return view.getFloat64(offset);
|
|
395
|
+
}
|
|
396
|
+
exports.readFloat64BE = readFloat64BE;
|
|
397
|
+
/**
|
|
398
|
+
* Reads 8 bytes from array starting at offset as little-endian
|
|
399
|
+
* 64-bit floating-point number ("double") and returns it.
|
|
400
|
+
*/
|
|
401
|
+
function readFloat64LE(array, offset) {
|
|
402
|
+
if (offset === void 0) { offset = 0; }
|
|
403
|
+
var view = new DataView(array.buffer, array.byteOffset, array.byteLength);
|
|
404
|
+
return view.getFloat64(offset, true);
|
|
405
|
+
}
|
|
406
|
+
exports.readFloat64LE = readFloat64LE;
|
|
407
|
+
/**
|
|
408
|
+
* Writes 4-byte big-endian floating-point representation of value
|
|
409
|
+
* to byte array starting at offset.
|
|
410
|
+
*
|
|
411
|
+
* If byte array is not given, creates a new 4-byte one.
|
|
412
|
+
*
|
|
413
|
+
* Returns the output byte array.
|
|
414
|
+
*/
|
|
415
|
+
function writeFloat32BE(value, out, offset) {
|
|
416
|
+
if (out === void 0) { out = new Uint8Array(4); }
|
|
417
|
+
if (offset === void 0) { offset = 0; }
|
|
418
|
+
var view = new DataView(out.buffer, out.byteOffset, out.byteLength);
|
|
419
|
+
view.setFloat32(offset, value);
|
|
420
|
+
return out;
|
|
421
|
+
}
|
|
422
|
+
exports.writeFloat32BE = writeFloat32BE;
|
|
423
|
+
/**
|
|
424
|
+
* Writes 4-byte little-endian floating-point representation of value
|
|
425
|
+
* to byte array starting at offset.
|
|
426
|
+
*
|
|
427
|
+
* If byte array is not given, creates a new 4-byte one.
|
|
428
|
+
*
|
|
429
|
+
* Returns the output byte array.
|
|
430
|
+
*/
|
|
431
|
+
function writeFloat32LE(value, out, offset) {
|
|
432
|
+
if (out === void 0) { out = new Uint8Array(4); }
|
|
433
|
+
if (offset === void 0) { offset = 0; }
|
|
434
|
+
var view = new DataView(out.buffer, out.byteOffset, out.byteLength);
|
|
435
|
+
view.setFloat32(offset, value, true);
|
|
436
|
+
return out;
|
|
437
|
+
}
|
|
438
|
+
exports.writeFloat32LE = writeFloat32LE;
|
|
439
|
+
/**
|
|
440
|
+
* Writes 8-byte big-endian floating-point representation of value
|
|
441
|
+
* to byte array starting at offset.
|
|
442
|
+
*
|
|
443
|
+
* If byte array is not given, creates a new 8-byte one.
|
|
444
|
+
*
|
|
445
|
+
* Returns the output byte array.
|
|
446
|
+
*/
|
|
447
|
+
function writeFloat64BE(value, out, offset) {
|
|
448
|
+
if (out === void 0) { out = new Uint8Array(8); }
|
|
449
|
+
if (offset === void 0) { offset = 0; }
|
|
450
|
+
var view = new DataView(out.buffer, out.byteOffset, out.byteLength);
|
|
451
|
+
view.setFloat64(offset, value);
|
|
452
|
+
return out;
|
|
453
|
+
}
|
|
454
|
+
exports.writeFloat64BE = writeFloat64BE;
|
|
455
|
+
/**
|
|
456
|
+
* Writes 8-byte little-endian floating-point representation of value
|
|
457
|
+
* to byte array starting at offset.
|
|
458
|
+
*
|
|
459
|
+
* If byte array is not given, creates a new 8-byte one.
|
|
460
|
+
*
|
|
461
|
+
* Returns the output byte array.
|
|
462
|
+
*/
|
|
463
|
+
function writeFloat64LE(value, out, offset) {
|
|
464
|
+
if (out === void 0) { out = new Uint8Array(8); }
|
|
465
|
+
if (offset === void 0) { offset = 0; }
|
|
466
|
+
var view = new DataView(out.buffer, out.byteOffset, out.byteLength);
|
|
467
|
+
view.setFloat64(offset, value, true);
|
|
468
|
+
return out;
|
|
469
|
+
}
|
|
470
|
+
exports.writeFloat64LE = writeFloat64LE;
|
|
471
|
+
//# sourceMappingURL=binary.js.map
|