bin-serde 1.7.3 → 1.7.4
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 +4 -4
- package/lib/index.d.ts +1 -1
- package/lib/index.js +3 -3
- package/package.json +1 -1
package/index.ts
CHANGED
|
@@ -154,13 +154,13 @@ export class Writer {
|
|
|
154
154
|
}
|
|
155
155
|
|
|
156
156
|
toBuffer() {
|
|
157
|
-
return
|
|
157
|
+
return typeof Buffer !== "undefined"
|
|
158
|
+
? Buffer.from(this.bytes.buffer, this.bytes.byteOffset, this.pos)
|
|
159
|
+
: this.bytes.slice(0, this.pos);
|
|
158
160
|
}
|
|
159
161
|
|
|
160
|
-
reset()
|
|
162
|
+
reset() {
|
|
161
163
|
this.pos = 0;
|
|
162
|
-
this.bytes = allocFromSlab(this.bytes.length);
|
|
163
|
-
this._view = null;
|
|
164
164
|
return this;
|
|
165
165
|
}
|
|
166
166
|
|
package/lib/index.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ export declare class Writer {
|
|
|
14
14
|
writeStringUtf8(val: string, len?: number): this;
|
|
15
15
|
writeBuffer(buf: Uint8Array): this;
|
|
16
16
|
concat(other: Writer): this;
|
|
17
|
-
toBuffer(): Uint8Array<ArrayBufferLike>;
|
|
17
|
+
toBuffer(): Uint8Array<ArrayBuffer> | Buffer<ArrayBufferLike>;
|
|
18
18
|
reset(): this;
|
|
19
19
|
get size(): number;
|
|
20
20
|
private ensureSize;
|
package/lib/index.js
CHANGED
|
@@ -136,12 +136,12 @@ export class Writer {
|
|
|
136
136
|
return this;
|
|
137
137
|
}
|
|
138
138
|
toBuffer() {
|
|
139
|
-
return
|
|
139
|
+
return typeof Buffer !== "undefined"
|
|
140
|
+
? Buffer.from(this.bytes.buffer, this.bytes.byteOffset, this.pos)
|
|
141
|
+
: this.bytes.slice(0, this.pos);
|
|
140
142
|
}
|
|
141
143
|
reset() {
|
|
142
144
|
this.pos = 0;
|
|
143
|
-
this.bytes = allocFromSlab(this.bytes.length);
|
|
144
|
-
this._view = null;
|
|
145
145
|
return this;
|
|
146
146
|
}
|
|
147
147
|
get size() {
|