@bare-ts/lib 0.1.1 → 0.2.0
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/codec/data.d.ts +4 -4
- package/dist/codec/data.js +16 -16
- package/dist/codec/float-array.d.ts +12 -12
- package/dist/codec/float-array.js +46 -49
- package/dist/codec/i16-array.d.ts +6 -6
- package/dist/codec/i16-array.js +22 -29
- package/dist/codec/i32-array.d.ts +6 -6
- package/dist/codec/i32-array.js +22 -29
- package/dist/codec/i64-array.d.ts +6 -6
- package/dist/codec/i64-array.js +22 -29
- package/dist/codec/i8-array.d.ts +4 -4
- package/dist/codec/i8-array.js +16 -16
- package/dist/codec/primitive.d.ts +36 -36
- package/dist/codec/primitive.js +139 -132
- package/dist/codec/string.d.ts +4 -2
- package/dist/codec/string.js +81 -77
- package/dist/codec/u16-array.d.ts +6 -6
- package/dist/codec/u16-array.js +22 -29
- package/dist/codec/u32-array.d.ts +6 -6
- package/dist/codec/u32-array.js +22 -29
- package/dist/codec/u64-array.d.ts +6 -6
- package/dist/codec/u64-array.js +22 -29
- package/dist/codec/u8-array.d.ts +4 -4
- package/dist/codec/u8-array.js +18 -16
- package/dist/codec/u8-clamped-array.d.ts +4 -4
- package/dist/codec/u8-clamped-array.js +16 -16
- package/dist/core/byte-cursor.d.ts +26 -8
- package/dist/core/byte-cursor.js +18 -28
- package/dist/index.cjs +551 -571
- package/package.json +1 -1
- package/CHANGELOG.md +0 -37
package/dist/codec/data.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ByteCursor } from "../core/index.js";
|
|
2
|
-
export declare function
|
|
3
|
-
export declare function
|
|
4
|
-
export declare function
|
|
5
|
-
export declare function
|
|
2
|
+
export declare function readData(bc: ByteCursor): ArrayBuffer;
|
|
3
|
+
export declare function writeData(bc: ByteCursor, x: ArrayBuffer): void;
|
|
4
|
+
export declare function readFixedData(bc: ByteCursor, len: number): ArrayBuffer;
|
|
5
|
+
export declare function writeFixedData(bc: ByteCursor, x: ArrayBuffer): void;
|
package/dist/codec/data.js
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
// src/codec/data.ts
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
readU8Array,
|
|
4
|
+
readU8FixedArray,
|
|
5
|
+
writeU8Array,
|
|
6
|
+
writeU8FixedArray
|
|
7
7
|
} from "./u8-array.js";
|
|
8
|
-
function
|
|
9
|
-
return
|
|
8
|
+
function readData(bc) {
|
|
9
|
+
return readU8Array(bc).buffer;
|
|
10
10
|
}
|
|
11
|
-
function
|
|
12
|
-
|
|
11
|
+
function writeData(bc, x) {
|
|
12
|
+
writeU8Array(bc, new Uint8Array(x));
|
|
13
13
|
}
|
|
14
|
-
function
|
|
15
|
-
return
|
|
14
|
+
function readFixedData(bc, len) {
|
|
15
|
+
return readU8FixedArray(bc, len).buffer;
|
|
16
16
|
}
|
|
17
|
-
function
|
|
18
|
-
|
|
17
|
+
function writeFixedData(bc, x) {
|
|
18
|
+
writeU8FixedArray(bc, new Uint8Array(x));
|
|
19
19
|
}
|
|
20
20
|
export {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
readData,
|
|
22
|
+
readFixedData,
|
|
23
|
+
writeData,
|
|
24
|
+
writeFixedData
|
|
25
25
|
};
|
|
26
26
|
//# sourceMappingURL=data.js.map
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import type { ByteCursor } from "../core/index.js";
|
|
2
|
-
export declare const
|
|
3
|
-
declare function
|
|
4
|
-
export declare const
|
|
5
|
-
declare function
|
|
6
|
-
export declare function
|
|
7
|
-
export declare function
|
|
8
|
-
export declare const
|
|
9
|
-
declare function
|
|
10
|
-
export declare const
|
|
11
|
-
declare function
|
|
12
|
-
export declare function
|
|
13
|
-
export declare function
|
|
2
|
+
export declare const readF32FixedArray: typeof readF32FixedArrayLE;
|
|
3
|
+
declare function readF32FixedArrayLE(bc: ByteCursor, len: number): Float32Array;
|
|
4
|
+
export declare const writeF32FixedArray: typeof writeF32FixedArrayLE;
|
|
5
|
+
declare function writeF32FixedArrayLE(bc: ByteCursor, x: Float32Array): void;
|
|
6
|
+
export declare function readF32Array(bc: ByteCursor): Float32Array;
|
|
7
|
+
export declare function writeF32Array(bc: ByteCursor, x: Float32Array): void;
|
|
8
|
+
export declare const readF64FixedArray: typeof readF64FixedArrayLE;
|
|
9
|
+
declare function readF64FixedArrayLE(bc: ByteCursor, len: number): Float64Array;
|
|
10
|
+
export declare const writeF64FixedArray: typeof writeF64FixedArrayLE;
|
|
11
|
+
declare function writeF64FixedArrayLE(bc: ByteCursor, x: Float64Array): void;
|
|
12
|
+
export declare function readF64Array(bc: ByteCursor): Float64Array;
|
|
13
|
+
export declare function writeF64Array(bc: ByteCursor, x: Float64Array): void;
|
|
14
14
|
export {};
|
|
@@ -2,98 +2,95 @@
|
|
|
2
2
|
import { ok as assert } from "assert";
|
|
3
3
|
import { BareError } from "../core/index.js";
|
|
4
4
|
import { IS_LITTLE_ENDIAN_PLATFORM } from "../util/util.js";
|
|
5
|
-
import {
|
|
5
|
+
import { readFixedData } from "./data.js";
|
|
6
6
|
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
readF32,
|
|
8
|
+
readF64,
|
|
9
|
+
readUintSafe,
|
|
10
|
+
writeF32,
|
|
11
|
+
writeF64,
|
|
12
|
+
writeUintSafe
|
|
13
13
|
} from "./primitive.js";
|
|
14
|
+
import { writeU8FixedArray } from "./u8-array.js";
|
|
14
15
|
var NAN_NOT_ALLOWED = "NaN is not allowed";
|
|
15
|
-
var
|
|
16
|
-
function
|
|
16
|
+
var readF32FixedArray = IS_LITTLE_ENDIAN_PLATFORM ? readF32FixedArrayLE : readF32FixedArrayBE;
|
|
17
|
+
function readF32FixedArrayLE(bc, len) {
|
|
17
18
|
const byteLen = len * 4;
|
|
18
|
-
const result = new Float32Array(
|
|
19
|
+
const result = new Float32Array(readFixedData(bc, byteLen));
|
|
19
20
|
if (result.some(Number.isNaN)) {
|
|
20
21
|
throw new BareError(bc.offset, NAN_NOT_ALLOWED);
|
|
21
22
|
}
|
|
22
23
|
return result;
|
|
23
24
|
}
|
|
24
|
-
function
|
|
25
|
+
function readF32FixedArrayBE(bc, len) {
|
|
25
26
|
bc.check(len * 4);
|
|
26
27
|
const result = new Float32Array(len);
|
|
27
28
|
for (let i = 0; i < len; i++)
|
|
28
|
-
result[i] =
|
|
29
|
+
result[i] = readF32(bc);
|
|
29
30
|
return result;
|
|
30
31
|
}
|
|
31
|
-
var
|
|
32
|
-
function
|
|
33
|
-
assert(x.length === len);
|
|
32
|
+
var writeF32FixedArray = IS_LITTLE_ENDIAN_PLATFORM ? writeF32FixedArrayLE : writeF32FixedArrayBE;
|
|
33
|
+
function writeF32FixedArrayLE(bc, x) {
|
|
34
34
|
assert(!x.every(Number.isNaN), NAN_NOT_ALLOWED);
|
|
35
|
-
bc
|
|
35
|
+
writeU8FixedArray(bc, new Uint8Array(x.buffer, x.byteOffset, x.byteLength));
|
|
36
36
|
}
|
|
37
|
-
function
|
|
38
|
-
assert(val.length === len);
|
|
37
|
+
function writeF32FixedArrayBE(bc, val) {
|
|
39
38
|
bc.reserve(val.length * 4);
|
|
40
39
|
for (let i = 0; i < val.length; i++)
|
|
41
|
-
|
|
40
|
+
writeF32(bc, val[i]);
|
|
42
41
|
}
|
|
43
|
-
function
|
|
44
|
-
return
|
|
42
|
+
function readF32Array(bc) {
|
|
43
|
+
return readF32FixedArray(bc, readUintSafe(bc));
|
|
45
44
|
}
|
|
46
|
-
function
|
|
47
|
-
|
|
45
|
+
function writeF32Array(bc, x) {
|
|
46
|
+
writeUintSafe(bc, x.length);
|
|
48
47
|
if (x.length !== 0) {
|
|
49
|
-
|
|
48
|
+
writeF32FixedArray(bc, x);
|
|
50
49
|
}
|
|
51
50
|
}
|
|
52
|
-
var
|
|
53
|
-
function
|
|
51
|
+
var readF64FixedArray = IS_LITTLE_ENDIAN_PLATFORM ? readF64FixedArrayLE : readF64FixedArrayBE;
|
|
52
|
+
function readF64FixedArrayLE(bc, len) {
|
|
54
53
|
const byteLen = len * 8;
|
|
55
|
-
const result = new Float64Array(
|
|
54
|
+
const result = new Float64Array(readFixedData(bc, byteLen));
|
|
56
55
|
if (result.some(Number.isNaN)) {
|
|
57
56
|
throw new BareError(bc.offset, NAN_NOT_ALLOWED);
|
|
58
57
|
}
|
|
59
58
|
return result;
|
|
60
59
|
}
|
|
61
|
-
function
|
|
60
|
+
function readF64FixedArrayBE(bc, len) {
|
|
62
61
|
bc.check(len * 8);
|
|
63
62
|
const result = new Float64Array(len);
|
|
64
63
|
for (let i = 0; i < len; i++)
|
|
65
|
-
result[i] =
|
|
64
|
+
result[i] = readF64(bc);
|
|
66
65
|
return result;
|
|
67
66
|
}
|
|
68
|
-
var
|
|
69
|
-
function
|
|
70
|
-
assert(x.length === len);
|
|
67
|
+
var writeF64FixedArray = IS_LITTLE_ENDIAN_PLATFORM ? writeF64FixedArrayLE : writeF64FixedArrayBE;
|
|
68
|
+
function writeF64FixedArrayLE(bc, x) {
|
|
71
69
|
assert(!x.every(Number.isNaN), NAN_NOT_ALLOWED);
|
|
72
|
-
bc
|
|
70
|
+
writeU8FixedArray(bc, new Uint8Array(x.buffer, x.byteOffset, x.byteLength));
|
|
73
71
|
}
|
|
74
|
-
function
|
|
75
|
-
assert(x.length === len);
|
|
72
|
+
function writeF64FixedArrayBE(bc, x) {
|
|
76
73
|
bc.reserve(x.length * 8);
|
|
77
74
|
for (let i = 0; i < x.length; i++)
|
|
78
|
-
|
|
75
|
+
writeF64(bc, x[i]);
|
|
79
76
|
}
|
|
80
|
-
function
|
|
81
|
-
return
|
|
77
|
+
function readF64Array(bc) {
|
|
78
|
+
return readF64FixedArray(bc, readUintSafe(bc));
|
|
82
79
|
}
|
|
83
|
-
function
|
|
84
|
-
|
|
80
|
+
function writeF64Array(bc, x) {
|
|
81
|
+
writeUintSafe(bc, x.length);
|
|
85
82
|
if (x.length !== 0) {
|
|
86
|
-
|
|
83
|
+
writeF64FixedArray(bc, x);
|
|
87
84
|
}
|
|
88
85
|
}
|
|
89
86
|
export {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
87
|
+
readF32Array,
|
|
88
|
+
readF32FixedArray,
|
|
89
|
+
readF64Array,
|
|
90
|
+
readF64FixedArray,
|
|
91
|
+
writeF32Array,
|
|
92
|
+
writeF32FixedArray,
|
|
93
|
+
writeF64Array,
|
|
94
|
+
writeF64FixedArray
|
|
98
95
|
};
|
|
99
96
|
//# sourceMappingURL=float-array.js.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { ByteCursor } from "../core/index.js";
|
|
2
|
-
export declare const
|
|
3
|
-
export declare function
|
|
4
|
-
declare function
|
|
5
|
-
export declare const
|
|
6
|
-
export declare function
|
|
7
|
-
declare function
|
|
2
|
+
export declare const readI16FixedArray: typeof readI16FixedArrayLE;
|
|
3
|
+
export declare function readI16Array(bc: ByteCursor): Int16Array;
|
|
4
|
+
declare function readI16FixedArrayLE(bc: ByteCursor, len: number): Int16Array;
|
|
5
|
+
export declare const writeI16FixedArray: typeof writeI16FixedArrayLE;
|
|
6
|
+
export declare function writeI16Array(bc: ByteCursor, x: Int16Array): void;
|
|
7
|
+
declare function writeI16FixedArrayLE(bc: ByteCursor, x: Int16Array): void;
|
|
8
8
|
export {};
|
package/dist/codec/i16-array.js
CHANGED
|
@@ -1,50 +1,43 @@
|
|
|
1
1
|
// src/codec/i16-array.ts
|
|
2
|
-
import { ok as assert } from "assert";
|
|
3
2
|
import { IS_LITTLE_ENDIAN_PLATFORM } from "../util/util.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
decodeUintSafe,
|
|
8
|
-
encodeI16,
|
|
9
|
-
encodeUintSafe
|
|
10
|
-
} from "./primitive.js";
|
|
3
|
+
import { readFixedData } from "./data.js";
|
|
4
|
+
import { readI16, readUintSafe, writeI16, writeUintSafe } from "./primitive.js";
|
|
5
|
+
import { writeU8FixedArray } from "./u8-array.js";
|
|
11
6
|
var I16_BYTE_COUNT = 2;
|
|
12
|
-
var
|
|
13
|
-
function
|
|
14
|
-
return
|
|
7
|
+
var readI16FixedArray = IS_LITTLE_ENDIAN_PLATFORM ? readI16FixedArrayLE : readI16FixedArrayBE;
|
|
8
|
+
function readI16Array(bc) {
|
|
9
|
+
return readI16FixedArray(bc, readUintSafe(bc));
|
|
15
10
|
}
|
|
16
|
-
function
|
|
11
|
+
function readI16FixedArrayLE(bc, len) {
|
|
17
12
|
const byteCount = len * I16_BYTE_COUNT;
|
|
18
|
-
return new Int16Array(
|
|
13
|
+
return new Int16Array(readFixedData(bc, byteCount));
|
|
19
14
|
}
|
|
20
|
-
function
|
|
15
|
+
function readI16FixedArrayBE(bc, len) {
|
|
21
16
|
bc.check(len * I16_BYTE_COUNT);
|
|
22
17
|
const result = new Int16Array(len);
|
|
23
18
|
for (let i = 0; i < len; i++)
|
|
24
|
-
result[i] =
|
|
19
|
+
result[i] = readI16(bc);
|
|
25
20
|
return result;
|
|
26
21
|
}
|
|
27
|
-
var
|
|
28
|
-
function
|
|
29
|
-
|
|
22
|
+
var writeI16FixedArray = IS_LITTLE_ENDIAN_PLATFORM ? writeI16FixedArrayLE : writeI16FixedArrayBE;
|
|
23
|
+
function writeI16Array(bc, x) {
|
|
24
|
+
writeUintSafe(bc, x.length);
|
|
30
25
|
if (x.length !== 0) {
|
|
31
|
-
|
|
26
|
+
writeI16FixedArray(bc, x);
|
|
32
27
|
}
|
|
33
28
|
}
|
|
34
|
-
function
|
|
35
|
-
|
|
36
|
-
bc.write(new Uint8Array(x.buffer, x.byteOffset, x.byteLength));
|
|
29
|
+
function writeI16FixedArrayLE(bc, x) {
|
|
30
|
+
writeU8FixedArray(bc, new Uint8Array(x.buffer, x.byteOffset, x.byteLength));
|
|
37
31
|
}
|
|
38
|
-
function
|
|
39
|
-
assert(x.length === len);
|
|
32
|
+
function writeI16FixedArrayBE(bc, x) {
|
|
40
33
|
bc.reserve(x.length * I16_BYTE_COUNT);
|
|
41
34
|
for (let i = 0; i < x.length; i++)
|
|
42
|
-
|
|
35
|
+
writeI16(bc, x[i]);
|
|
43
36
|
}
|
|
44
37
|
export {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
38
|
+
readI16Array,
|
|
39
|
+
readI16FixedArray,
|
|
40
|
+
writeI16Array,
|
|
41
|
+
writeI16FixedArray
|
|
49
42
|
};
|
|
50
43
|
//# sourceMappingURL=i16-array.js.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { ByteCursor } from "../core/index.js";
|
|
2
|
-
export declare const
|
|
3
|
-
export declare function
|
|
4
|
-
declare function
|
|
5
|
-
export declare const
|
|
6
|
-
export declare function
|
|
7
|
-
declare function
|
|
2
|
+
export declare const readI32FixedArray: typeof readI32FixedArrayLE;
|
|
3
|
+
export declare function readI32Array(bc: ByteCursor): Int32Array;
|
|
4
|
+
declare function readI32FixedArrayLE(bc: ByteCursor, len: number): Int32Array;
|
|
5
|
+
export declare const writeI32FixedArray: typeof writeI32FixedArrayLE;
|
|
6
|
+
export declare function writeI32Array(bc: ByteCursor, x: Int32Array): void;
|
|
7
|
+
declare function writeI32FixedArrayLE(bc: ByteCursor, x: Int32Array): void;
|
|
8
8
|
export {};
|
package/dist/codec/i32-array.js
CHANGED
|
@@ -1,50 +1,43 @@
|
|
|
1
1
|
// src/codec/i32-array.ts
|
|
2
|
-
import { ok as assert } from "assert";
|
|
3
2
|
import { IS_LITTLE_ENDIAN_PLATFORM } from "../util/util.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
decodeUintSafe,
|
|
8
|
-
encodeI32,
|
|
9
|
-
encodeUintSafe
|
|
10
|
-
} from "./primitive.js";
|
|
3
|
+
import { readFixedData } from "./data.js";
|
|
4
|
+
import { readI32, readUintSafe, writeI32, writeUintSafe } from "./primitive.js";
|
|
5
|
+
import { writeU8FixedArray } from "./u8-array.js";
|
|
11
6
|
var I32_BYTE_COUNT = 4;
|
|
12
|
-
var
|
|
13
|
-
function
|
|
14
|
-
return
|
|
7
|
+
var readI32FixedArray = IS_LITTLE_ENDIAN_PLATFORM ? readI32FixedArrayLE : readI32FixedArrayBE;
|
|
8
|
+
function readI32Array(bc) {
|
|
9
|
+
return readI32FixedArray(bc, readUintSafe(bc));
|
|
15
10
|
}
|
|
16
|
-
function
|
|
11
|
+
function readI32FixedArrayLE(bc, len) {
|
|
17
12
|
const byteCount = len * I32_BYTE_COUNT;
|
|
18
|
-
return new Int32Array(
|
|
13
|
+
return new Int32Array(readFixedData(bc, byteCount));
|
|
19
14
|
}
|
|
20
|
-
function
|
|
15
|
+
function readI32FixedArrayBE(bc, len) {
|
|
21
16
|
bc.check(len * I32_BYTE_COUNT);
|
|
22
17
|
const result = new Int32Array(len);
|
|
23
18
|
for (let i = 0; i < len; i++)
|
|
24
|
-
result[i] =
|
|
19
|
+
result[i] = readI32(bc);
|
|
25
20
|
return result;
|
|
26
21
|
}
|
|
27
|
-
var
|
|
28
|
-
function
|
|
29
|
-
|
|
22
|
+
var writeI32FixedArray = IS_LITTLE_ENDIAN_PLATFORM ? writeI32FixedArrayLE : writeI32FixedArrayBE;
|
|
23
|
+
function writeI32Array(bc, x) {
|
|
24
|
+
writeUintSafe(bc, x.length);
|
|
30
25
|
if (x.length !== 0) {
|
|
31
|
-
|
|
26
|
+
writeI32FixedArray(bc, x);
|
|
32
27
|
}
|
|
33
28
|
}
|
|
34
|
-
function
|
|
35
|
-
|
|
36
|
-
bc.write(new Uint8Array(x.buffer, x.byteOffset, x.byteLength));
|
|
29
|
+
function writeI32FixedArrayLE(bc, x) {
|
|
30
|
+
writeU8FixedArray(bc, new Uint8Array(x.buffer, x.byteOffset, x.byteLength));
|
|
37
31
|
}
|
|
38
|
-
function
|
|
39
|
-
assert(x.length === len);
|
|
32
|
+
function writeI32FixedArrayBE(bc, x) {
|
|
40
33
|
bc.reserve(x.length * I32_BYTE_COUNT);
|
|
41
34
|
for (let i = 0; i < x.length; i++)
|
|
42
|
-
|
|
35
|
+
writeI32(bc, x[i]);
|
|
43
36
|
}
|
|
44
37
|
export {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
38
|
+
readI32Array,
|
|
39
|
+
readI32FixedArray,
|
|
40
|
+
writeI32Array,
|
|
41
|
+
writeI32FixedArray
|
|
49
42
|
};
|
|
50
43
|
//# sourceMappingURL=i32-array.js.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { ByteCursor } from "../core/index.js";
|
|
2
|
-
export declare const
|
|
3
|
-
export declare function
|
|
4
|
-
declare function
|
|
5
|
-
export declare const
|
|
6
|
-
export declare function
|
|
7
|
-
declare function
|
|
2
|
+
export declare const readI64FixedArray: typeof readI64FixedArrayLE;
|
|
3
|
+
export declare function readI64Array(bc: ByteCursor): BigInt64Array;
|
|
4
|
+
declare function readI64FixedArrayLE(bc: ByteCursor, len: number): BigInt64Array;
|
|
5
|
+
export declare const writeI64FixedArray: typeof writeI64FixedArrayLE;
|
|
6
|
+
export declare function writeI64Array(bc: ByteCursor, x: BigInt64Array): void;
|
|
7
|
+
declare function writeI64FixedArrayLE(bc: ByteCursor, x: BigInt64Array): void;
|
|
8
8
|
export {};
|
package/dist/codec/i64-array.js
CHANGED
|
@@ -1,50 +1,43 @@
|
|
|
1
1
|
// src/codec/i64-array.ts
|
|
2
|
-
import { ok as assert } from "assert";
|
|
3
2
|
import { IS_LITTLE_ENDIAN_PLATFORM } from "../util/util.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
decodeUintSafe,
|
|
8
|
-
encodeI64,
|
|
9
|
-
encodeUintSafe
|
|
10
|
-
} from "./primitive.js";
|
|
3
|
+
import { readFixedData } from "./data.js";
|
|
4
|
+
import { readI64, readUintSafe, writeI64, writeUintSafe } from "./primitive.js";
|
|
5
|
+
import { writeU8FixedArray } from "./u8-array.js";
|
|
11
6
|
var I64_BYTE_COUNT = 8;
|
|
12
|
-
var
|
|
13
|
-
function
|
|
14
|
-
return
|
|
7
|
+
var readI64FixedArray = IS_LITTLE_ENDIAN_PLATFORM ? readI64FixedArrayLE : readI64FixedArrayBE;
|
|
8
|
+
function readI64Array(bc) {
|
|
9
|
+
return readI64FixedArray(bc, readUintSafe(bc));
|
|
15
10
|
}
|
|
16
|
-
function
|
|
11
|
+
function readI64FixedArrayLE(bc, len) {
|
|
17
12
|
const byteCount = len * I64_BYTE_COUNT;
|
|
18
|
-
return new BigInt64Array(
|
|
13
|
+
return new BigInt64Array(readFixedData(bc, byteCount));
|
|
19
14
|
}
|
|
20
|
-
function
|
|
15
|
+
function readI64FixedArrayBE(bc, len) {
|
|
21
16
|
bc.check(len * I64_BYTE_COUNT);
|
|
22
17
|
const result = new BigInt64Array(len);
|
|
23
18
|
for (let i = 0; i < len; i++)
|
|
24
|
-
result[i] =
|
|
19
|
+
result[i] = readI64(bc);
|
|
25
20
|
return result;
|
|
26
21
|
}
|
|
27
|
-
var
|
|
28
|
-
function
|
|
29
|
-
|
|
22
|
+
var writeI64FixedArray = IS_LITTLE_ENDIAN_PLATFORM ? writeI64FixedArrayLE : writeI64FixedArrayBE;
|
|
23
|
+
function writeI64Array(bc, x) {
|
|
24
|
+
writeUintSafe(bc, x.length);
|
|
30
25
|
if (x.length !== 0) {
|
|
31
|
-
|
|
26
|
+
writeI64FixedArray(bc, x);
|
|
32
27
|
}
|
|
33
28
|
}
|
|
34
|
-
function
|
|
35
|
-
|
|
36
|
-
bc.write(new Uint8Array(x.buffer, x.byteOffset, x.byteLength));
|
|
29
|
+
function writeI64FixedArrayLE(bc, x) {
|
|
30
|
+
writeU8FixedArray(bc, new Uint8Array(x.buffer, x.byteOffset, x.byteLength));
|
|
37
31
|
}
|
|
38
|
-
function
|
|
39
|
-
assert(x.length === len);
|
|
32
|
+
function writeI64FixedArrayBE(bc, x) {
|
|
40
33
|
bc.reserve(x.length * I64_BYTE_COUNT);
|
|
41
34
|
for (let i = 0; i < x.length; i++)
|
|
42
|
-
|
|
35
|
+
writeI64(bc, x[i]);
|
|
43
36
|
}
|
|
44
37
|
export {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
38
|
+
readI64Array,
|
|
39
|
+
readI64FixedArray,
|
|
40
|
+
writeI64Array,
|
|
41
|
+
writeI64FixedArray
|
|
49
42
|
};
|
|
50
43
|
//# sourceMappingURL=i64-array.js.map
|
package/dist/codec/i8-array.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ByteCursor } from "../core/index.js";
|
|
2
|
-
export declare function
|
|
3
|
-
export declare function
|
|
4
|
-
export declare function
|
|
5
|
-
export declare function
|
|
2
|
+
export declare function readI8Array(bc: ByteCursor): Int8Array;
|
|
3
|
+
export declare function writeI8Array(bc: ByteCursor, x: Int8Array): void;
|
|
4
|
+
export declare function readI8FixedArray(bc: ByteCursor, len: number): Int8Array;
|
|
5
|
+
export declare function writeI8FixedArray(bc: ByteCursor, x: Int8Array): void;
|
package/dist/codec/i8-array.js
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
// src/codec/i8-array.ts
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
function
|
|
6
|
-
return
|
|
2
|
+
import { readFixedData } from "./data.js";
|
|
3
|
+
import { readUintSafe, writeUintSafe } from "./primitive.js";
|
|
4
|
+
import { writeU8FixedArray } from "./u8-array.js";
|
|
5
|
+
function readI8Array(bc) {
|
|
6
|
+
return readI8FixedArray(bc, readUintSafe(bc));
|
|
7
7
|
}
|
|
8
|
-
function
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
function writeI8Array(bc, x) {
|
|
9
|
+
writeUintSafe(bc, x.length);
|
|
10
|
+
writeI8FixedArray(bc, x);
|
|
11
11
|
}
|
|
12
|
-
function
|
|
13
|
-
return new Int8Array(
|
|
12
|
+
function readI8FixedArray(bc, len) {
|
|
13
|
+
return new Int8Array(readFixedData(bc, len));
|
|
14
14
|
}
|
|
15
|
-
function
|
|
16
|
-
|
|
15
|
+
function writeI8FixedArray(bc, x) {
|
|
16
|
+
writeU8FixedArray(bc, new Uint8Array(x.buffer, x.byteOffset, x.byteLength));
|
|
17
17
|
}
|
|
18
18
|
export {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
readI8Array,
|
|
20
|
+
readI8FixedArray,
|
|
21
|
+
writeI8Array,
|
|
22
|
+
writeI8FixedArray
|
|
23
23
|
};
|
|
24
24
|
//# sourceMappingURL=i8-array.js.map
|
|
@@ -1,37 +1,37 @@
|
|
|
1
1
|
import { type ByteCursor } from "../core/index.js";
|
|
2
|
-
export declare function
|
|
3
|
-
export declare function
|
|
4
|
-
export declare function
|
|
5
|
-
export declare function
|
|
6
|
-
export declare function
|
|
7
|
-
export declare function
|
|
8
|
-
export declare function
|
|
9
|
-
export declare function
|
|
10
|
-
export declare function
|
|
11
|
-
export declare function
|
|
12
|
-
export declare function
|
|
13
|
-
export declare function
|
|
14
|
-
export declare function
|
|
15
|
-
export declare function
|
|
16
|
-
export declare function
|
|
17
|
-
export declare function
|
|
18
|
-
export declare function
|
|
19
|
-
export declare function
|
|
20
|
-
export declare function
|
|
21
|
-
export declare function
|
|
22
|
-
export declare function
|
|
23
|
-
export declare function
|
|
24
|
-
export declare function
|
|
25
|
-
export declare function
|
|
26
|
-
export declare function
|
|
27
|
-
export declare function
|
|
28
|
-
export declare function
|
|
29
|
-
export declare function
|
|
30
|
-
export declare function
|
|
31
|
-
export declare function
|
|
32
|
-
export declare function
|
|
33
|
-
export declare function
|
|
34
|
-
export declare function
|
|
35
|
-
export declare function
|
|
36
|
-
export declare function
|
|
37
|
-
export declare function
|
|
2
|
+
export declare function readBool(bc: ByteCursor): boolean;
|
|
3
|
+
export declare function writeBool(bc: ByteCursor, x: boolean): void;
|
|
4
|
+
export declare function readF32(bc: ByteCursor): number;
|
|
5
|
+
export declare function writeF32(bc: ByteCursor, x: number): void;
|
|
6
|
+
export declare function readF64(bc: ByteCursor): number;
|
|
7
|
+
export declare function writeF64(bc: ByteCursor, x: number): void;
|
|
8
|
+
export declare function readI8(bc: ByteCursor): number;
|
|
9
|
+
export declare function writeI8(bc: ByteCursor, x: number): void;
|
|
10
|
+
export declare function readI16(bc: ByteCursor): number;
|
|
11
|
+
export declare function writeI16(bc: ByteCursor, x: number): void;
|
|
12
|
+
export declare function readI32(bc: ByteCursor): number;
|
|
13
|
+
export declare function writeI32(bc: ByteCursor, x: number): void;
|
|
14
|
+
export declare function readI64(bc: ByteCursor): bigint;
|
|
15
|
+
export declare function writeI64(bc: ByteCursor, x: bigint): void;
|
|
16
|
+
export declare function readI64Safe(bc: ByteCursor): number;
|
|
17
|
+
export declare function writeI64Safe(bc: ByteCursor, x: number): void;
|
|
18
|
+
export declare function readInt(bc: ByteCursor): bigint;
|
|
19
|
+
export declare function writeInt(bc: ByteCursor, x: bigint): void;
|
|
20
|
+
export declare function readIntSafe(bc: ByteCursor): number;
|
|
21
|
+
export declare function writeIntSafe(bc: ByteCursor, x: number): void;
|
|
22
|
+
export declare function readU8(bc: ByteCursor): number;
|
|
23
|
+
export declare function writeU8(bc: ByteCursor, x: number): void;
|
|
24
|
+
export declare function readU16(bc: ByteCursor): number;
|
|
25
|
+
export declare function writeU16(bc: ByteCursor, x: number): void;
|
|
26
|
+
export declare function readU32(bc: ByteCursor): number;
|
|
27
|
+
export declare function writeU32(bc: ByteCursor, x: number): void;
|
|
28
|
+
export declare function readU64(bc: ByteCursor): bigint;
|
|
29
|
+
export declare function writeU64(bc: ByteCursor, x: bigint): void;
|
|
30
|
+
export declare function readU64Safe(bc: ByteCursor): number;
|
|
31
|
+
export declare function writeU64Safe(bc: ByteCursor, x: number): void;
|
|
32
|
+
export declare function readUint(bc: ByteCursor): bigint;
|
|
33
|
+
export declare function writeUint(bc: ByteCursor, x: bigint): void;
|
|
34
|
+
export declare function readUintSafe(bc: ByteCursor): number;
|
|
35
|
+
export declare function writeUintSafe(bc: ByteCursor, x: number): void;
|
|
36
|
+
export declare function readVoid(_dc: ByteCursor): undefined;
|
|
37
|
+
export declare function writeVoid(_dc: ByteCursor, _x: undefined): void;
|