@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/index.cjs CHANGED
@@ -27,99 +27,98 @@ __export(src_exports, {
27
27
  BareError: () => BareError,
28
28
  ByteCursor: () => ByteCursor,
29
29
  Config: () => Config,
30
- decodeBool: () => decodeBool,
31
- decodeData: () => decodeData,
32
- decodeF32: () => decodeF32,
33
- decodeF32Array: () => decodeF32Array,
34
- decodeF32FixedArray: () => decodeF32FixedArray,
35
- decodeF64: () => decodeF64,
36
- decodeF64Array: () => decodeF64Array,
37
- decodeF64FixedArray: () => decodeF64FixedArray,
38
- decodeFixedData: () => decodeFixedData,
39
- decodeI16: () => decodeI16,
40
- decodeI16Array: () => decodeI16Array,
41
- decodeI16FixedArray: () => decodeI16FixedArray,
42
- decodeI32: () => decodeI32,
43
- decodeI32Array: () => decodeI32Array,
44
- decodeI32FixedArray: () => decodeI32FixedArray,
45
- decodeI64: () => decodeI64,
46
- decodeI64Array: () => decodeI64Array,
47
- decodeI64FixedArray: () => decodeI64FixedArray,
48
- decodeI64Safe: () => decodeI64Safe,
49
- decodeI8: () => decodeI8,
50
- decodeI8Array: () => decodeI8Array,
51
- decodeI8FixedArray: () => decodeI8FixedArray,
52
- decodeInt: () => decodeInt,
53
- decodeIntSafe: () => decodeIntSafe,
54
- decodeString: () => decodeString,
55
- decodeU16: () => decodeU16,
56
- decodeU16Array: () => decodeU16Array,
57
- decodeU16FixedArray: () => decodeU16FixedArray,
58
- decodeU32: () => decodeU32,
59
- decodeU32Array: () => decodeU32Array,
60
- decodeU32FixedArray: () => decodeU32FixedArray,
61
- decodeU64: () => decodeU64,
62
- decodeU64Array: () => decodeU64Array,
63
- decodeU64FixedArray: () => decodeU64FixedArray,
64
- decodeU64Safe: () => decodeU64Safe,
65
- decodeU8: () => decodeU8,
66
- decodeU8Array: () => decodeU8Array,
67
- decodeU8ClampedArray: () => decodeU8ClampedArray,
68
- decodeU8ClampedFixedArray: () => decodeU8ClampedFixedArray,
69
- decodeU8FixedArray: () => decodeU8FixedArray,
70
- decodeUint: () => decodeUint,
71
- decodeUintSafe: () => decodeUintSafe,
72
- decodeVoid: () => decodeVoid,
73
- encodeBool: () => encodeBool,
74
- encodeData: () => encodeData,
75
- encodeF32: () => encodeF32,
76
- encodeF32Array: () => encodeF32Array,
77
- encodeF32FixedArray: () => encodeF32FixedArray,
78
- encodeF64: () => encodeF64,
79
- encodeF64Array: () => encodeF64Array,
80
- encodeF64FixedArray: () => encodeF64FixedArray,
81
- encodeFixedData: () => encodeFixedData,
82
- encodeI16: () => encodeI16,
83
- encodeI16Array: () => encodeI16Array,
84
- encodeI16FixedArray: () => encodeI16FixedArray,
85
- encodeI32: () => encodeI32,
86
- encodeI32Array: () => encodeI32Array,
87
- encodeI32FixedArray: () => encodeI32FixedArray,
88
- encodeI64: () => encodeI64,
89
- encodeI64Array: () => encodeI64Array,
90
- encodeI64FixedArray: () => encodeI64FixedArray,
91
- encodeI64Safe: () => encodeI64Safe,
92
- encodeI8: () => encodeI8,
93
- encodeI8Array: () => encodeI8Array,
94
- encodeI8FixedArray: () => encodeI8FixedArray,
95
- encodeInt: () => encodeInt,
96
- encodeIntSafe: () => encodeIntSafe,
97
- encodeString: () => encodeString,
98
- encodeU16: () => encodeU16,
99
- encodeU16Array: () => encodeU16Array,
100
- encodeU16FixedArray: () => encodeU16FixedArray,
101
- encodeU32: () => encodeU32,
102
- encodeU32Array: () => encodeU32Array,
103
- encodeU32FixedArray: () => encodeU32FixedArray,
104
- encodeU64: () => encodeU64,
105
- encodeU64Array: () => encodeU64Array,
106
- encodeU64FixedArray: () => encodeU64FixedArray,
107
- encodeU64Safe: () => encodeU64Safe,
108
- encodeU8: () => encodeU8,
109
- encodeU8Array: () => encodeU8Array,
110
- encodeU8ClampedArray: () => encodeU8ClampedArray,
111
- encodeU8ClampedFixedArray: () => encodeU8ClampedFixedArray,
112
- encodeU8FixedArray: () => encodeU8FixedArray,
113
- encodeUint: () => encodeUint,
114
- encodeUintSafe: () => encodeUintSafe,
115
- encodeVoid: () => encodeVoid
30
+ readBool: () => readBool,
31
+ readData: () => readData,
32
+ readF32: () => readF32,
33
+ readF32Array: () => readF32Array,
34
+ readF32FixedArray: () => readF32FixedArray,
35
+ readF64: () => readF64,
36
+ readF64Array: () => readF64Array,
37
+ readF64FixedArray: () => readF64FixedArray,
38
+ readFixedData: () => readFixedData,
39
+ readFixedString: () => readFixedString,
40
+ readI16: () => readI16,
41
+ readI16Array: () => readI16Array,
42
+ readI16FixedArray: () => readI16FixedArray,
43
+ readI32: () => readI32,
44
+ readI32Array: () => readI32Array,
45
+ readI32FixedArray: () => readI32FixedArray,
46
+ readI64: () => readI64,
47
+ readI64Array: () => readI64Array,
48
+ readI64FixedArray: () => readI64FixedArray,
49
+ readI64Safe: () => readI64Safe,
50
+ readI8: () => readI8,
51
+ readI8Array: () => readI8Array,
52
+ readI8FixedArray: () => readI8FixedArray,
53
+ readInt: () => readInt,
54
+ readIntSafe: () => readIntSafe,
55
+ readString: () => readString,
56
+ readU16: () => readU16,
57
+ readU16Array: () => readU16Array,
58
+ readU16FixedArray: () => readU16FixedArray,
59
+ readU32: () => readU32,
60
+ readU32Array: () => readU32Array,
61
+ readU32FixedArray: () => readU32FixedArray,
62
+ readU64: () => readU64,
63
+ readU64Array: () => readU64Array,
64
+ readU64FixedArray: () => readU64FixedArray,
65
+ readU64Safe: () => readU64Safe,
66
+ readU8: () => readU8,
67
+ readU8Array: () => readU8Array,
68
+ readU8ClampedArray: () => readU8ClampedArray,
69
+ readU8ClampedFixedArray: () => readU8ClampedFixedArray,
70
+ readU8FixedArray: () => readU8FixedArray,
71
+ readUint: () => readUint,
72
+ readUintSafe: () => readUintSafe,
73
+ readVoid: () => readVoid,
74
+ writeBool: () => writeBool,
75
+ writeData: () => writeData,
76
+ writeF32: () => writeF32,
77
+ writeF32Array: () => writeF32Array,
78
+ writeF32FixedArray: () => writeF32FixedArray,
79
+ writeF64: () => writeF64,
80
+ writeF64Array: () => writeF64Array,
81
+ writeF64FixedArray: () => writeF64FixedArray,
82
+ writeFixedData: () => writeFixedData,
83
+ writeFixedString: () => writeFixedString,
84
+ writeI16: () => writeI16,
85
+ writeI16Array: () => writeI16Array,
86
+ writeI16FixedArray: () => writeI16FixedArray,
87
+ writeI32: () => writeI32,
88
+ writeI32Array: () => writeI32Array,
89
+ writeI32FixedArray: () => writeI32FixedArray,
90
+ writeI64: () => writeI64,
91
+ writeI64Array: () => writeI64Array,
92
+ writeI64FixedArray: () => writeI64FixedArray,
93
+ writeI64Safe: () => writeI64Safe,
94
+ writeI8: () => writeI8,
95
+ writeI8Array: () => writeI8Array,
96
+ writeI8FixedArray: () => writeI8FixedArray,
97
+ writeInt: () => writeInt,
98
+ writeIntSafe: () => writeIntSafe,
99
+ writeString: () => writeString,
100
+ writeU16: () => writeU16,
101
+ writeU16Array: () => writeU16Array,
102
+ writeU16FixedArray: () => writeU16FixedArray,
103
+ writeU32: () => writeU32,
104
+ writeU32Array: () => writeU32Array,
105
+ writeU32FixedArray: () => writeU32FixedArray,
106
+ writeU64: () => writeU64,
107
+ writeU64Array: () => writeU64Array,
108
+ writeU64FixedArray: () => writeU64FixedArray,
109
+ writeU64Safe: () => writeU64Safe,
110
+ writeU8: () => writeU8,
111
+ writeU8Array: () => writeU8Array,
112
+ writeU8ClampedArray: () => writeU8ClampedArray,
113
+ writeU8ClampedFixedArray: () => writeU8ClampedFixedArray,
114
+ writeU8FixedArray: () => writeU8FixedArray,
115
+ writeUint: () => writeUint,
116
+ writeUintSafe: () => writeUintSafe,
117
+ writeVoid: () => writeVoid
116
118
  });
117
119
 
118
- // src/codec/u8-array.ts
119
- var import_assert4 = require("assert");
120
-
121
120
  // src/codec/primitive.ts
