bin-serde 1.1.0 → 1.1.1

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/index.ts CHANGED
@@ -4,8 +4,13 @@ const { pack, unpack } = (utf8 as any).default ?? utf8;
4
4
 
5
5
  export class Writer {
6
6
  private pos = 0;
7
- private view = new DataView(new ArrayBuffer(64));
8
- private bytes = new Uint8Array(this.view.buffer);
7
+ private view: DataView;
8
+ private bytes: Uint8Array;
9
+
10
+ public constructor() {
11
+ this.view = new DataView(new ArrayBuffer(64));
12
+ this.bytes = new Uint8Array(this.view.buffer);
13
+ }
9
14
 
10
15
  public writeUInt8(val: number) {
11
16
  this.ensureSize(1);
package/lib/index.d.ts CHANGED
@@ -2,6 +2,7 @@ export declare class Writer {
2
2
  private pos;
3
3
  private view;
4
4
  private bytes;
5
+ constructor();
5
6
  writeUInt8(val: number): this;
6
7
  writeUInt32(val: number): this;
7
8
  writeUInt64(val: bigint): this;
package/lib/index.js CHANGED
@@ -6,8 +6,12 @@ const utf8_buffer_size_1 = require("utf8-buffer-size");
6
6
  const { pack, unpack } = utf8.default ?? utf8;
7
7
  class Writer {
8
8
  pos = 0;
9
- view = new DataView(new ArrayBuffer(64));
10
- bytes = new Uint8Array(this.view.buffer);
9
+ view;
10
+ bytes;
11
+ constructor() {
12
+ this.view = new DataView(new ArrayBuffer(64));
13
+ this.bytes = new Uint8Array(this.view.buffer);
14
+ }
11
15
  writeUInt8(val) {
12
16
  this.ensureSize(1);
13
17
  this.view.setUint8(this.pos, val);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bin-serde",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "description": "A low level library for efficiently writing and reading binary data in javascript",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",