@blue-quickjs/dv 0.2.2 → 0.2.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/dist/lib/dv.js +13 -1
- package/package.json +1 -1
package/dist/lib/dv.js
CHANGED
|
@@ -122,12 +122,24 @@ class ByteBuilder {
|
|
|
122
122
|
function dvError(code, message) {
|
|
123
123
|
return new DvError(code, message);
|
|
124
124
|
}
|
|
125
|
+
function describeUnsupportedType(value) {
|
|
126
|
+
if (value === undefined) {
|
|
127
|
+
return 'undefined';
|
|
128
|
+
}
|
|
129
|
+
if (value === null) {
|
|
130
|
+
return 'null';
|
|
131
|
+
}
|
|
132
|
+
if (Array.isArray(value)) {
|
|
133
|
+
return 'array';
|
|
134
|
+
}
|
|
135
|
+
return typeof value;
|
|
136
|
+
}
|
|
125
137
|
function encodeValue(value, builder, limits, depth) {
|
|
126
138
|
if (value === null) {
|
|
127
139
|
builder.pushByte(0xf6);
|
|
128
140
|
return;
|
|
129
141
|
}
|
|
130
|
-
const type =
|
|
142
|
+
const type = describeUnsupportedType(value);
|
|
131
143
|
if (type === 'boolean') {
|
|
132
144
|
builder.pushByte(value ? 0xf5 : 0xf4);
|
|
133
145
|
return;
|