bin-serde 1.7.1 → 1.7.3

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
@@ -157,6 +157,13 @@ export class Writer {
157
157
  return this.bytes.subarray(0, this.pos);
158
158
  }
159
159
 
160
+ reset(): this {
161
+ this.pos = 0;
162
+ this.bytes = allocFromSlab(this.bytes.length);
163
+ this._view = null;
164
+ return this;
165
+ }
166
+
160
167
  get size(): number {
161
168
  return this.pos;
162
169
  }
package/lib/index.d.ts CHANGED
@@ -15,6 +15,7 @@ export declare class Writer {
15
15
  writeBuffer(buf: Uint8Array): this;
16
16
  concat(other: Writer): this;
17
17
  toBuffer(): Uint8Array<ArrayBufferLike>;
18
+ reset(): this;
18
19
  get size(): number;
19
20
  private ensureSize;
20
21
  private get view();
package/lib/index.js CHANGED
@@ -138,6 +138,12 @@ export class Writer {
138
138
  toBuffer() {
139
139
  return this.bytes.subarray(0, this.pos);
140
140
  }
141
+ reset() {
142
+ this.pos = 0;
143
+ this.bytes = allocFromSlab(this.bytes.length);
144
+ this._view = null;
145
+ return this;
146
+ }
141
147
  get size() {
142
148
  return this.pos;
143
149
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bin-serde",
3
- "version": "1.7.1",
3
+ "version": "1.7.3",
4
4
  "description": "A low level library for efficiently writing and reading binary data in javascript",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",