122
- var import_assert3 = require("assert");
121
+ var import_assert2 = require("assert");
123
122
 
124
123
  // src/core/bare-error.ts
125
124
  var BareError = class extends Error {
@@ -186,50 +185,40 @@ function Config(part) {
186
185
  }
187
186
 
188
187
  // src/core/byte-cursor.ts
189
- var import_assert2 = require("assert");
190
188
  var TOO_LARGE_BUFFER = "too large buffer";
191
189
  var ByteCursor = class {
192
190
  constructor(bytes, config) {
193
- this.config = config;
194
- this.offset = 0;
195
- this.view = bytes instanceof Uint8Array ? new DataView(bytes.buffer, bytes.byteOffset, bytes.length) : new DataView(bytes);
196
- if (this.view.byteLength > config.maxBufferLength) {
191
+ if (bytes.length > config.maxBufferLength) {
197
192
  throw new BareError(0, TOO_LARGE_BUFFER);
198
193
  }
194
+ this.bytes = bytes;
195
+ this.config = config;
196
+ this.offset = 0;
197
+ this.view = new DataView(bytes.buffer, bytes.byteOffset, bytes.length);
199
198
  }
200
199
  check(min) {
201
- if (this.offset + min > this.view.byteLength) {
200
+ if (this.offset + min > this.bytes.length) {
202
201
  throw new BareError(this.offset, "missing bytes");
203
202
  }
204
203
  }
205
204
  reserve(min) {
206
- const { config, offset, view } = this;
207
- if (offset + min > view.byteLength) {
208
- const bytes = new Uint8Array(view.buffer);
209
- const minExtraLength = min + offset - view.byteLength;
210
- (0, import_assert2.ok)(bytes.length === view.byteOffset + view.byteLength, "un-growable buffer");
211
- (0, import_assert2.ok)(bytes.length + minExtraLength <= config.maxBufferLength, TOO_LARGE_BUFFER);
212
- const newLen = Math.min(bytes.length + Math.max(minExtraLength, bytes.length), config.maxBufferLength);
205
+ const minLen = this.offset + min | 0;
206
+ if (minLen > this.bytes.length) {
207
+ if (minLen > this.config.maxBufferLength) {
208
+ throw new BareError(0, TOO_LARGE_BUFFER);
209
+ }
210
+ const newLen = Math.min(minLen << 1, this.config.maxBufferLength);
213
211
  const newBytes = new Uint8Array(newLen);
214
- newBytes.set(bytes);
215
- this.view = new DataView(newBytes.buffer, view.byteOffset);
212
+ newBytes.set(this.bytes);
213
+ this.bytes = newBytes;
214
+ this.view = new DataView(newBytes.buffer);
216
215
  }
217
216
  }
218
217
  read(len) {
219
218
  this.check(len);
220
- const bufferOffset = this.view.byteOffset + this.offset;
219
+ const offset = this.offset;
221
220
  this.offset += len;
222
- return new Uint8Array(this.view.buffer, bufferOffset, len);
223
- }
224
- write(bytes) {
225
- const len = bytes.length;
226
- if (len !== 0) {
227
- this.reserve(len);
228
- const bufferOffset = this.view.byteOffset + this.offset;
229
- const buffer = new Uint8Array(this.view.buffer);
230
- buffer.set(bytes, bufferOffset);
231
- this.offset += len;
232
- }
221
+ return this.bytes.subarray(offset, offset + len);
233
222
  }
234
223
  };
235
224
 
@@ -237,18 +226,18 @@ var ByteCursor = class {
237
226
  var NAN_NOT_ALLOWED = "NaN is not allowed";
238
227
  var NON_CANONICAL_REPRESENTATION = "must be canonical";
239
228
  var TOO_LARGE_NUMBER2 = "too large number";
240
- function decodeBool(bc) {
241
- const val = decodeU8(bc);
229
+ function readBool(bc) {
230
+ const val = readU8(bc);
242
231
  if (val > 1) {
243
232
  bc.offset--;
244
233
  throw new BareError(bc.offset, "a bool must be equal to 0 or 1");
245
234
  }
246
235
  return val !== 0;
247
236
  }
248
- function encodeBool(bc, x) {
249
- encodeU8(bc, x ? 1 : 0);
237
+ function writeBool(bc, x) {
238
+ writeU8(bc, x ? 1 : 0);
250
239
  }
251
- function decodeF32(bc) {
240
+ function readF32(bc) {
252
241
  bc.check(4);
253
242
  const result = bc.view.getFloat32(bc.offset, true);
254
243
  if (Number.isNaN(result)) {
@@ -257,14 +246,14 @@ function decodeF32(bc) {
257
246
  bc.offset += 4;
258
247
  return result;
259
248
  }
260
- function encodeF32(bc, x) {
261
- (0, import_assert3.ok)(!Number.isNaN(x), NAN_NOT_ALLOWED);
249
+ function writeF32(bc, x) {
250
+ (0, import_assert2.ok)(!Number.isNaN(x), NAN_NOT_ALLOWED);
262
251
  bc.reserve(4);
263
252
  bc.view.setFloat32(bc.offset, x, true);
264
- (0, import_assert3.ok)(Math.abs(bc.view.getFloat32(bc.offset, true) - x) <= Number.EPSILON, TOO_LARGE_NUMBER2);
253
+ (0, import_assert2.ok)(Math.abs(bc.view.getFloat32(bc.offset, true) - x) <= Number.EPSILON, TOO_LARGE_NUMBER2);
265
254
  bc.offset += 4;
266
255
  }
267
- function decodeF64(bc) {
256
+ function readF64(bc) {
268
257
  bc.check(8);
269
258
  const result = bc.view.getFloat64(bc.offset, true);
270
259
  if (Number.isNaN(result)) {
@@ -273,69 +262,69 @@ function decodeF64(bc) {
273
262
  bc.offset += 8;
274
263
  return result;
275
264
  }
276
- function encodeF64(bc, x) {
277
- (0, import_assert3.ok)(!Number.isNaN(x), NAN_NOT_ALLOWED);
265
+ function writeF64(bc, x) {
266
+ (0, import_assert2.ok)(!Number.isNaN(x), NAN_NOT_ALLOWED);
278
267
  bc.reserve(8);
279
268
  bc.view.setFloat64(bc.offset, x, true);
280
269
  bc.offset += 8;
281
270
  }
282
- function decodeI8(bc) {
271
+ function readI8(bc) {
283
272
  bc.check(1);
284
273
  return bc.view.getInt8(bc.offset++);
285
274
  }
286
- function encodeI8(bc, x) {
287
- (0, import_assert3.ok)(isI8(x), TOO_LARGE_NUMBER2);
275
+ function writeI8(bc, x) {
276
+ (0, import_assert2.ok)(isI8(x), TOO_LARGE_NUMBER2);
288
277
  bc.reserve(1);
289
278
  bc.view.setInt8(bc.offset++, x);
290
279
  }
291
- function decodeI16(bc) {
280
+ function readI16(bc) {
292
281
  bc.check(2);
293
282
  const result = bc.view.getInt16(bc.offset, true);
294
283
  bc.offset += 2;
295
284
  return result;
296
285
  }
297
- function encodeI16(bc, x) {
298
- (0, import_assert3.ok)(isI16(x), TOO_LARGE_NUMBER2);
286
+ function writeI16(bc, x) {
287
+ (0, import_assert2.ok)(isI16(x), TOO_LARGE_NUMBER2);
299
288
  bc.reserve(2);
300
289
  bc.view.setInt16(bc.offset, x, true);
301
290
  bc.offset += 2;
302
291
  }
303
- function decodeI32(bc) {
292
+ function readI32(bc) {
304
293
  bc.check(4);
305
294
  const result = bc.view.getInt32(bc.offset, true);
306
295
  bc.offset += 4;
307
296
  return result;
308
297
  }
309
- function encodeI32(bc, x) {
310
- (0, import_assert3.ok)(isI32(x), TOO_LARGE_NUMBER2);
298
+ function writeI32(bc, x) {
299
+ (0, import_assert2.ok)(isI32(x), TOO_LARGE_NUMBER2);
311
300
  bc.reserve(4);
312
301
  bc.view.setInt32(bc.offset, x, true);
313
302
  bc.offset += 4;
314
303
  }
315
- function decodeI64(bc) {
304
+ function readI64(bc) {
316
305
  bc.check(8);
317
306
  const result = bc.view.getBigInt64(bc.offset, true);
318
307
  bc.offset += 8;
319
308
  return result;
320
309
  }
321
- function encodeI64(bc, x) {
322
- (0, import_assert3.ok)(isI64(x), TOO_LARGE_NUMBER2);
310
+ function writeI64(bc, x) {
311
+ (0, import_assert2.ok)(isI64(x), TOO_LARGE_NUMBER2);
323
312
  bc.reserve(8);
324
313
  bc.view.setBigInt64(bc.offset, x, true);
325
314
  bc.offset += 8;
326
315
  }
327
- function decodeI64Safe(bc) {
328
- const result = decodeU32(bc) + decodeI32(bc) * 4294967296;
316
+ function readI64Safe(bc) {
317
+ const result = readU32(bc) + readI32(bc) * 4294967296;
329
318
  if (!Number.isSafeInteger(result)) {
330
319
  bc.offset -= 8;
331
320
  throw new BareError(bc.offset, TOO_LARGE_NUMBER2);
332
321
  }
333
322
  return result;
334
323
  }
335
- function encodeI64Safe(bc, x) {
336
- (0, import_assert3.ok)(Number.isSafeInteger(x), TOO_LARGE_NUMBER2);
324
+ function writeI64Safe(bc, x) {
325
+ (0, import_assert2.ok)(Number.isSafeInteger(x), TOO_LARGE_NUMBER2);
337
326
  const lowest32 = x >>> 0;
338
- encodeU32(bc, lowest32);
327
+ writeU32(bc, lowest32);
339
328
  let highest32 = x / 4294967296 | 0;
340
329
  if (x < 0) {
341
330
  highest32 = ~Math.abs(highest32) >>> 0;
@@ -343,27 +332,27 @@ function encodeI64Safe(bc, x) {
343
332
  highest32++;
344
333
  }
345
334
  }
346
- encodeU32(bc, highest32);
335
+ writeU32(bc, highest32);
347
336
  }
348
- function decodeInt(bc) {
349
- const zigZag = decodeUint(bc);
337
+ function readInt(bc) {
338
+ const zigZag = readUint(bc);
350
339
  return zigZag >> BigInt(1) ^ -(zigZag & BigInt(1));
351
340
  }
352
- function encodeInt(bc, x) {
353
- (0, import_assert3.ok)(isI64(x), TOO_LARGE_NUMBER2);
341
+ function writeInt(bc, x) {
342
+ (0, import_assert2.ok)(isI64(x), TOO_LARGE_NUMBER2);
354
343
  const zigZag = x >> BigInt(63) ^ x << BigInt(1);
355
- encodeUint(bc, zigZag);
344
+ writeUint(bc, zigZag);
356
345
  }
357
346
  var INT_SAFE_MAX_BYTE_COUNT = 8;
358
- function decodeIntSafe(bc) {
359
- const firstByte = decodeU8(bc);
347
+ function readIntSafe(bc) {
348
+ const firstByte = readU8(bc);
360
349
  let result = (firstByte & 127) >> 1;
361
350
  if (firstByte >= 128) {
362
351
  let shiftMul = 64;
363
352
  let byteCount = 1;
364
353
  let byte;
365
354
  do {
366
- byte = decodeU8(bc);
355
+ byte = readU8(bc);
367
356
  result += (byte & 127) * shiftMul;
368
357
  shiftMul *= 128;
369
358
  byteCount++;
@@ -383,8 +372,8 @@ function decodeIntSafe(bc) {
383
372
  }
384
373
  return result;
385
374
  }
386
- function encodeIntSafe(bc, x) {
387
- (0, import_assert3.ok)(Number.isSafeInteger(x), TOO_LARGE_NUMBER2);
375
+ function writeIntSafe(bc, x) {
376
+ (0, import_assert2.ok)(Number.isSafeInteger(x), TOO_LARGE_NUMBER2);
388
377
  const sign = x < 0 ? 1 : 0;
389
378
  if (x < 0) {
390
379
  x = -(x + 1);
@@ -392,103 +381,107 @@ function encodeIntSafe(bc, x) {
392
381
  const firstByte = (x & 63) << 1 | sign;
393
382
  x = Math.floor(x / 64);
394
383
  if (x > 0) {
395
- encodeU8(bc, 128 | firstByte);
396
- encodeUintSafe(bc, x);
384
+ writeU8(bc, 128 | firstByte);
385
+ writeUintSafe(bc, x);
397
386
  } else {
398
- encodeU8(bc, firstByte);
387
+ writeU8(bc, firstByte);
399
388
  }
400
389
  }
401
- function decodeU8(bc) {
390
+ function readU8(bc) {
402
391
  bc.check(1);
403
- return bc.view.getUint8(bc.offset++);
392
+ return bc.bytes[bc.offset++];
404
393
  }
405
- function encodeU8(bc, x) {
406
- (0, import_assert3.ok)(isU8(x), TOO_LARGE_NUMBER2);
394
+ function writeU8(bc, x) {
395
+ (0, import_assert2.ok)(isU8(x), TOO_LARGE_NUMBER2);
407
396
  bc.reserve(1);
408
- bc.view.setUint8(bc.offset++, x);
397
+ bc.bytes[bc.offset++] = x;
409
398
  }
410
- function decodeU16(bc) {
399
+ function readU16(bc) {
411
400
  bc.check(2);
412
401
  const result = bc.view.getUint16(bc.offset, true);
413
402
  bc.offset += 2;
414
403
  return result;
415
404
  }
416
- function encodeU16(bc, x) {
417
- (0, import_assert3.ok)(isU16(x), TOO_LARGE_NUMBER2);
405
+ function writeU16(bc, x) {
406
+ (0, import_assert2.ok)(isU16(x), TOO_LARGE_NUMBER2);
418
407
  bc.reserve(2);
419
408
  bc.view.setUint16(bc.offset, x, true);
420
409
  bc.offset += 2;
421
410
  }
422
- function decodeU32(bc) {
411
+ function readU32(bc) {
423
412
  bc.check(4);
424
413
  const result = bc.view.getUint32(bc.offset, true);
425
414
  bc.offset += 4;
426
415
  return result;
427
416
  }
428
- function encodeU32(bc, x) {
429
- (0, import_assert3.ok)(isU32(x), TOO_LARGE_NUMBER2);
417
+ function writeU32(bc, x) {
418
+ (0, import_assert2.ok)(isU32(x), TOO_LARGE_NUMBER2);
430
419
  bc.reserve(4);
431
420
  bc.view.setUint32(bc.offset, x, true);
432
421
  bc.offset += 4;
433
422
  }
434
- function decodeU64(bc) {
423
+ function readU64(bc) {
435
424
  bc.check(8);
436
425
  const result = bc.view.getBigUint64(bc.offset, true);
437
426
  bc.offset += 8;
438
427
  return result;
439
428
  }
440
- function encodeU64(bc, x) {
441
- (0, import_assert3.ok)(isU64(x), TOO_LARGE_NUMBER2);
429
+ function writeU64(bc, x) {
430
+ (0, import_assert2.ok)(isU64(x), TOO_LARGE_NUMBER2);
442
431
  bc.reserve(8);
443
432
  bc.view.setBigUint64(bc.offset, x, true);
444
433
  bc.offset += 8;
445
434
  }
446
- function decodeU64Safe(bc) {
447
- const result = decodeU32(bc) + decodeU32(bc) * 4294967296;
435
+ function readU64Safe(bc) {
436
+ const result = readU32(bc) + readU32(bc) * 4294967296;
448
437
  if (!isSafeU64(result)) {
449
438
  bc.offset -= 8;
450
439
  throw new BareError(bc.offset, TOO_LARGE_NUMBER2);
451
440
  }
452
441
  return result;
453
442
  }
454
- function encodeU64Safe(bc, x) {
455
- (0, import_assert3.ok)(isSafeU64(x), TOO_LARGE_NUMBER2);
456
- encodeU32(bc, x >>> 0);
457
- encodeU32(bc, x / 4294967296 >>> 0);
443
+ function writeU64Safe(bc, x) {
444
+ (0, import_assert2.ok)(isSafeU64(x), TOO_LARGE_NUMBER2);
445
+ writeU32(bc, x >>> 0);
446
+ writeU32(bc, x / 4294967296 >>> 0);
458
447
  }
459
448
  var UINT_MAX_BYTE_COUNT = 10;
460
- function decodeUint(bc) {
461
- let byteCount = 0;
462
- let byte;
463
- let low = 0;
464
- let shiftMul = 1;
465
- do {
466
- byte = decodeU8(bc);
467
- low += (byte & 127) * shiftMul;
468
- shiftMul *= 128;
469
- byteCount++;
470
- } while (byte >= 128 && byteCount < 7);
471
- let height = 0;
472
- shiftMul = 1;
473
- while (byte >= 128 && byteCount < UINT_MAX_BYTE_COUNT) {
474
- byte = decodeU8(bc);
475
- height += (byte & 127) * shiftMul;
476
- shiftMul *= 128;
477
- byteCount++;
478
- }
479
- if (byteCount !== 1 && byte === 0 || byteCount === UINT_MAX_BYTE_COUNT && byte > 1) {
480
- bc.offset -= byteCount;
481
- throw new BareError(bc.offset, NON_CANONICAL_REPRESENTATION);
449
+ function readUint(bc) {
450
+ let low = readU8(bc);
451
+ if (low >= 128) {
452
+ low &= 127;
453
+ let shiftMul = 128;
454
+ let byteCount = 1;
455
+ let byte;
456
+ do {
457
+ byte = readU8(bc);
458
+ low += (byte & 127) * shiftMul;
459
+ shiftMul *= 128;
460
+ byteCount++;
461
+ } while (byte >= 128 && byteCount < 7);
462
+ let height = 0;
463
+ shiftMul = 1;
464
+ while (byte >= 128 && byteCount < UINT_MAX_BYTE_COUNT) {
465
+ byte = readU8(bc);
466
+ height += (byte & 127) * shiftMul;
467
+ shiftMul *= 128;
468
+ byteCount++;
469
+ }
470
+ if (byte === 0 || byteCount === UINT_MAX_BYTE_COUNT && byte > 1) {
471
+ bc.offset -= byteCount;
472
+ throw new BareError(bc.offset, NON_CANONICAL_REPRESENTATION);
473
+ }
474
+ return BigInt(low) + (BigInt(height) << BigInt(7 * 7));
482
475
  }
483
- return BigInt(low) + (BigInt(height) << BigInt(7 * 7));
476
+ return BigInt(low);
484
477
  }
485
- function encodeUint(bc, x) {
486
- (0, import_assert3.ok)(isU64(x), TOO_LARGE_NUMBER2);
478
+ function writeUint(bc, x) {
479
+ (0, import_assert2.ok)(isU64(x), TOO_LARGE_NUMBER2);
487
480
  let tmp = Number(BigInt.asUintN(7 * 7, x));
488
481
  let rest = Number(x >> BigInt(7 * 7));
489
482
  let byteCount = 0;
490
483
  while (tmp >= 128 || rest !== 0) {
491
- encodeU8(bc, 128 | tmp & 127);
484
+ writeU8(bc, 128 | tmp & 127);
492
485
  tmp = Math.floor(tmp / 128);
493
486
  byteCount++;
494
487
  if (byteCount === 7) {
@@ -496,387 +489,381 @@ function encodeUint(bc, x) {
496
489
  rest = 0;
497
490
  }
498
491
  }
499
- encodeU8(bc, tmp);
492
+ writeU8(bc, tmp);
500
493
  }
501
494
  var UINT_SAFE_MAX_BYTE_COUNT = 8;
502
- function decodeUintSafe(bc) {
503
- let result = 0;
504
- let shiftMul = 1;
505
- let byteCount = 0;
506
- let byte;
507
- do {
508
- byte = decodeU8(bc);
509
- result += (byte & 127) * shiftMul;
510
- shiftMul *= 128;
511
- byteCount++;
512
- } while (byte >= 128 && byteCount < UINT_SAFE_MAX_BYTE_COUNT);
513
- if (byteCount !== 1 && byte === 0) {
514
- bc.offset -= byteCount - 1;
515
- throw new BareError(bc.offset - byteCount + 1, NON_CANONICAL_REPRESENTATION);
516
- }
517
- if (byteCount === UINT_SAFE_MAX_BYTE_COUNT && byte > 15) {
518
- bc.offset -= byteCount - 1;
519
- throw new BareError(bc.offset, TOO_LARGE_NUMBER2);
495
+ function readUintSafe(bc) {
496
+ let result = readU8(bc);
497
+ if (result >= 128) {
498
+ result &= 127;
499
+ let shiftMul = 128;
500
+ let byteCount = 1;
501
+ let byte;
502
+ do {
503
+ byte = readU8(bc);
504
+ result += (byte & 127) * shiftMul;
505
+ shiftMul *= 128;
506
+ byteCount++;
507
+ } while (byte >= 128 && byteCount < UINT_SAFE_MAX_BYTE_COUNT);
508
+ if (byte === 0) {
509
+ bc.offset -= byteCount - 1;
510
+ throw new BareError(bc.offset - byteCount + 1, NON_CANONICAL_REPRESENTATION);
511
+ }
512
+ if (byteCount === UINT_SAFE_MAX_BYTE_COUNT && byte > 15) {
513
+ bc.offset -= byteCount - 1;
514
+ throw new BareError(bc.offset, TOO_LARGE_NUMBER2);
515
+ }
520
516
  }
521
517
  return result;
522
518
  }
523
- function encodeUintSafe(bc, x) {
524
- (0, import_assert3.ok)(isSafeU64(x), TOO_LARGE_NUMBER2);
519
+ function writeUintSafe(bc, x) {
520
+ (0, import_assert2.ok)(isSafeU64(x), TOO_LARGE_NUMBER2);
525
521
  while (x >= 128) {
526
- encodeU8(bc, 128 | x & 127);
522
+ writeU8(bc, 128 | x & 127);
527
523
  x = Math.floor(x / 128);
528
524
  }
529
- encodeU8(bc, x);
525
+ writeU8(bc, x);
530
526
  }
531
- function decodeVoid(_dc) {
527
+ function readVoid(_dc) {
532
528
  return void 0;
533
529
  }
534
- function encodeVoid(_dc, _x) {
530
+ function writeVoid(_dc, _x) {
535
531
  }
536
532
 
537
533
  // src/codec/u8-array.ts
538
- function decodeU8Array(bc) {
539
- const len = decodeUintSafe(bc);
540
- return bc.read(len).slice();
534
+ function readU8Array(bc) {
535
+ return readU8FixedArray(bc, readUintSafe(bc));
541
536
  }
542
- function encodeU8Array(bc, x) {
543
- encodeUintSafe(bc, x.length);
544
- bc.write(x);
537
+ function writeU8Array(bc, x) {
538
+ writeUintSafe(bc, x.length);
539
+ writeU8FixedArray(bc, x);
545
540
  }
546
- function decodeU8FixedArray(bc, len) {
541
+ function readU8FixedArray(bc, len) {
547
542
  return bc.read(len).slice();
548
543
  }
549
- function encodeU8FixedArray(bc, x, len) {
550
- (0, import_assert4.ok)(x.length === len);
551
- bc.write(x);
544
+ function writeU8FixedArray(bc, x) {
545
+ const len = x.length;
546
+ if (len !== 0) {
547
+ bc.reserve(len);
548
+ bc.bytes.set(x, bc.offset);
549
+ bc.offset += len;
550
+ }
552
551
  }
553
552
 
554
553
  // src/codec/data.ts
555
- function decodeData(bc) {
556
- return decodeU8Array(bc).buffer;
554
+ function readData(bc) {
555
+ return readU8Array(bc).buffer;
557
556
  }
558
- function encodeData(bc, x) {
559
- encodeU8Array(bc, new Uint8Array(x));
557
+ function writeData(bc, x) {
558
+ writeU8Array(bc, new Uint8Array(x));
560
559
  }
561
- function decodeFixedData(bc, len) {
562
- return decodeU8FixedArray(bc, len).buffer;
560
+ function readFixedData(bc, len) {
561
+ return readU8FixedArray(bc, len).buffer;
563
562
  }
564
- function encodeFixedData(bc, x, len) {
565
- encodeU8FixedArray(bc, new Uint8Array(x), len);
563
+ function writeFixedData(bc, x) {
564
+ writeU8FixedArray(bc, new Uint8Array(x));
566
565
  }
567
566
 
568
567
  // src/codec/float-array.ts
569
- var import_assert5 = require("assert");
568
+ var import_assert3 = require("assert");
570
569
 
571
570
  // src/util/util.ts
572
571
  var IS_LITTLE_ENDIAN_PLATFORM = new DataView(Uint16Array.of(1).buffer).getUint8(0) === 1;
573
572
 
574
573
  // src/codec/float-array.ts
575
574
  var NAN_NOT_ALLOWED2 = "NaN is not allowed";
576
- var decodeF32FixedArray = IS_LITTLE_ENDIAN_PLATFORM ? decodeF32FixedArrayLE : decodeF32FixedArrayBE;
577
- function decodeF32FixedArrayLE(bc, len) {
575
+ var readF32FixedArray = IS_LITTLE_ENDIAN_PLATFORM ? readF32FixedArrayLE : readF32FixedArrayBE;
576
+ function readF32FixedArrayLE(bc, len) {
578
577
  const byteLen = len * 4;
579
- const result = new Float32Array(decodeFixedData(bc, byteLen));
578
+ const result = new Float32Array(readFixedData(bc, byteLen));
580
579
  if (result.some(Number.isNaN)) {
581
580
  throw new BareError(bc.offset, NAN_NOT_ALLOWED2);
582
581
  }
583
582
  return result;
584
583
  }
585
- function decodeF32FixedArrayBE(bc, len) {
584
+ function readF32FixedArrayBE(bc, len) {
586
585
  bc.check(len * 4);
587
586
  const result = new Float32Array(len);
588
587
  for (let i = 0; i < len; i++)
589
- result[i] = decodeF32(bc);
588
+ result[i] = readF32(bc);
590
589
  return result;
591
590
  }
592
- var encodeF32FixedArray = IS_LITTLE_ENDIAN_PLATFORM ? encodeF32FixedArrayLE : encodeF32FixedArrayBE;
593
- function encodeF32FixedArrayLE(bc, x, len) {
594
- (0, import_assert5.ok)(x.length === len);
595
- (0, import_assert5.ok)(!x.every(Number.isNaN), NAN_NOT_ALLOWED2);
596
- bc.write(new Uint8Array(x.buffer, x.byteOffset, x.byteLength));
591
+ var writeF32FixedArray = IS_LITTLE_ENDIAN_PLATFORM ? writeF32FixedArrayLE : writeF32FixedArrayBE;
592
+ function writeF32FixedArrayLE(bc, x) {
593
+ (0, import_assert3.ok)(!x.every(Number.isNaN), NAN_NOT_ALLOWED2);
594
+ writeU8FixedArray(bc, new Uint8Array(x.buffer, x.byteOffset, x.byteLength));
597
595
  }
598
- function encodeF32FixedArrayBE(bc, val, len) {
599
- (0, import_assert5.ok)(val.length === len);
596
+ function writeF32FixedArrayBE(bc, val) {
600
597
  bc.reserve(val.length * 4);
601
598
  for (let i = 0; i < val.length; i++)
602
- encodeF32(bc, val[i]);
599
+ writeF32(bc, val[i]);
603
600
  }
604
- function decodeF32Array(bc) {
605
- return decodeF32FixedArray(bc, decodeUintSafe(bc));
601
+ function readF32Array(bc) {
602
+ return readF32FixedArray(bc, readUintSafe(bc));
606
603
  }
607
- function encodeF32Array(bc, x) {
608
- encodeUintSafe(bc, x.length);
604
+ function writeF32Array(bc, x) {
605
+ writeUintSafe(bc, x.length);
609
606
  if (x.length !== 0) {
610
- encodeF32FixedArray(bc, x, x.length);
607
+ writeF32FixedArray(bc, x);
611
608
  }
612
609
  }
613
- var decodeF64FixedArray = IS_LITTLE_ENDIAN_PLATFORM ? decodeF64FixedArrayLE : decodeF64FixedArrayBE;
614
- function decodeF64FixedArrayLE(bc, len) {
610
+ var readF64FixedArray = IS_LITTLE_ENDIAN_PLATFORM ? readF64FixedArrayLE : readF64FixedArrayBE;
611
+ function readF64FixedArrayLE(bc, len) {
615
612
  const byteLen = len * 8;
616
- const result = new Float64Array(decodeFixedData(bc, byteLen));
613
+ const result = new Float64Array(readFixedData(bc, byteLen));
617
614
  if (result.some(Number.isNaN)) {
618
615
  throw new BareError(bc.offset, NAN_NOT_ALLOWED2);
619
616
  }
620
617
  return result;
621
618
  }
622
- function decodeF64FixedArrayBE(bc, len) {
619
+ function readF64FixedArrayBE(bc, len) {
623
620
  bc.check(len * 8);
624
621
  const result = new Float64Array(len);
625
622
  for (let i = 0; i < len; i++)
626
- result[i] = decodeF64(bc);
623
+ result[i] = readF64(bc);
627
624
  return result;
628
625
  }
629
- var encodeF64FixedArray = IS_LITTLE_ENDIAN_PLATFORM ? encodeF64FixedArrayLE : encodeF64FixedArrayBE;
630
- function encodeF64FixedArrayLE(bc, x, len) {
631
- (0, import_assert5.ok)(x.length === len);
632
- (0, import_assert5.ok)(!x.every(Number.isNaN), NAN_NOT_ALLOWED2);
633
- bc.write(new Uint8Array(x.buffer, x.byteOffset, x.byteLength));
626
+ var writeF64FixedArray = IS_LITTLE_ENDIAN_PLATFORM ? writeF64FixedArrayLE : writeF64FixedArrayBE;
627
+ function writeF64FixedArrayLE(bc, x) {
628
+ (0, import_assert3.ok)(!x.every(Number.isNaN), NAN_NOT_ALLOWED2);
629
+ writeU8FixedArray(bc, new Uint8Array(x.buffer, x.byteOffset, x.byteLength));
634
630
  }
635
- function encodeF64FixedArrayBE(bc, x, len) {
636
- (0, import_assert5.ok)(x.length === len);
631
+ function writeF64FixedArrayBE(bc, x) {
637
632
  bc.reserve(x.length * 8);
638
633
  for (let i = 0; i < x.length; i++)
639
- encodeF64(bc, x[i]);
634
+ writeF64(bc, x[i]);
640
635
  }
641
- function decodeF64Array(bc) {
642
- return decodeF64FixedArray(bc, decodeUintSafe(bc));
636
+ function readF64Array(bc) {
637
+ return readF64FixedArray(bc, readUintSafe(bc));
643
638
  }
644
- function encodeF64Array(bc, x) {
645
- encodeUintSafe(bc, x.length);
639
+ function writeF64Array(bc, x) {
640
+ writeUintSafe(bc, x.length);
646
641
  if (x.length !== 0) {
647
- encodeF64FixedArray(bc, x, x.length);
642
+ writeF64FixedArray(bc, x);
648
643
  }
649
644
  }
650
645
 
651
646
  // src/codec/i16-array.ts
652
- var import_assert6 = require("assert");
653
647
  var I16_BYTE_COUNT = 2;
654
- var decodeI16FixedArray = IS_LITTLE_ENDIAN_PLATFORM ? decodeI16FixedArrayLE : decodeI16FixedArrayBE;
655
- function decodeI16Array(bc) {
656
- return decodeI16FixedArray(bc, decodeUintSafe(bc));
648
+ var readI16FixedArray = IS_LITTLE_ENDIAN_PLATFORM ? readI16FixedArrayLE : readI16FixedArrayBE;
649
+ function readI16Array(bc) {
650
+ return readI16FixedArray(bc, readUintSafe(bc));
657
651
  }
658
- function decodeI16FixedArrayLE(bc, len) {
652
+ function readI16FixedArrayLE(bc, len) {
659
653
  const byteCount = len * I16_BYTE_COUNT;
660
- return new Int16Array(decodeFixedData(bc, byteCount));
654
+ return new Int16Array(readFixedData(bc, byteCount));
661
655
  }
662
- function decodeI16FixedArrayBE(bc, len) {
656
+ function readI16FixedArrayBE(bc, len) {
663
657
  bc.check(len * I16_BYTE_COUNT);
664
658
  const result = new Int16Array(len);
665
659
  for (let i = 0; i < len; i++)
666
- result[i] = decodeI16(bc);
660
+ result[i] = readI16(bc);
667
661
  return result;
668
662
  }
669
- var encodeI16FixedArray = IS_LITTLE_ENDIAN_PLATFORM ? encodeI16FixedArrayLE : encodeI16FixedArrayBE;
670
- function encodeI16Array(bc, x) {
671
- encodeUintSafe(bc, x.length);
663
+ var writeI16FixedArray = IS_LITTLE_ENDIAN_PLATFORM ? writeI16FixedArrayLE : writeI16FixedArrayBE;
664
+ function writeI16Array(bc, x) {
665
+ writeUintSafe(bc, x.length);
672
666
  if (x.length !== 0) {
673
- encodeI16FixedArray(bc, x, x.length);
667
+ writeI16FixedArray(bc, x);
674
668
  }
675
669
  }
676
- function encodeI16FixedArrayLE(bc, x, len) {
677
- (0, import_assert6.ok)(x.length === len);
678
- bc.write(new Uint8Array(x.buffer, x.byteOffset, x.byteLength));
670
+ function writeI16FixedArrayLE(bc, x) {
671
+ writeU8FixedArray(bc, new Uint8Array(x.buffer, x.byteOffset, x.byteLength));
679
672
  }
680
- function encodeI16FixedArrayBE(bc, x, len) {
681
- (0, import_assert6.ok)(x.length === len);
673
+ function writeI16FixedArrayBE(bc, x) {
682
674
  bc.reserve(x.length * I16_BYTE_COUNT);
683
675
  for (let i = 0; i < x.length; i++)
684
- encodeI16(bc, x[i]);
676
+ writeI16(bc, x[i]);
685
677
  }
686
678
 
687
679
  // src/codec/i32-array.ts
688
- var import_assert7 = require("assert");
689
680
  var I32_BYTE_COUNT = 4;
690
- var decodeI32FixedArray = IS_LITTLE_ENDIAN_PLATFORM ? decodeI32FixedArrayLE : decodeI32FixedArrayBE;
691
- function decodeI32Array(bc) {
692
- return decodeI32FixedArray(bc, decodeUintSafe(bc));
681
+ var readI32FixedArray = IS_LITTLE_ENDIAN_PLATFORM ? readI32FixedArrayLE : readI32FixedArrayBE;
682
+ function readI32Array(bc) {
683
+ return readI32FixedArray(bc, readUintSafe(bc));
693
684
  }
694
- function decodeI32FixedArrayLE(bc, len) {
685
+ function readI32FixedArrayLE(bc, len) {
695
686
  const byteCount = len * I32_BYTE_COUNT;
696
- return new Int32Array(decodeFixedData(bc, byteCount));
687
+ return new Int32Array(readFixedData(bc, byteCount));
697
688
  }
698
- function decodeI32FixedArrayBE(bc, len) {
689
+ function readI32FixedArrayBE(bc, len) {
699
690
  bc.check(len * I32_BYTE_COUNT);
700
691
  const result = new Int32Array(len);
701
692
  for (let i = 0; i < len; i++)
702
- result[i] = decodeI32(bc);
693
+ result[i] = readI32(bc);
703
694
  return result;
704
695
  }
705
- var encodeI32FixedArray = IS_LITTLE_ENDIAN_PLATFORM ? encodeI32FixedArrayLE : encodeI32FixedArrayBE;
706
- function encodeI32Array(bc, x) {
707
- encodeUintSafe(bc, x.length);
696
+ var writeI32FixedArray = IS_LITTLE_ENDIAN_PLATFORM ? writeI32FixedArrayLE : writeI32FixedArrayBE;
697
+ function writeI32Array(bc, x) {
698
+ writeUintSafe(bc, x.length);
708
699
  if (x.length !== 0) {
709
- encodeI32FixedArray(bc, x, x.length);
700
+ writeI32FixedArray(bc, x);
710
701
  }
711
702
  }
712
- function encodeI32FixedArrayLE(bc, x, len) {
713
- (0, import_assert7.ok)(x.length === len);
714
- bc.write(new Uint8Array(x.buffer, x.byteOffset, x.byteLength));
703
+ function writeI32FixedArrayLE(bc, x) {
704
+ writeU8FixedArray(bc, new Uint8Array(x.buffer, x.byteOffset, x.byteLength));
715
705
  }
716
- function encodeI32FixedArrayBE(bc, x, len) {
717
- (0, import_assert7.ok)(x.length === len);
706
+ function writeI32FixedArrayBE(bc, x) {
718
707
  bc.reserve(x.length * I32_BYTE_COUNT);
719
708
  for (let i = 0; i < x.length; i++)
720
- encodeI32(bc, x[i]);
709
+ writeI32(bc, x[i]);
721
710
  }
722
711
 
723
712
  // src/codec/i64-array.ts
724
- var import_assert8 = require("assert");
725
713
  var I64_BYTE_COUNT = 8;
726
- var decodeI64FixedArray = IS_LITTLE_ENDIAN_PLATFORM ? decodeI64FixedArrayLE : decodeI64FixedArrayBE;
727
- function decodeI64Array(bc) {
728
- return decodeI64FixedArray(bc, decodeUintSafe(bc));
714
+ var readI64FixedArray = IS_LITTLE_ENDIAN_PLATFORM ? readI64FixedArrayLE : readI64FixedArrayBE;
715
+ function readI64Array(bc) {
716
+ return readI64FixedArray(bc, readUintSafe(bc));
729
717
  }
730
- function decodeI64FixedArrayLE(bc, len) {
718
+ function readI64FixedArrayLE(bc, len) {
731
719
  const byteCount = len * I64_BYTE_COUNT;
732
- return new BigInt64Array(decodeFixedData(bc, byteCount));
720
+ return new BigInt64Array(readFixedData(bc, byteCount));
733
721
  }
734
- function decodeI64FixedArrayBE(bc, len) {
722
+ function readI64FixedArrayBE(bc, len) {
735
723
  bc.check(len * I64_BYTE_COUNT);
736
724
  const result = new BigInt64Array(len);
737
725
  for (let i = 0; i < len; i++)
738
- result[i] = decodeI64(bc);
726
+ result[i] = readI64(bc);
739
727
  return result;
740
728
  }
741
- var encodeI64FixedArray = IS_LITTLE_ENDIAN_PLATFORM ? encodeI64FixedArrayLE : encodeI64FixedArrayBE;
742
- function encodeI64Array(bc, x) {
743
- encodeUintSafe(bc, x.length);
729
+ var writeI64FixedArray = IS_LITTLE_ENDIAN_PLATFORM ? writeI64FixedArrayLE : writeI64FixedArrayBE;
730
+ function writeI64Array(bc, x) {
731
+ writeUintSafe(bc, x.length);
744
732
  if (x.length !== 0) {
745
- encodeI64FixedArray(bc, x, x.length);
733
+ writeI64FixedArray(bc, x);
746
734
  }
747
735
  }
748
- function encodeI64FixedArrayLE(bc, x, len) {
749
- (0, import_assert8.ok)(x.length === len);
750
- bc.write(new Uint8Array(x.buffer, x.byteOffset, x.byteLength));
736
+ function writeI64FixedArrayLE(bc, x) {
737
+ writeU8FixedArray(bc, new Uint8Array(x.buffer, x.byteOffset, x.byteLength));
751
738
  }
752
- function encodeI64FixedArrayBE(bc, x, len) {
753
- (0, import_assert8.ok)(x.length === len);
739
+ function writeI64FixedArrayBE(bc, x) {
754
740
  bc.reserve(x.length * I64_BYTE_COUNT);
755
741
  for (let i = 0; i < x.length; i++)
756
- encodeI64(bc, x[i]);
742
+ writeI64(bc, x[i]);
757
743
  }
758
744
 
759
745
  // src/codec/i8-array.ts
760
- function decodeI8Array(bc) {
761
- return decodeI8FixedArray(bc, decodeUintSafe(bc));
746
+ function readI8Array(bc) {
747
+ return readI8FixedArray(bc, readUintSafe(bc));
762
748
  }
763
- function encodeI8Array(bc, x) {
764
- encodeUintSafe(bc, x.length);
765
- encodeI8FixedArray(bc, x, x.length);
749
+ function writeI8Array(bc, x) {
750
+ writeUintSafe(bc, x.length);
751
+ writeI8FixedArray(bc, x);
766
752
  }
767
- function decodeI8FixedArray(bc, len) {
768
- return new Int8Array(decodeFixedData(bc, len));
753
+ function readI8FixedArray(bc, len) {
754
+ return new Int8Array(readFixedData(bc, len));
769
755
  }
770
- function encodeI8FixedArray(bc, x, len) {
771
- encodeU8FixedArray(bc, new Uint8Array(x.buffer, x.byteOffset, x.byteLength), len);
756
+ function writeI8FixedArray(bc, x) {
757
+ writeU8FixedArray(bc, new Uint8Array(x.buffer, x.byteOffset, x.byteLength));
772
758
  }
773
759
 
774
760
  // src/codec/string.ts
775
- function decodeString(bc) {
776
- const strBytesLen = decodeUintSafe(bc);
777
- const strBytes = bc.read(strBytesLen);
761
+ var INVALID_UTF8_STRING = "invalid UTF-8 string";
762
+ function readString(bc) {
763
+ return readFixedString(bc, readUintSafe(bc));
764
+ }
765
+ function writeString(bc, x) {
766
+ if (x.length < bc.config.textEncoderThreshold) {
767
+ const byteLen = utf8ByteLength(x);
768
+ writeUintSafe(bc, byteLen);
769
+ bc.reserve(byteLen);
770
+ writeUtf8Js(bc, x);
771
+ } else {
772
+ const strBytes = UTF8_ENCODER.encode(x);
773
+ writeUintSafe(bc, strBytes.length);
774
+ writeU8FixedArray(bc, strBytes);
775
+ }
776
+ }
777
+ function readFixedString(bc, byteLen) {
778
+ if (byteLen < bc.config.textDecoderThreshold) {
779
+ return readUtf8Js(bc, byteLen);
780
+ }
778
781
  try {
779
- return strBytesLen < bc.config.textDecoderThreshold ? decodeUtf8Js(strBytes) : UTF8_DECODER.decode(strBytes);
782
+ return UTF8_DECODER.decode(bc.read(byteLen));
780
783
  } catch (cause) {
781
- throw new BareError(bc.offset - strBytesLen, "invalid UTF-8 string", {
782
- cause
783
- });
784
+ throw new BareError(bc.offset, INVALID_UTF8_STRING);
784
785
  }
785
786
  }
786
- function encodeString(bc, x) {
787
+ function writeFixedString(bc, x) {
787
788
  if (x.length < bc.config.textEncoderThreshold) {
788
789
  const byteLen = utf8ByteLength(x);
789
- encodeUintSafe(bc, byteLen);
790
790
  bc.reserve(byteLen);
791
- encodeUtf8Js(bc, x);
791
+ writeUtf8Js(bc, x);
792
792
  } else {
793
- const strBytes = UTF8_ENCODER.encode(x);
794
- encodeUintSafe(bc, strBytes.length);
795
- bc.write(strBytes);
793
+ writeU8FixedArray(bc, UTF8_ENCODER.encode(x));
796
794
  }
797
795
  }
798
- function decodeUtf8Js(bytes) {
799
- const bytesLen = bytes.length;
796
+ function readUtf8Js(bc, byteLen) {
797
+ bc.check(byteLen);
800
798
  let result = "";
801
- let i = 0;
802
- while (i < bytesLen) {
803
- let codePoint = bytes[i++] | 0;
804
- switch (Math.clz32(~codePoint << 24)) {
805
- case 0:
806
- break;
807
- case 2: {
808
- if (i < bytesLen) {
809
- codePoint = (codePoint & 31) << 6 | bytes[i] & 63;
810
- }
811
- if (codePoint >> 7 === 0 || bytes[i] >> 6 !== 2) {
812
- throw TypeError("Decoding failed");
813
- }
814
- i += 1;
815
- break;
816
- }
817
- case 3: {
818
- if (i + 1 < bytesLen) {
819
- codePoint = (codePoint & 15) << 12 | (bytes[i] & 63) << 6 | bytes[i + 1] & 63;
820
- }
821
- if (codePoint >> 11 === 0 || bytes[i] >> 6 !== 2 || bytes[i + 1] >> 6 !== 2 || codePoint >> 11 === 27) {
822
- throw TypeError("Decoding failed");
823
- }
824
- i += 2;
825
- break;
799
+ const bytes = bc.bytes;
800
+ let offset = bc.offset;
801
+ const upperOffset = offset + byteLen;
802
+ while (offset < upperOffset) {
803
+ let codePoint = bytes[offset++];
804
+ if (codePoint > 127) {
805
+ let malformed = true;
806
+ const byte1 = codePoint;
807
+ if (offset < upperOffset && codePoint < 224) {
808
+ const byte2 = bytes[offset++];
809
+ codePoint = (byte1 & 31) << 6 | byte2 & 63;
810
+ malformed = codePoint >> 7 === 0 || byte1 >> 5 !== 6 || byte2 >> 6 !== 2;
811
+ } else if (offset + 1 < upperOffset && codePoint < 240) {
812
+ const byte2 = bytes[offset++];
813
+ const byte3 = bytes[offset++];
814
+ codePoint = (byte1 & 15) << 12 | (byte2 & 63) << 6 | byte3 & 63;
815
+ malformed = codePoint >> 11 === 0 || codePoint >> 11 === 27 || byte1 >> 4 !== 14 || byte2 >> 6 !== 2 || byte3 >> 6 !== 2;
816
+ } else if (offset + 2 < upperOffset) {
817
+ const byte2 = bytes[offset++];
818
+ const byte3 = bytes[offset++];
819
+ const byte4 = bytes[offset++];
820
+ codePoint = (byte1 & 7) << 18 | (byte2 & 63) << 12 | (byte3 & 63) << 6 | byte4 & 63;
821
+ malformed = codePoint >> 16 === 0 || codePoint > 1114111 || byte1 >> 3 !== 30 || byte2 >> 6 !== 2 || byte3 >> 6 !== 2 || byte4 >> 6 !== 2;
826
822
  }
827
- case 4: {
828
- if (i + 2 < bytesLen) {
829
- codePoint = (codePoint & 7) << 18 | (bytes[i] & 63) << 12 | (bytes[i + 1] & 63) << 6 | bytes[i + 2] & 63;
830
- }
831
- if (codePoint >> 16 === 0 || codePoint > 1114111 || bytes[i] >> 6 !== 2 || bytes[i + 1] >> 6 !== 2 || bytes[i + 2] >> 6 !== 2) {
832
- throw TypeError("Decoding failed");
833
- }
834
- i += 3;
835
- break;
823
+ if (malformed) {
824
+ throw new BareError(bc.offset, INVALID_UTF8_STRING);
836
825
  }
837
- default:
838
- throw TypeError("Decoding failed");
839
826
  }
840
827
  result += String.fromCodePoint(codePoint);
841
828
  }
829
+ bc.offset = offset;
842
830
  return result;
843
831
  }
844
- function encodeUtf8Js(bc, s) {
845
- const sLen = s.length;
832
+ function writeUtf8Js(bc, s) {
833
+ const bytes = bc.bytes;
846
834
  let offset = bc.offset;
847
- const view = bc.view;
848
835
  let i = 0;
849
- while (i < sLen) {
836
+ while (i < s.length) {
850
837
  const codePoint = s.codePointAt(i++);
851
838
  if (codePoint < 128) {
852
- view.setUint8(offset++, codePoint);
853
- } else if (codePoint < 2048) {
854
- view.setUint8(offset++, 192 | codePoint >> 6);
855
- view.setUint8(offset++, 128 | codePoint & 63);
856
- } else if (codePoint < 65536) {
857
- view.setUint8(offset++, 224 | codePoint >> 12);
858
- view.setUint8(offset++, 128 | codePoint >> 6 & 63);
859
- view.setUint8(offset++, 128 | codePoint & 63);
839
+ bytes[offset++] = codePoint;
860
840
  } else {
861
- view.setUint8(offset++, 240 | codePoint >> 18);
862
- view.setUint8(offset++, 128 | codePoint >> 12 & 63);
863
- view.setUint8(offset++, 128 | codePoint >> 6 & 63);
864
- view.setUint8(offset++, 128 | codePoint & 63);
865
- i++;
841
+ if (codePoint < 2048) {
842
+ bytes[offset++] = 192 | codePoint >> 6;
843
+ } else {
844
+ if (codePoint < 65536) {
845
+ bytes[offset++] = 224 | codePoint >> 12;
846
+ } else {
847
+ bytes[offset++] = 240 | codePoint >> 18;
848
+ bytes[offset++] = 128 | codePoint >> 12 & 63;
849
+ i++;
850
+ }
851
+ bytes[offset++] = 128 | codePoint >> 6 & 63;
852
+ }
853
+ bytes[offset++] = 128 | codePoint & 63;
866
854
  }
867
855
  }
868
856
  bc.offset = offset;
869
857
  }
870
858
  function utf8ByteLength(s) {
871
- const sLen = s.length;
872
- let result = sLen;
873
- for (let i = 0; i < sLen; i++) {
859
+ let result = s.length;
860
+ for (let i = 0; i < s.length; i++) {
874
861
  const codePoint = s.codePointAt(i);
875
- if (codePoint >= 128) {
862
+ if (codePoint > 127) {
876
863
  result++;
877
- if (codePoint >= 2048) {
864
+ if (codePoint > 2047) {
878
865
  result++;
879
- if (codePoint >= 65536) {
866
+ if (codePoint > 65535) {
880
867
  i++;
881
868
  }
882
869
  }
@@ -888,126 +875,117 @@ var UTF8_DECODER = new TextDecoder("utf-8", { fatal: true });
888
875
  var UTF8_ENCODER = new TextEncoder();
889
876
 
890
877
  // src/codec/u16-array.ts
891
- var import_assert9 = require("assert");
892
878
  var U16_BYTE_COUNT = 2;
893
- var decodeU16FixedArray = IS_LITTLE_ENDIAN_PLATFORM ? decodeU16FixedArrayLE : decodeU16FixedArrayBE;
894
- function decodeU16Array(bc) {
895
- return decodeU16FixedArray(bc, decodeUintSafe(bc));
879
+ var readU16FixedArray = IS_LITTLE_ENDIAN_PLATFORM ? readU16FixedArrayLE : readU16FixedArrayBE;
880
+ function readU16Array(bc) {
881
+ return readU16FixedArray(bc, readUintSafe(bc));
896
882
  }
897
- function decodeU16FixedArrayLE(bc, len) {
883
+ function readU16FixedArrayLE(bc, len) {
898
884
  const byteCount = len * U16_BYTE_COUNT;
899
- return new Uint16Array(decodeFixedData(bc, byteCount));
885
+ return new Uint16Array(readFixedData(bc, byteCount));
900
886
  }
901
- function decodeU16FixedArrayBE(bc, len) {
887
+ function readU16FixedArrayBE(bc, len) {
902
888
  bc.check(len * U16_BYTE_COUNT);
903
889
  const result = new Uint16Array(len);
904
890
  for (let i = 0; i < len; i++)
905
- result[i] = decodeU16(bc);
891
+ result[i] = readU16(bc);
906
892
  return result;
907
893
  }
908
- var encodeU16FixedArray = IS_LITTLE_ENDIAN_PLATFORM ? encodeU16FixedArrayLE : encodeU16FixedArrayBE;
909
- function encodeU16Array(bc, x) {
910
- encodeUintSafe(bc, x.length);
894
+ var writeU16FixedArray = IS_LITTLE_ENDIAN_PLATFORM ? writeU16FixedArrayLE : writeU16FixedArrayBE;
895
+ function writeU16Array(bc, x) {
896
+ writeUintSafe(bc, x.length);
911
897
  if (x.length !== 0) {
912
- encodeU16FixedArray(bc, x, x.length);
898
+ writeU16FixedArray(bc, x);
913
899
  }
914
900
  }
915
- function encodeU16FixedArrayLE(bc, x, len) {
916
- (0, import_assert9.ok)(x.length === len);
917
- bc.write(new Uint8Array(x.buffer, x.byteOffset, x.byteLength));
901
+ function writeU16FixedArrayLE(bc, x) {
902
+ writeU8FixedArray(bc, new Uint8Array(x.buffer, x.byteOffset, x.byteLength));
918
903
  }
919
- function encodeU16FixedArrayBE(bc, x, len) {
920
- (0, import_assert9.ok)(x.length === len);
904
+ function writeU16FixedArrayBE(bc, x) {
921
905
  bc.reserve(x.length * U16_BYTE_COUNT);
922
906
  for (let i = 0; i < x.length; i++)
923
- encodeU16(bc, x[i]);
907
+ writeU16(bc, x[i]);
924
908
  }
925
909
 
926
910
  // src/codec/u32-array.ts
927
- var import_assert10 = require("assert");
928
911
  var U32_BYTE_COUNT = 4;
929
- var decodeU32FixedArray = IS_LITTLE_ENDIAN_PLATFORM ? decodeU32FixedArrayLE : decodeU32FixedArrayBE;
930
- function decodeU32Array(bc) {
931
- return decodeU32FixedArray(bc, decodeUintSafe(bc));
912
+ var readU32FixedArray = IS_LITTLE_ENDIAN_PLATFORM ? readU32FixedArrayLE : readU32FixedArrayBE;
913
+ function readU32Array(bc) {
914
+ return readU32FixedArray(bc, readUintSafe(bc));
932
915
  }
933
- function decodeU32FixedArrayLE(bc, len) {
916
+ function readU32FixedArrayLE(bc, len) {
934
917
  const byteCount = len * U32_BYTE_COUNT;
935
- return new Uint32Array(decodeFixedData(bc, byteCount));
918
+ return new Uint32Array(readFixedData(bc, byteCount));
936
919
  }
937
- function decodeU32FixedArrayBE(bc, len) {
920
+ function readU32FixedArrayBE(bc, len) {
938
921
  bc.check(len * U32_BYTE_COUNT);
939
922
  const result = new Uint32Array(len);
940
923
  for (let i = 0; i < len; i++)
941
- result[i] = decodeU32(bc);
924
+ result[i] = readU32(bc);
942
925
  return result;
943
926
  }
944
- var encodeU32FixedArray = IS_LITTLE_ENDIAN_PLATFORM ? encodeU32FixedArrayLE : encodeU32FixedArrayBE;
945
- function encodeU32Array(bc, x) {
946
- encodeUintSafe(bc, x.length);
927
+ var writeU32FixedArray = IS_LITTLE_ENDIAN_PLATFORM ? writeU32FixedArrayLE : writeU32FixedArrayBE;
928
+ function writeU32Array(bc, x) {
929
+ writeUintSafe(bc, x.length);
947
930
  if (x.length !== 0) {
948
- encodeU32FixedArray(bc, x, x.length);
931
+ writeU32FixedArray(bc, x);
949
932
  }
950
933
  }
951
- function encodeU32FixedArrayLE(bc, x, len) {
952
- (0, import_assert10.ok)(x.length === len);
953
- bc.write(new Uint8Array(x.buffer, x.byteOffset, x.byteLength));
934
+ function writeU32FixedArrayLE(bc, x) {
935
+ writeU8FixedArray(bc, new Uint8Array(x.buffer, x.byteOffset, x.byteLength));
954
936
  }
955
- function encodeU32FixedArrayBE(bc, x, len) {
956
- (0, import_assert10.ok)(x.length === len);
937
+ function writeU32FixedArrayBE(bc, x) {
957
938
  bc.reserve(x.length * U32_BYTE_COUNT);
958
939
  for (let i = 0; i < x.length; i++)
959
- encodeU32(bc, x[i]);
940
+ writeU32(bc, x[i]);
960
941
  }
961
942
 
962
943
  // src/codec/u64-array.ts
963
- var import_assert11 = require("assert");
964
944
  var U64_BYTE_COUNT = 8;
965
- var decodeU64FixedArray = IS_LITTLE_ENDIAN_PLATFORM ? decodeU64FixedArrayLE : decodeU64FixedArrayBE;
966
- function decodeU64Array(bc) {
967
- return decodeU64FixedArray(bc, decodeUintSafe(bc));
945
+ var readU64FixedArray = IS_LITTLE_ENDIAN_PLATFORM ? readU64FixedArrayLE : readU64FixedArrayBE;
946
+ function readU64Array(bc) {
947
+ return readU64FixedArray(bc, readUintSafe(bc));
968
948
  }
969
- function decodeU64FixedArrayLE(bc, len) {
949
+ function readU64FixedArrayLE(bc, len) {
970
950
  const byteCount = len * U64_BYTE_COUNT;
971
- return new BigUint64Array(decodeFixedData(bc, byteCount));
951
+ return new BigUint64Array(readFixedData(bc, byteCount));
972
952
  }
973
- function decodeU64FixedArrayBE(bc, len) {
953
+ function readU64FixedArrayBE(bc, len) {
974
954
  bc.check(len * U64_BYTE_COUNT);
975
955
  const result = new BigUint64Array(len);
976
956
  for (let i = 0; i < len; i++)
977
- result[i] = decodeU64(bc);
957
+ result[i] = readU64(bc);
978
958
  return result;
979
959
  }
980
- var encodeU64FixedArray = IS_LITTLE_ENDIAN_PLATFORM ? encodeU64FixedArrayLE : encodeU64FixedArrayBE;
981
- function encodeU64Array(bc, x) {
982
- encodeUintSafe(bc, x.length);
960
+ var writeU64FixedArray = IS_LITTLE_ENDIAN_PLATFORM ? writeU64FixedArrayLE : writeU64FixedArrayBE;
961
+ function writeU64Array(bc, x) {
962
+ writeUintSafe(bc, x.length);
983
963
  if (x.length !== 0) {
984
- encodeU64FixedArray(bc, x, x.length);
964
+ writeU64FixedArray(bc, x);
985
965
  }
986
966
  }
987
- function encodeU64FixedArrayLE(bc, x, len) {
988
- (0, import_assert11.ok)(x.length === len);
989
- bc.write(new Uint8Array(x.buffer, x.byteOffset, x.byteLength));
967
+ function writeU64FixedArrayLE(bc, x) {
968
+ writeU8FixedArray(bc, new Uint8Array(x.buffer, x.byteOffset, x.byteLength));
990
969
  }
991
- function encodeU64FixedArrayBE(bc, x, len) {
992
- (0, import_assert11.ok)(x.length === len);
970
+ function writeU64FixedArrayBE(bc, x) {
993
971
  bc.reserve(x.length * U64_BYTE_COUNT);
994
972
  for (let i = 0; i < x.length; i++)
995
- encodeU64(bc, x[i]);
973
+ writeU64(bc, x[i]);
996
974
  }
997
975
 
998
976
  // src/codec/u8-clamped-array.ts
999
- function decodeU8ClampedArray(bc) {
1000
- return decodeU8ClampedFixedArray(bc, decodeUintSafe(bc));
977
+ function readU8ClampedArray(bc) {
978
+ return readU8ClampedFixedArray(bc, readUintSafe(bc));
1001
979
  }
1002
- function encodeU8ClampedArray(bc, x) {
1003
- encodeUintSafe(bc, x.length);
1004
- encodeU8ClampedFixedArray(bc, x, x.length);
980
+ function writeU8ClampedArray(bc, x) {
981
+ writeUintSafe(bc, x.length);
982
+ writeU8ClampedFixedArray(bc, x);
1005
983
  }
1006
- function decodeU8ClampedFixedArray(bc, len) {
1007
- return new Uint8ClampedArray(decodeFixedData(bc, len));
984
+ function readU8ClampedFixedArray(bc, len) {
985
+ return new Uint8ClampedArray(readFixedData(bc, len));
1008
986
  }
1009
- function encodeU8ClampedFixedArray(bc, x, len) {
1010
- encodeU8FixedArray(bc, new Uint8Array(x.buffer, x.byteOffset, x.byteLength), len);
987
+ function writeU8ClampedFixedArray(bc, x) {
988
+ writeU8FixedArray(bc, new Uint8Array(x.buffer, x.byteOffset, x.byteLength));
1011
989
  }
1012
990
  module.exports = __toCommonJS(src_exports);
1013
991
  // Annotate the CommonJS export names for ESM import in node:
@@ -1015,90 +993,92 @@ module.exports = __toCommonJS(src_exports);
1015
993
  BareError,
1016
994
  ByteCursor,
1017
995
  Config,
1018
- decodeBool,
1019
- decodeData,
1020
- decodeF32,
1021
- decodeF32Array,
1022
- decodeF32FixedArray,
1023
- decodeF64,
1024
- decodeF64Array,
1025
- decodeF64FixedArray,
1026
- decodeFixedData,
1027
- decodeI16,
1028
- decodeI16Array,
1029
- decodeI16FixedArray,
1030
- decodeI32,
1031
- decodeI32Array,
1032
- decodeI32FixedArray,
1033
- decodeI64,
1034
- decodeI64Array,
1035
- decodeI64FixedArray,
1036
- decodeI64Safe,
1037
- decodeI8,
1038
- decodeI8Array,
1039
- decodeI8FixedArray,
1040
- decodeInt,
1041
- decodeIntSafe,
1042
- decodeString,
1043
- decodeU16,
1044
- decodeU16Array,
1045
- decodeU16FixedArray,
1046
- decodeU32,
1047
- decodeU32Array,
1048
- decodeU32FixedArray,
1049
- decodeU64,
1050
- decodeU64Array,
1051
- decodeU64FixedArray,
1052
- decodeU64Safe,
1053
- decodeU8,
1054
- decodeU8Array,
1055
- decodeU8ClampedArray,
1056
- decodeU8ClampedFixedArray,
1057
- decodeU8FixedArray,
1058
- decodeUint,
1059
- decodeUintSafe,
1060
- decodeVoid,
1061
- encodeBool,
1062
- encodeData,
1063
- encodeF32,
1064
- encodeF32Array,
1065
- encodeF32FixedArray,
1066
- encodeF64,
1067
- encodeF64Array,
1068
- encodeF64FixedArray,
1069
- encodeFixedData,
1070
- encodeI16,
1071
- encodeI16Array,
1072
- encodeI16FixedArray,
1073
- encodeI32,
1074
- encodeI32Array,
1075
- encodeI32FixedArray,
1076
- encodeI64,
1077
- encodeI64Array,
1078
- encodeI64FixedArray,
1079
- encodeI64Safe,
1080
- encodeI8,
1081
- encodeI8Array,
1082
- encodeI8FixedArray,
1083
- encodeInt,
1084
- encodeIntSafe,
1085
- encodeString,
1086
- encodeU16,
1087
- encodeU16Array,
1088
- encodeU16FixedArray,
1089
- encodeU32,
1090
- encodeU32Array,
1091
- encodeU32FixedArray,
1092
- encodeU64,
1093
- encodeU64Array,
1094
- encodeU64FixedArray,
1095
- encodeU64Safe,
1096
- encodeU8,
1097
- encodeU8Array,
1098
- encodeU8ClampedArray,
1099
- encodeU8ClampedFixedArray,
1100
- encodeU8FixedArray,
1101
- encodeUint,
1102
- encodeUintSafe,
1103
- encodeVoid
996
+ readBool,
997
+ readData,
998
+ readF32,
999
+ readF32Array,
1000
+ readF32FixedArray,
1001
+ readF64,
1002
+ readF64Array,
1003
+ readF64FixedArray,
1004
+ readFixedData,
1005
+ readFixedString,
1006
+ readI16,
1007
+ readI16Array,
1008
+ readI16FixedArray,
1009
+ readI32,
1010
+ readI32Array,
1011
+ readI32FixedArray,
1012
+ readI64,
1013
+ readI64Array,
1014
+ readI64FixedArray,
1015
+ readI64Safe,
1016
+ readI8,
1017
+ readI8Array,
1018
+ readI8FixedArray,
1019
+ readInt,
1020
+ readIntSafe,
1021
+ readString,
1022
+ readU16,
1023
+ readU16Array,
1024
+ readU16FixedArray,
1025
+ readU32,
1026
+ readU32Array,
1027
+ readU32FixedArray,
1028
+ readU64,
1029
+ readU64Array,
1030
+ readU64FixedArray,
1031
+ readU64Safe,
1032
+ readU8,
1033
+ readU8Array,
1034
+ readU8ClampedArray,
1035
+ readU8ClampedFixedArray,
1036
+ readU8FixedArray,
1037
+ readUint,
1038
+ readUintSafe,
1039
+ readVoid,
1040
+ writeBool,
1041
+ writeData,
1042
+ writeF32,
1043
+ writeF32Array,
1044
+ writeF32FixedArray,
1045
+ writeF64,
1046
+ writeF64Array,
1047
+ writeF64FixedArray,
1048
+ writeFixedData,
1049
+ writeFixedString,
1050
+ writeI16,
1051
+ writeI16Array,
1052
+ writeI16FixedArray,
1053
+ writeI32,
1054
+ writeI32Array,
1055
+ writeI32FixedArray,
1056
+ writeI64,
1057
+ writeI64Array,
1058
+ writeI64FixedArray,
1059
+ writeI64Safe,
1060
+ writeI8,
1061
+ writeI8Array,
1062
+ writeI8FixedArray,
1063
+ writeInt,
1064
+ writeIntSafe,
1065
+ writeString,
1066
+ writeU16,
1067
+ writeU16Array,
1068
+ writeU16FixedArray,
1069
+ writeU32,
1070
+ writeU32Array,
1071
+ writeU32FixedArray,
1072
+ writeU64,
1073
+ writeU64Array,
1074
+ writeU64FixedArray,
1075
+ writeU64Safe,
1076
+ writeU8,
1077
+ writeU8Array,
1078
+ writeU8ClampedArray,
1079
+ writeU8ClampedFixedArray,
1080
+ writeU8FixedArray,
1081
+ writeUint,
1082
+ writeUintSafe,
1083
+ writeVoid
1104
1084
  });