@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.
@@ -1,5 +1,5 @@
1
1
  import type { ByteCursor } from "../core/index.js";
2
- export declare function decodeData(bc: ByteCursor): ArrayBuffer;
3
- export declare function encodeData(bc: ByteCursor, x: ArrayBuffer): void;
4
- export declare function decodeFixedData(bc: ByteCursor, len: number): ArrayBuffer;
5
- export declare function encodeFixedData(bc: ByteCursor, x: ArrayBuffer, len: number): void;
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;
@@ -1,26 +1,26 @@
1
1
  // src/codec/data.ts
2
2
  import {
3
- decodeU8Array,
4
- decodeU8FixedArray,
5
- encodeU8Array,
6
- encodeU8FixedArray
3
+ readU8Array,
4
+ readU8FixedArray,
5
+ writeU8Array,
6
+ writeU8FixedArray
7
7
  } from "./u8-array.js";
8
- function decodeData(bc) {
9
- return decodeU8Array(bc).buffer;
8
+ function readData(bc) {
9
+ return readU8Array(bc).buffer;
10
10
  }
11
- function encodeData(bc, x) {
12
- encodeU8Array(bc, new Uint8Array(x));
11
+ function writeData(bc, x) {
12
+ writeU8Array(bc, new Uint8Array(x));
13
13
  }
14
- function decodeFixedData(bc, len) {
15
- return decodeU8FixedArray(bc, len).buffer;
14
+ function readFixedData(bc, len) {
15
+ return readU8FixedArray(bc, len).buffer;
16
16
  }
17
- function encodeFixedData(bc, x, len) {
18
- encodeU8FixedArray(bc, new Uint8Array(x), len);
17
+ function writeFixedData(bc, x) {
18
+ writeU8FixedArray(bc, new Uint8Array(x));
19
19
  }
20
20
  export {
21
- decodeData,
22
- decodeFixedData,
23
- encodeData,
24
- encodeFixedData
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 decodeF32FixedArray: typeof decodeF32FixedArrayLE;
3
- declare function decodeF32FixedArrayLE(bc: ByteCursor, len: number): Float32Array;
4
- export declare const encodeF32FixedArray: typeof encodeF32FixedArrayLE;
5
- declare function encodeF32FixedArrayLE(bc: ByteCursor, x: Float32Array, len: number): void;
6
- export declare function decodeF32Array(bc: ByteCursor): Float32Array;
7
- export declare function encodeF32Array(bc: ByteCursor, x: Float32Array): void;
8
- export declare const decodeF64FixedArray: typeof decodeF64FixedArrayLE;
9
- declare function decodeF64FixedArrayLE(bc: ByteCursor, len: number): Float64Array;
10
- export declare const encodeF64FixedArray: typeof encodeF64FixedArrayLE;
11
- declare function encodeF64FixedArrayLE(bc: ByteCursor, x: Float64Array, len: number): void;
12
- export declare function decodeF64Array(bc: ByteCursor): Float64Array;
13
- export declare function encodeF64Array(bc: ByteCursor, x: Float64Array): void;
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 { decodeFixedData } from "./data.js";
5
+ import { readFixedData } from "./data.js";
6
6
  import {
7
- decodeF32,
8
- decodeF64,
9
- decodeUintSafe,
10
- encodeF32,
11
- encodeF64,
12
- encodeUintSafe
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 decodeF32FixedArray = IS_LITTLE_ENDIAN_PLATFORM ? decodeF32FixedArrayLE : decodeF32FixedArrayBE;
16
- function decodeF32FixedArrayLE(bc, len) {
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(decodeFixedData(bc, byteLen));
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 decodeF32FixedArrayBE(bc, len) {
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] = decodeF32(bc);
29
+ result[i] = readF32(bc);
29
30
  return result;
30
31
  }
31
- var encodeF32FixedArray = IS_LITTLE_ENDIAN_PLATFORM ? encodeF32FixedArrayLE : encodeF32FixedArrayBE;
32
- function encodeF32FixedArrayLE(bc, x, len) {
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.write(new Uint8Array(x.buffer, x.byteOffset, x.byteLength));
35
+ writeU8FixedArray(bc, new Uint8Array(x.buffer, x.byteOffset, x.byteLength));
36
36
  }
37
- function encodeF32FixedArrayBE(bc, val, len) {
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
- encodeF32(bc, val[i]);
40
+ writeF32(bc, val[i]);
42
41
  }
43
- function decodeF32Array(bc) {
44
- return decodeF32FixedArray(bc, decodeUintSafe(bc));
42
+ function readF32Array(bc) {
43
+ return readF32FixedArray(bc, readUintSafe(bc));
45
44
  }
46
- function encodeF32Array(bc, x) {
47
- encodeUintSafe(bc, x.length);
45
+ function writeF32Array(bc, x) {
46
+ writeUintSafe(bc, x.length);
48
47
  if (x.length !== 0) {
49
- encodeF32FixedArray(bc, x, x.length);
48
+ writeF32FixedArray(bc, x);
50
49
  }
51
50
  }
52
- var decodeF64FixedArray = IS_LITTLE_ENDIAN_PLATFORM ? decodeF64FixedArrayLE : decodeF64FixedArrayBE;
53
- function decodeF64FixedArrayLE(bc, len) {
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(decodeFixedData(bc, byteLen));
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 decodeF64FixedArrayBE(bc, len) {
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] = decodeF64(bc);
64
+ result[i] = readF64(bc);
66
65
  return result;
67
66
  }
68
- var encodeF64FixedArray = IS_LITTLE_ENDIAN_PLATFORM ? encodeF64FixedArrayLE : encodeF64FixedArrayBE;
69
- function encodeF64FixedArrayLE(bc, x, len) {
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.write(new Uint8Array(x.buffer, x.byteOffset, x.byteLength));
70
+ writeU8FixedArray(bc, new Uint8Array(x.buffer, x.byteOffset, x.byteLength));
73
71
  }
74
- function encodeF64FixedArrayBE(bc, x, len) {
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
- encodeF64(bc, x[i]);
75
+ writeF64(bc, x[i]);
79
76
  }
80
- function decodeF64Array(bc) {
81
- return decodeF64FixedArray(bc, decodeUintSafe(bc));
77
+ function readF64Array(bc) {
78
+ return readF64FixedArray(bc, readUintSafe(bc));
82
79
  }
83
- function encodeF64Array(bc, x) {
84
- encodeUintSafe(bc, x.length);
80
+ function writeF64Array(bc, x) {
81
+ writeUintSafe(bc, x.length);
85
82
  if (x.length !== 0) {
86
- encodeF64FixedArray(bc, x, x.length);
83
+ writeF64FixedArray(bc, x);
87
84
  }
88
85
  }
89
86
  export {
90
- decodeF32Array,
91
- decodeF32FixedArray,
92
- decodeF64Array,
93
- decodeF64FixedArray,
94
- encodeF32Array,
95
- encodeF32FixedArray,
96
- encodeF64Array,
97
- encodeF64FixedArray
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 decodeI16FixedArray: typeof decodeI16FixedArrayLE;
3
- export declare function decodeI16Array(bc: ByteCursor): Int16Array;
4
- declare function decodeI16FixedArrayLE(bc: ByteCursor, len: number): Int16Array;
5
- export declare const encodeI16FixedArray: typeof encodeI16FixedArrayLE;
6
- export declare function encodeI16Array(bc: ByteCursor, x: Int16Array): void;
7
- declare function encodeI16FixedArrayLE(bc: ByteCursor, x: Int16Array, len: number): void;
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 {};
@@ -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 { decodeFixedData } from "./data.js";
5
- import {
6
- decodeI16,
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 decodeI16FixedArray = IS_LITTLE_ENDIAN_PLATFORM ? decodeI16FixedArrayLE : decodeI16FixedArrayBE;
13
- function decodeI16Array(bc) {
14
- return decodeI16FixedArray(bc, decodeUintSafe(bc));
7
+ var readI16FixedArray = IS_LITTLE_ENDIAN_PLATFORM ? readI16FixedArrayLE : readI16FixedArrayBE;
8
+ function readI16Array(bc) {
9
+ return readI16FixedArray(bc, readUintSafe(bc));
15
10
  }
16
- function decodeI16FixedArrayLE(bc, len) {
11
+ function readI16FixedArrayLE(bc, len) {
17
12
  const byteCount = len * I16_BYTE_COUNT;
18
- return new Int16Array(decodeFixedData(bc, byteCount));
13
+ return new Int16Array(readFixedData(bc, byteCount));
19
14
  }
20
- function decodeI16FixedArrayBE(bc, len) {
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] = decodeI16(bc);
19
+ result[i] = readI16(bc);
25
20
  return result;
26
21
  }
27
- var encodeI16FixedArray = IS_LITTLE_ENDIAN_PLATFORM ? encodeI16FixedArrayLE : encodeI16FixedArrayBE;
28
- function encodeI16Array(bc, x) {
29
- encodeUintSafe(bc, x.length);
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
- encodeI16FixedArray(bc, x, x.length);
26
+ writeI16FixedArray(bc, x);
32
27
  }
33
28
  }
34
- function encodeI16FixedArrayLE(bc, x, len) {
35
- assert(x.length === len);
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 encodeI16FixedArrayBE(bc, x, len) {
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
- encodeI16(bc, x[i]);
35
+ writeI16(bc, x[i]);
43
36
  }
44
37
  export {
45
- decodeI16Array,
46
- decodeI16FixedArray,
47
- encodeI16Array,
48
- encodeI16FixedArray
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 decodeI32FixedArray: typeof decodeI32FixedArrayLE;
3
- export declare function decodeI32Array(bc: ByteCursor): Int32Array;
4
- declare function decodeI32FixedArrayLE(bc: ByteCursor, len: number): Int32Array;
5
- export declare const encodeI32FixedArray: typeof encodeI32FixedArrayLE;
6
- export declare function encodeI32Array(bc: ByteCursor, x: Int32Array): void;
7
- declare function encodeI32FixedArrayLE(bc: ByteCursor, x: Int32Array, len: number): void;
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 {};
@@ -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 { decodeFixedData } from "./data.js";
5
- import {
6
- decodeI32,
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 decodeI32FixedArray = IS_LITTLE_ENDIAN_PLATFORM ? decodeI32FixedArrayLE : decodeI32FixedArrayBE;
13
- function decodeI32Array(bc) {
14
- return decodeI32FixedArray(bc, decodeUintSafe(bc));
7
+ var readI32FixedArray = IS_LITTLE_ENDIAN_PLATFORM ? readI32FixedArrayLE : readI32FixedArrayBE;
8
+ function readI32Array(bc) {
9
+ return readI32FixedArray(bc, readUintSafe(bc));
15
10
  }
16
- function decodeI32FixedArrayLE(bc, len) {
11
+ function readI32FixedArrayLE(bc, len) {
17
12
  const byteCount = len * I32_BYTE_COUNT;
18
- return new Int32Array(decodeFixedData(bc, byteCount));
13
+ return new Int32Array(readFixedData(bc, byteCount));
19
14
  }
20
- function decodeI32FixedArrayBE(bc, len) {
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] = decodeI32(bc);
19
+ result[i] = readI32(bc);
25
20
  return result;
26
21
  }
27
- var encodeI32FixedArray = IS_LITTLE_ENDIAN_PLATFORM ? encodeI32FixedArrayLE : encodeI32FixedArrayBE;
28
- function encodeI32Array(bc, x) {
29
- encodeUintSafe(bc, x.length);
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
- encodeI32FixedArray(bc, x, x.length);
26
+ writeI32FixedArray(bc, x);
32
27
  }
33
28
  }
34
- function encodeI32FixedArrayLE(bc, x, len) {
35
- assert(x.length === len);
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 encodeI32FixedArrayBE(bc, x, len) {
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
- encodeI32(bc, x[i]);
35
+ writeI32(bc, x[i]);
43
36
  }
44
37
  export {
45
- decodeI32Array,
46
- decodeI32FixedArray,
47
- encodeI32Array,
48
- encodeI32FixedArray
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 decodeI64FixedArray: typeof decodeI64FixedArrayLE;
3
- export declare function decodeI64Array(bc: ByteCursor): BigInt64Array;
4
- declare function decodeI64FixedArrayLE(bc: ByteCursor, len: number): BigInt64Array;
5
- export declare const encodeI64FixedArray: typeof encodeI64FixedArrayLE;
6
- export declare function encodeI64Array(bc: ByteCursor, x: BigInt64Array): void;
7
- declare function encodeI64FixedArrayLE(bc: ByteCursor, x: BigInt64Array, len: number): void;
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 {};
@@ -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 { decodeFixedData } from "./data.js";
5
- import {
6
- decodeI64,
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 decodeI64FixedArray = IS_LITTLE_ENDIAN_PLATFORM ? decodeI64FixedArrayLE : decodeI64FixedArrayBE;
13
- function decodeI64Array(bc) {
14
- return decodeI64FixedArray(bc, decodeUintSafe(bc));
7
+ var readI64FixedArray = IS_LITTLE_ENDIAN_PLATFORM ? readI64FixedArrayLE : readI64FixedArrayBE;
8
+ function readI64Array(bc) {
9
+ return readI64FixedArray(bc, readUintSafe(bc));
15
10
  }
16
- function decodeI64FixedArrayLE(bc, len) {
11
+ function readI64FixedArrayLE(bc, len) {
17
12
  const byteCount = len * I64_BYTE_COUNT;
18
- return new BigInt64Array(decodeFixedData(bc, byteCount));
13
+ return new BigInt64Array(readFixedData(bc, byteCount));
19
14
  }
20
- function decodeI64FixedArrayBE(bc, len) {
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] = decodeI64(bc);
19
+ result[i] = readI64(bc);
25
20
  return result;
26
21
  }
27
- var encodeI64FixedArray = IS_LITTLE_ENDIAN_PLATFORM ? encodeI64FixedArrayLE : encodeI64FixedArrayBE;
28
- function encodeI64Array(bc, x) {
29
- encodeUintSafe(bc, x.length);
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
- encodeI64FixedArray(bc, x, x.length);
26
+ writeI64FixedArray(bc, x);
32
27
  }
33
28
  }
34
- function encodeI64FixedArrayLE(bc, x, len) {
35
- assert(x.length === len);
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 encodeI64FixedArrayBE(bc, x, len) {
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
- encodeI64(bc, x[i]);
35
+ writeI64(bc, x[i]);
43
36
  }
44
37
  export {
45
- decodeI64Array,
46
- decodeI64FixedArray,
47
- encodeI64Array,
48
- encodeI64FixedArray
38
+ readI64Array,
39
+ readI64FixedArray,
40
+ writeI64Array,
41
+ writeI64FixedArray
49
42
  };
50
43
  //# sourceMappingURL=i64-array.js.map
@@ -1,5 +1,5 @@
1
1
  import type { ByteCursor } from "../core/index.js";
2
- export declare function decodeI8Array(bc: ByteCursor): Int8Array;
3
- export declare function encodeI8Array(bc: ByteCursor, x: Int8Array): void;
4
- export declare function decodeI8FixedArray(bc: ByteCursor, len: number): Int8Array;
5
- export declare function encodeI8FixedArray(bc: ByteCursor, x: Int8Array, len: number): void;
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;
@@ -1,24 +1,24 @@
1
1
  // src/codec/i8-array.ts
2
- import { decodeFixedData } from "./data.js";
3
- import { decodeUintSafe, encodeUintSafe } from "./primitive.js";
4
- import { encodeU8FixedArray } from "./u8-array.js";
5
- function decodeI8Array(bc) {
6
- return decodeI8FixedArray(bc, decodeUintSafe(bc));
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 encodeI8Array(bc, x) {
9
- encodeUintSafe(bc, x.length);
10
- encodeI8FixedArray(bc, x, x.length);
8
+ function writeI8Array(bc, x) {
9
+ writeUintSafe(bc, x.length);
10
+ writeI8FixedArray(bc, x);
11
11
  }
12
- function decodeI8FixedArray(bc, len) {
13
- return new Int8Array(decodeFixedData(bc, len));
12
+ function readI8FixedArray(bc, len) {
13
+ return new Int8Array(readFixedData(bc, len));
14
14
  }
15
- function encodeI8FixedArray(bc, x, len) {
16
- encodeU8FixedArray(bc, new Uint8Array(x.buffer, x.byteOffset, x.byteLength), len);
15
+ function writeI8FixedArray(bc, x) {
16
+ writeU8FixedArray(bc, new Uint8Array(x.buffer, x.byteOffset, x.byteLength));
17
17
  }
18
18
  export {
19
- decodeI8Array,
20
- decodeI8FixedArray,
21
- encodeI8Array,
22
- encodeI8FixedArray
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 decodeBool(bc: ByteCursor): boolean;
3
- export declare function encodeBool(bc: ByteCursor, x: boolean): void;
4
- export declare function decodeF32(bc: ByteCursor): number;
5
- export declare function encodeF32(bc: ByteCursor, x: number): void;
6
- export declare function decodeF64(bc: ByteCursor): number;
7
- export declare function encodeF64(bc: ByteCursor, x: number): void;
8
- export declare function decodeI8(bc: ByteCursor): number;
9
- export declare function encodeI8(bc: ByteCursor, x: number): void;
10
- export declare function decodeI16(bc: ByteCursor): number;
11
- export declare function encodeI16(bc: ByteCursor, x: number): void;
12
- export declare function decodeI32(bc: ByteCursor): number;
13
- export declare function encodeI32(bc: ByteCursor, x: number): void;
14
- export declare function decodeI64(bc: ByteCursor): bigint;
15
- export declare function encodeI64(bc: ByteCursor, x: bigint): void;
16
- export declare function decodeI64Safe(bc: ByteCursor): number;
17
- export declare function encodeI64Safe(bc: ByteCursor, x: number): void;
18
- export declare function decodeInt(bc: ByteCursor): bigint;
19
- export declare function encodeInt(bc: ByteCursor, x: bigint): void;
20
- export declare function decodeIntSafe(bc: ByteCursor): number;
21
- export declare function encodeIntSafe(bc: ByteCursor, x: number): void;
22
- export declare function decodeU8(bc: ByteCursor): number;
23
- export declare function encodeU8(bc: ByteCursor, x: number): void;
24
- export declare function decodeU16(bc: ByteCursor): number;
25
- export declare function encodeU16(bc: ByteCursor, x: number): void;
26
- export declare function decodeU32(bc: ByteCursor): number;
27
- export declare function encodeU32(bc: ByteCursor, x: number): void;
28
- export declare function decodeU64(bc: ByteCursor): bigint;
29
- export declare function encodeU64(bc: ByteCursor, x: bigint): void;
30
- export declare function decodeU64Safe(bc: ByteCursor): number;
31
- export declare function encodeU64Safe(bc: ByteCursor, x: number): void;
32
- export declare function decodeUint(bc: ByteCursor): bigint;
33
- export declare function encodeUint(bc: ByteCursor, x: bigint): void;
34
- export declare function decodeUintSafe(bc: ByteCursor): number;
35
- export declare function encodeUintSafe(bc: ByteCursor, x: number): void;
36
- export declare function decodeVoid(_dc: ByteCursor): undefined;
37
- export declare function encodeVoid(_dc: ByteCursor, _x: undefined): void;
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;