bin-serde 1.1.1 → 1.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/lib/index.js +5 -10
- package/package.json +2 -1
- package/tsconfig.json +2 -1
package/lib/index.js
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.Reader = exports.Writer = void 0;
|
|
4
|
-
const utf8 = require("utf8-buffer");
|
|
5
|
-
const utf8_buffer_size_1 = require("utf8-buffer-size");
|
|
1
|
+
import * as utf8 from "utf8-buffer";
|
|
2
|
+
import utf8Size from "utf8-buffer-size";
|
|
6
3
|
const { pack, unpack } = utf8.default ?? utf8;
|
|
7
|
-
class Writer {
|
|
4
|
+
export class Writer {
|
|
8
5
|
pos = 0;
|
|
9
6
|
view;
|
|
10
7
|
bytes;
|
|
@@ -96,7 +93,7 @@ class Writer {
|
|
|
96
93
|
}
|
|
97
94
|
writeString(val) {
|
|
98
95
|
if (val.length > 0) {
|
|
99
|
-
const byteSize = (
|
|
96
|
+
const byteSize = utf8Size(val);
|
|
100
97
|
this.writeUVarint(byteSize);
|
|
101
98
|
this.ensureSize(byteSize);
|
|
102
99
|
pack(val, this.bytes, this.pos);
|
|
@@ -126,8 +123,7 @@ class Writer {
|
|
|
126
123
|
}
|
|
127
124
|
}
|
|
128
125
|
}
|
|
129
|
-
|
|
130
|
-
class Reader {
|
|
126
|
+
export class Reader {
|
|
131
127
|
pos = 0;
|
|
132
128
|
view;
|
|
133
129
|
bytes;
|
|
@@ -199,4 +195,3 @@ class Reader {
|
|
|
199
195
|
return this.view.byteLength - this.pos;
|
|
200
196
|
}
|
|
201
197
|
}
|
|
202
|
-
exports.Reader = Reader;
|
package/package.json
CHANGED