@flighthq/buffer 0.5.1-next.3308.79ae053 → 0.5.1-next.4304.322dc96

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/README.md CHANGED
@@ -13,5 +13,5 @@ Import the supported application-facing API from `@flighthq/buffer`. The `@fligh
13
13
  This package is part of the locked-version Flight SDK graph. Applications may instead install and import `@flighthq/sdk` when package-level tree shaking is sufficient.
14
14
 
15
15
  - [Flight project](https://github.com/flighthq/flight)
16
- - [Source for @flighthq/buffer@0.5.1-next.3308.79ae053](https://github.com/flighthq/flight/tree/79ae05332d95f01cdbd3492cf912bbd3b8f9658a/packages/buffer)
17
- - [License](https://github.com/flighthq/flight/blob/79ae05332d95f01cdbd3492cf912bbd3b8f9658a/LICENSE.md)
16
+ - [Source for @flighthq/buffer@0.5.1-next.4304.322dc96](https://github.com/flighthq/flight/tree/322dc963fc5a404a31bc0cc612e906de504ea024/packages/buffer)
17
+ - [License](https://github.com/flighthq/flight/blob/322dc963fc5a404a31bc0cc612e906de504ea024/LICENSE.md)
@@ -1,5 +1,12 @@
1
- export type { ByteReader } from '@flighthq/types/contract';
2
- import type { ByteReader, NonEntityCreateResult } from '@flighthq/types/contract';
1
+ import type { NonEntityCreateResult } from '@flighthq/entity/contract';
2
+ /**
3
+ * A forward-only little/big-endian cursor over a byte view (TS `ByteReader`), shared by the
4
+ * binary format parsers.
5
+ */
6
+ export interface ByteReader {
7
+ view: Readonly<Uint8Array>;
8
+ offset: number;
9
+ }
3
10
  export declare function createByteReader(bytes: Readonly<Uint8Array>, offset?: number): NonEntityCreateResult<ByteReader, 'descriptor'>;
4
11
  export declare function hasByteReaderBytes(reader: Readonly<ByteReader>, count: number): boolean;
5
12
  export declare function readByteReaderU16(reader: ByteReader): number;
@@ -1 +1 @@
1
- {"version":3,"file":"byteReader.d.ts","sourceRoot":"","sources":["../src/byteReader.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,UAAU,EAAE,MAAM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ACd,qBAAqB,CAAC,UAAU,EAAE,YAAY,CAAC,CAEjD;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,QAAQ,CAAC,UAAU,CAAC,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAEvF;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CAK5D;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CAM5D;AAED,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CAMrE;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CAK5D;AAYD,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CASrE;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CAO5D;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CAI3D;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAEtE"}
@@ -1,46 +1,61 @@
1
- export function createByteReader(bytes, offset = 0) {
2
- return { view: new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength), offset };
1
+ // Generated from crates/flight-buffer/src/byte_reader.rs by flight-compiler.
2
+ // Rust is authoritative; run `npm run generate` after changing it.
3
+ export function createByteReader(bytes, offset) {
4
+ return { view: bytes, offset: offset ?? 0 };
3
5
  }
4
6
  export function hasByteReaderBytes(reader, count) {
5
- return count >= 0 && reader.offset + count <= reader.view.byteLength;
7
+ return reader.offset <= reader.view.length && count <= reader.view.length - reader.offset;
6
8
  }
7
9
  export function readByteReaderU16(reader) {
8
- const value = reader.view.getUint16(reader.offset, true);
10
+ const offset = reader.offset;
11
+ const value = (reader.view[offset] & 0xffff) | ((reader.view[offset + 1] & 0xffff) << 8);
9
12
  reader.offset += 2;
10
13
  return value;
11
14
  }
12
15
  export function readByteReaderU24(reader) {
13
- const view = reader.view;
14
16
  const offset = reader.offset;
15
- const value = view.getUint8(offset) | (view.getUint8(offset + 1) << 8) | (view.getUint8(offset + 2) << 16);
17
+ const value = (reader.view[offset] >>> 0) | ((reader.view[offset + 1] >>> 0) << 8) | ((reader.view[offset + 2] >>> 0) << 16);
16
18
  reader.offset += 3;
17
- return value;
19
+ return value >>> 0;
18
20
  }
19
21
  export function readByteReaderU24BigEndian(reader) {
20
- const view = reader.view;
21
22
  const offset = reader.offset;
22
- const value = (view.getUint8(offset) << 16) | (view.getUint8(offset + 1) << 8) | view.getUint8(offset + 2);
23
+ const value = ((reader.view[offset] >>> 0) << 16) | ((reader.view[offset + 1] >>> 0) << 8) | (reader.view[offset + 2] >>> 0);
23
24
  reader.offset += 3;
24
- return value;
25
+ return value >>> 0;
25
26
  }
26
27
  export function readByteReaderU32(reader) {
27
- const value = reader.view.getUint32(reader.offset, true);
28
+ const offset = reader.offset;
29
+ const value = readByteReaderU32At(reader.view, offset);
28
30
  reader.offset += 4;
29
- return value;
31
+ return value >>> 0;
32
+ }
33
+ function readByteReaderU32At(view, offset) {
34
+ return (((view[offset] >>> 0) |
35
+ ((view[offset + 1] >>> 0) << 8) |
36
+ ((view[offset + 2] >>> 0) << 16) |
37
+ ((view[offset + 3] >>> 0) << 24)) >>>
38
+ 0);
30
39
  }
31
40
  export function readByteReaderU32BigEndian(reader) {
32
- const value = reader.view.getUint32(reader.offset, false);
41
+ const offset = reader.offset;
42
+ const value = ((reader.view[offset] >>> 0) << 24) |
43
+ ((reader.view[offset + 1] >>> 0) << 16) |
44
+ ((reader.view[offset + 2] >>> 0) << 8) |
45
+ (reader.view[offset + 3] >>> 0);
33
46
  reader.offset += 4;
34
- return value;
47
+ return value >>> 0;
35
48
  }
36
49
  export function readByteReaderU64(reader) {
37
- const low = reader.view.getUint32(reader.offset, true);
38
- const high = reader.view.getUint32(reader.offset + 4, true);
50
+ const offset = reader.offset;
51
+ const low = readByteReaderU32At(reader.view, offset);
52
+ const high = readByteReaderU32At(reader.view, offset + 4);
53
+ const value = high * 0x1_0000_0000 + low;
39
54
  reader.offset += 8;
40
- return high * 0x1_0000_0000 + low;
55
+ return value;
41
56
  }
42
57
  export function readByteReaderU8(reader) {
43
- const value = reader.view.getUint8(reader.offset);
58
+ const value = reader.view[reader.offset];
44
59
  reader.offset += 1;
45
60
  return value;
46
61
  }
@@ -1 +1 @@
1
- {"version":3,"file":"byteReader.js","sourceRoot":"","sources":["../src/byteReader.ts"],"names":[],"mappings":"AAIA,MAAM,UAAU,gBAAgB,CAC9B,KAA2B,EAC3B,MAAM,GAAG,CAAC;IAEV,OAAO,EAAE,IAAI,EAAE,IAAI,QAAQ,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;AAC1F,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,MAA4B,EAAE,KAAa;IAC5E,OAAO,KAAK,IAAI,CAAC,IAAI,MAAM,CAAC,MAAM,GAAG,KAAK,IAAI,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC;AACvE,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,MAAkB;IAClD,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IACzD,MAAM,CAAC,MAAM,IAAI,CAAC,CAAC;IACnB,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,MAAkB;IAClD,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC;IACzB,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;IAC7B,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,GAA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BAAmB,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,CAAC,CAAC,CAAC;IAC1D,MAAM,KAAK,GAAG,IAAI,GAAG,aAAa,GAAG,GAAG,CAAC;IACzC,MAAM,CAAC,MAAM,IAAI,CAAC,CAAC;IACnB,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,MAAkB;IACjD,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACzC,MAAM,CAAC,MAAM,IAAI,CAAC,CAAC;IACnB,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,MAAkB,EAAE,KAAa;IAC9D,MAAM,CAAC,MAAM,IAAI,KAAK,CAAC;AACzB,CAAC"}
@@ -1,2 +1,3 @@
1
- export * from './byteReader.ts';
1
+ export { createByteReader, hasByteReaderBytes, readByteReaderU16, readByteReaderU24, readByteReaderU24BigEndian, readByteReaderU32, readByteReaderU32BigEndian, readByteReaderU64, readByteReaderU8, skipByteReader, } from './byteReader.ts';
2
+ export type { ByteReader } from './byteReader.ts';
2
3
  //# sourceMappingURL=contract.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../src/contract.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC"}
1
+ {"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../src/contract.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,EACjB,0BAA0B,EAC1B,iBAAiB,EACjB,0BAA0B,EAC1B,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,GACf,MAAM,iBAAiB,CAAC;AACzB,YAAY,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC"}
package/dist/contract.js CHANGED
@@ -1,2 +1,4 @@
1
- export * from "./byteReader.js";
1
+ // Generated from crates/flight-buffer/src/lib.rs by flight-compiler.
2
+ // Rust is authoritative; run `npm run generate` after changing it.
3
+ export { createByteReader, hasByteReaderBytes, readByteReaderU16, readByteReaderU24, readByteReaderU24BigEndian, readByteReaderU32, readByteReaderU32BigEndian, readByteReaderU64, readByteReaderU8, skipByteReader, } from "./byteReader.js";
2
4
  //# sourceMappingURL=contract.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"contract.js","sourceRoot":"","sources":["../src/contract.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC"}
1
+ {"version":3,"file":"contract.js","sourceRoot":"","sources":["../src/contract.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,mEAAmE;AAEnE,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,EACjB,0BAA0B,EAC1B,iBAAiB,EACjB,0BAA0B,EAC1B,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,GACf,MAAM,iBAAiB,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
- export * from './byteReader.ts';
1
+ export { createByteReader, hasByteReaderBytes, readByteReaderU16, readByteReaderU24, readByteReaderU24BigEndian, readByteReaderU32, readByteReaderU32BigEndian, readByteReaderU64, readByteReaderU8, skipByteReader, } from './contract.ts';
2
+ export type { ByteReader } from './contract.ts';
2
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,EACjB,0BAA0B,EAC1B,iBAAiB,EACjB,0BAA0B,EAC1B,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,GACf,MAAM,eAAe,CAAC;AAEvB,YAAY,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC"}
package/dist/index.js CHANGED
@@ -1,2 +1,4 @@
1
- export * from "./byteReader.js";
1
+ // Generated from crates/flight-buffer/src/lib.rs by flight-compiler.
2
+ // Rust is authoritative; run `npm run generate` after changing it.
3
+ export { createByteReader, hasByteReaderBytes, readByteReaderU16, readByteReaderU24, readByteReaderU24BigEndian, readByteReaderU32, readByteReaderU32BigEndian, readByteReaderU64, readByteReaderU8, skipByteReader, } from "./contract.js";
2
4
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,mEAAmE;AAEnE,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,EACjB,0BAA0B,EAC1B,iBAAiB,EACjB,0BAA0B,EAC1B,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,GACf,MAAM,eAAe,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flighthq/buffer",
3
- "version": "0.5.1-next.3308.79ae053",
3
+ "version": "0.5.1-next.4304.322dc96",
4
4
  "author": "Joshua Granick and other contributors",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -32,13 +32,15 @@
32
32
  "scripts": {
33
33
  "build": "tsc -b",
34
34
  "clean": "tsc -b --clean",
35
+ "generate": "tsx ../../scripts/generate-rust-package.ts --crate flight-buffer --package buffer",
36
+ "generate:check": "tsx ../../scripts/generate-rust-package.ts --crate flight-buffer --package buffer --check",
35
37
  "test": "vitest run --config vitest.config.ts",
36
38
  "test:watch": "vitest --watch --config vitest.config.ts",
37
39
  "prepack": "npm run clean && npm run clean:dist && npm run build",
38
40
  "clean:dist": "tsx ../../scripts/clean-package-dist.ts"
39
41
  },
40
42
  "dependencies": {
41
- "@flighthq/types": "0.5.1-next.3308.79ae053"
43
+ "@flighthq/entity": "0.5.1-next.4304.322dc96"
42
44
  },
43
45
  "devDependencies": {
44
46
  "typescript": "^5.3.0"
@@ -1,3 +1,8 @@
1
+ // Generated from crates/flight-buffer/tests/byte_reader_test.rs by flight-compiler.
2
+ // Rust is authoritative; run `npm run generate` after changing it.
3
+
4
+ import { describe, expect, it } from 'vitest';
5
+
1
6
  import {
2
7
  createByteReader,
3
8
  hasByteReaderBytes,
@@ -9,109 +14,121 @@ import {
9
14
  readByteReaderU64,
10
15
  readByteReaderU8,
11
16
  skipByteReader,
12
- } from './byteReader.ts';
17
+ } from './contract.ts';
13
18
 
14
19
  describe('createByteReader', () => {
15
20
  it('starts at the given offset', () => {
16
- const reader = createByteReader(new Uint8Array([1, 2, 3, 4]), 2);
17
- expect(reader.offset).toBe(2);
18
- expect(readByteReaderU8(reader)).toBe(3);
21
+ const bytes: Uint8Array = new Uint8Array([1, 2, 3, 4]);
22
+ let reader = createByteReader(bytes, 2);
23
+ expect(reader.offset).toEqual(2);
24
+ expect(readByteReaderU8(reader)).toEqual(3);
19
25
  });
20
-
21
- it('views a subarray by its byteOffset', () => {
22
- const backing = new Uint8Array([9, 9, 0x01, 0x00]);
23
- const reader = createByteReader(backing.subarray(2));
24
- expect(readByteReaderU16(reader)).toBe(1);
26
+ it('views a subslice at its own start', () => {
27
+ const backing: Uint8Array = new Uint8Array([9, 9, 0x01, 0x00]);
28
+ let reader = createByteReader(backing.slice(2), undefined);
29
+ expect(readByteReaderU16(reader)).toEqual(1);
25
30
  });
26
31
  });
27
32
 
28
33
  describe('hasByteReaderBytes', () => {
34
+ // Rust-only: rejects a count that would overflow native pointer arithmetic
29
35
  it('reports whether count bytes remain from the current offset', () => {
30
- const reader = createByteReader(new Uint8Array(8), 4);
36
+ const bytes = new Uint8Array(8).fill(0);
37
+ const reader = createByteReader(bytes, 4);
31
38
  expect(hasByteReaderBytes(reader, 4)).toBe(true);
32
- expect(hasByteReaderBytes(reader, 5)).toBe(false);
39
+ expect(!hasByteReaderBytes(reader, 5)).toBe(true);
33
40
  expect(hasByteReaderBytes(reader, 0)).toBe(true);
34
41
  });
35
42
  });
36
43
 
37
44
  describe('readByteReaderU16', () => {
38
- it('reads little-endian and advances 2', () => {
39
- const reader = createByteReader(new Uint8Array([0x34, 0x12]));
40
- expect(readByteReaderU16(reader)).toBe(0x1234);
41
- expect(reader.offset).toBe(2);
45
+ it('reads little endian and advances two', () => {
46
+ const bytes: Uint8Array = new Uint8Array([0x34, 0x12]);
47
+ let reader = createByteReader(bytes, undefined);
48
+ expect(readByteReaderU16(reader)).toEqual(0x1234);
49
+ expect(reader.offset).toEqual(2);
42
50
  });
43
51
  });
44
52
 
45
53
  describe('readByteReaderU24', () => {
46
- it('reads a 3-byte little-endian value and advances 3', () => {
47
- const reader = createByteReader(new Uint8Array([0x56, 0x34, 0x12]));
48
- expect(readByteReaderU24(reader)).toBe(0x123456);
49
- expect(reader.offset).toBe(3);
54
+ it('reads a three byte little endian value and advances three', () => {
55
+ const bytes: Uint8Array = new Uint8Array([0x56, 0x34, 0x12]);
56
+ let reader = createByteReader(bytes, undefined);
57
+ expect(readByteReaderU24(reader)).toEqual(0x123456);
58
+ expect(reader.offset).toEqual(3);
50
59
  });
51
-
52
- it('reads the full 24-bit range without sign issues', () => {
53
- const reader = createByteReader(new Uint8Array([0xff, 0xff, 0xff]));
54
- expect(readByteReaderU24(reader)).toBe(0xffffff);
60
+ it('reads the full unsigned range', () => {
61
+ const bytes: Uint8Array = new Uint8Array([0xff, 0xff, 0xff]);
62
+ let reader = createByteReader(bytes, undefined);
63
+ expect(readByteReaderU24(reader)).toEqual(0xff_ffff);
55
64
  });
56
65
  });
57
66
 
58
67
  describe('readByteReaderU24BigEndian', () => {
59
- it('reads a 3-byte big-endian value and advances 3', () => {
60
- const reader = createByteReader(new Uint8Array([0x12, 0x34, 0x56]));
61
- expect(readByteReaderU24BigEndian(reader)).toBe(0x123456);
62
- expect(reader.offset).toBe(3);
68
+ it('reads a three byte big endian value and advances three', () => {
69
+ const bytes: Uint8Array = new Uint8Array([0x12, 0x34, 0x56]);
70
+ let reader = createByteReader(bytes, undefined);
71
+ expect(readByteReaderU24BigEndian(reader)).toEqual(0x123456);
72
+ expect(reader.offset).toEqual(3);
63
73
  });
64
-
65
- it('reads the full 24-bit range without sign issues', () => {
66
- const reader = createByteReader(new Uint8Array([0xff, 0xff, 0xff]));
67
- expect(readByteReaderU24BigEndian(reader)).toBe(0xffffff);
74
+ it('reads the full unsigned range', () => {
75
+ const bytes: Uint8Array = new Uint8Array([0xff, 0xff, 0xff]);
76
+ let reader = createByteReader(bytes, undefined);
77
+ expect(readByteReaderU24BigEndian(reader)).toEqual(0xff_ffff);
68
78
  });
69
79
  });
70
80
 
71
81
  describe('readByteReaderU32', () => {
72
- it('reads little-endian and advances 4', () => {
73
- const reader = createByteReader(new Uint8Array([0x78, 0x56, 0x34, 0x12]));
74
- expect(readByteReaderU32(reader)).toBe(0x12345678);
75
- expect(reader.offset).toBe(4);
82
+ it('reads little endian and advances four', () => {
83
+ const bytes: Uint8Array = new Uint8Array([0x78, 0x56, 0x34, 0x12]);
84
+ let reader = createByteReader(bytes, undefined);
85
+ expect(readByteReaderU32(reader)).toEqual(0x1234_5678);
86
+ expect(reader.offset).toEqual(4);
76
87
  });
77
88
  });
78
89
 
79
90
  describe('readByteReaderU32BigEndian', () => {
80
- it('reads a 4-byte big-endian value and advances 4', () => {
81
- const reader = createByteReader(new Uint8Array([0x12, 0x34, 0x56, 0x78]));
82
- expect(readByteReaderU32BigEndian(reader)).toBe(0x12345678);
83
- expect(reader.offset).toBe(4);
91
+ it('reads big endian and advances four', () => {
92
+ const bytes: Uint8Array = new Uint8Array([0x12, 0x34, 0x56, 0x78]);
93
+ let reader = createByteReader(bytes, undefined);
94
+ expect(readByteReaderU32BigEndian(reader)).toEqual(0x1234_5678);
95
+ expect(reader.offset).toEqual(4);
84
96
  });
85
-
86
- it('reads the full 32-bit range as an unsigned value', () => {
87
- const reader = createByteReader(new Uint8Array([0xff, 0xff, 0xff, 0xff]));
88
- expect(readByteReaderU32BigEndian(reader)).toBe(0xffffffff);
97
+ it('reads the full unsigned range', () => {
98
+ const bytes: Uint8Array = new Uint8Array([0xff, 0xff, 0xff, 0xff]);
99
+ let reader = createByteReader(bytes, undefined);
100
+ expect(readByteReaderU32BigEndian(reader)).toEqual(0xffffffff);
89
101
  });
90
102
  });
91
103
 
92
104
  describe('readByteReaderU64', () => {
93
- it('reads little-endian as a number and advances 8', () => {
94
- const bytes = new Uint8Array(8);
95
- new DataView(bytes.buffer).setUint32(0, 0x1000, true);
96
- new DataView(bytes.buffer).setUint32(4, 0x2, true);
97
- const reader = createByteReader(bytes);
98
- expect(readByteReaderU64(reader)).toBe(0x2 * 0x1_0000_0000 + 0x1000);
99
- expect(reader.offset).toBe(8);
105
+ it('reads little endian exactly and advances eight', () => {
106
+ const bytes: Uint8Array = new Uint8Array([0, 0x10, 0, 0, 2, 0, 0, 0]);
107
+ let reader = createByteReader(bytes, undefined);
108
+ expect(readByteReaderU64(reader)).toEqual(2 * 0x1_0000_0000 + 0x1000);
109
+ expect(reader.offset).toEqual(8);
110
+ });
111
+ it('reads the low word as unsigned when combining the result', () => {
112
+ const bytes: Uint8Array = new Uint8Array([0xff, 0xff, 0xff, 0xff, 2, 0, 0, 0]);
113
+ let reader = createByteReader(bytes, undefined);
114
+ expect(readByteReaderU64(reader)).toEqual(3 * 0x1_0000_0000 - 1);
100
115
  });
101
116
  });
102
117
 
103
118
  describe('readByteReaderU8', () => {
104
- it('reads one byte and advances 1', () => {
105
- const reader = createByteReader(new Uint8Array([0xab]));
106
- expect(readByteReaderU8(reader)).toBe(0xab);
107
- expect(reader.offset).toBe(1);
119
+ it('reads one byte and advances one', () => {
120
+ const bytes: Uint8Array = new Uint8Array([0xab]);
121
+ let reader = createByteReader(bytes, undefined);
122
+ expect(readByteReaderU8(reader)).toEqual(0xab);
123
+ expect(reader.offset).toEqual(1);
108
124
  });
109
125
  });
110
126
 
111
127
  describe('skipByteReader', () => {
112
128
  it('advances the offset without reading', () => {
113
- const reader = createByteReader(new Uint8Array(8));
129
+ const bytes = new Uint8Array(8).fill(0);
130
+ let reader = createByteReader(bytes, undefined);
114
131
  skipByteReader(reader, 3);
115
- expect(reader.offset).toBe(3);
132
+ expect(reader.offset).toEqual(3);
116
133
  });
117
134
  });