mol_vary 0.0.27 → 0.0.29
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/README.md +2 -2
- package/node.d.ts +15 -6
- package/node.d.ts.map +1 -1
- package/node.deps.json +1 -1
- package/node.js +130 -64
- package/node.js.map +1 -1
- package/node.mjs +130 -64
- package/node.test.js +332 -160
- package/node.test.js.map +1 -1
- package/package.json +4 -1
- package/web.d.ts +15 -6
- package/web.d.ts.map +1 -1
- package/web.deps.json +1 -1
- package/web.js +130 -64
- package/web.js.map +1 -1
- package/web.mjs +130 -64
- package/web.test.js +202 -96
- package/web.test.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mol_vary",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.29",
|
|
4
4
|
"exports": {
|
|
5
5
|
"node": {
|
|
6
6
|
"import": "./node.mjs",
|
|
@@ -17,9 +17,12 @@
|
|
|
17
17
|
"keywords": [
|
|
18
18
|
"$mol_vary",
|
|
19
19
|
"$mol",
|
|
20
|
+
"$mol_bigint_encode",
|
|
21
|
+
"$mol_bigint",
|
|
20
22
|
"$mol_fail",
|
|
21
23
|
"$mol_charset_encode",
|
|
22
24
|
"$mol_charset",
|
|
25
|
+
"$mol_bigint_decode",
|
|
23
26
|
"$mol_charset_decode_from",
|
|
24
27
|
"$mol_charset_decode",
|
|
25
28
|
"$mol_charset_encoding",
|
package/web.d.ts
CHANGED
|
@@ -14,6 +14,10 @@ declare namespace $ {
|
|
|
14
14
|
export {};
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
+
declare namespace $ {
|
|
18
|
+
function $mol_bigint_encode(num: bigint): Uint8Array<ArrayBuffer>;
|
|
19
|
+
}
|
|
20
|
+
|
|
17
21
|
declare namespace $ {
|
|
18
22
|
function $mol_fail(error: any): never;
|
|
19
23
|
}
|
|
@@ -24,6 +28,10 @@ declare namespace $ {
|
|
|
24
28
|
function $mol_charset_encode_size(str: string): number;
|
|
25
29
|
}
|
|
26
30
|
|
|
31
|
+
declare namespace $ {
|
|
32
|
+
function $mol_bigint_decode(buf: Uint8Array<ArrayBuffer>): bigint;
|
|
33
|
+
}
|
|
34
|
+
|
|
27
35
|
declare namespace $ {
|
|
28
36
|
type $mol_charset_encoding = 'utf8' | 'utf-16le' | 'utf-16be' | 'ibm866' | 'iso-8859-2' | 'iso-8859-3' | 'iso-8859-4' | 'iso-8859-5' | 'iso-8859-6' | 'iso-8859-7' | 'iso-8859-8' | 'iso-8859-8i' | 'iso-8859-10' | 'iso-8859-13' | 'iso-8859-14' | 'iso-8859-15' | 'iso-8859-16' | 'koi8-r' | 'koi8-u' | 'koi8-r' | 'macintosh' | 'windows-874' | 'windows-1250' | 'windows-1251' | 'windows-1252' | 'windows-1253' | 'windows-1254' | 'windows-1255' | 'windows-1256' | 'windows-1257' | 'windows-1258' | 'x-mac-cyrillic' | 'gbk' | 'gb18030' | 'hz-gb-2312' | 'big5' | 'euc-jp' | 'iso-2022-jp' | 'shift-jis' | 'euc-kr' | 'iso-2022-kr';
|
|
29
37
|
}
|
|
@@ -58,12 +66,13 @@ declare namespace $ {
|
|
|
58
66
|
tupl = 192,
|
|
59
67
|
sint = 224
|
|
60
68
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
69
|
+
enum $mol_vary_len {
|
|
70
|
+
L1 = 28,
|
|
71
|
+
L2 = 29,
|
|
72
|
+
L4 = 30,
|
|
73
|
+
L8 = 31,
|
|
74
|
+
LA = 32
|
|
75
|
+
}
|
|
67
76
|
enum $mol_vary_spec {
|
|
68
77
|
none,
|
|
69
78
|
true,
|
package/web.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../mam.d.ts","../../fail/fail.d.ts","../../charset/encode/encode.d.ts","../../charset/encoding/encoding.d.ts","../../charset/decode/decode.d.ts","../../charset/decode/from/from.d.ts","../../dom/context/context.d.ts","../../dom/context/context.web.d.ts","../../dom/dom.d.ts","../vary.d.ts"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;ACfA;AACA;AACA;AACA;ACHA;AACA;AACA;AACA;AACA;AACA;ACLA;AACA;AACA;AACA;ACHA;AACA;AACA;AACA;ACHA;AACA;AACA;AACA;ACHA;AACA;AACA;AACA;ACHA;AACA;AACA;ACFA;AACA;AACA;AACA;ACHA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","sourcesContent":[null,null,null,null,null,null,null,null,null,null]}
|
|
1
|
+
{"version":3,"sources":["../../../mam.d.ts","../../bigint/encode/encode.d.ts","../../fail/fail.d.ts","../../charset/encode/encode.d.ts","../../bigint/decode/decode.d.ts","../../charset/encoding/encoding.d.ts","../../charset/decode/decode.d.ts","../../charset/decode/from/from.d.ts","../../dom/context/context.d.ts","../../dom/context/context.web.d.ts","../../dom/dom.d.ts","../vary.d.ts"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;ACfA;AACA;AACA;AACA;ACHA;AACA;AACA;AACA;ACHA;AACA;AACA;AACA;AACA;AACA;ACLA;AACA;AACA;AACA;ACHA;AACA;AACA;AACA;ACHA;AACA;AACA;AACA;ACHA;AACA;AACA;AACA;ACHA;AACA;AACA;AACA;ACHA;AACA;AACA;ACFA;AACA;AACA;AACA;ACHA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","sourcesContent":[null,null,null,null,null,null,null,null,null,null,null,null]}
|
package/web.deps.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"files":["mam.ts","LICENSE","README.md","mam.jam.js","tsfmt.json","package.json","tsconfig.json","lang.lang.tree","meta.lang.tree","sandbox.config.json","mol/CNAME","mol/LICENSE","mol/readme.md","mol/mol.meta.tree","mol/CONTRIBUTING.md","mol/CODE_OF_CONDUCT.md","mol/fail/fail.ts","mol/charset/encode/encode.ts","mol/charset/encoding/encoding.ts","mol/charset/decode/decode.ts","mol/charset/decode/from/from.ts","mol/dom/context/context.ts","mol/dom/context/context.web.ts","mol/dom/dom.ts","mol/vary/vary.ts","mol/vary/readme.md"],"mods":{},"deps_in":{"mol":{"mol/vary":-999,"mol/fail":-999,"mol/charset":-999,"mol/dom":-999},"":{"mol":-999},"mol/fail":{"mol/vary":-3},"mol/charset/encode":{"mol/vary":-4},"mol/charset":{"mol/charset/encode":-999,"mol/charset/decode":-999,"mol/charset/encoding":-999},"mol/charset/decode/from":{"mol/vary":-4},"mol/charset/decode":{"mol/charset/decode/from":-999},"mol/charset/encoding":{"mol/charset/decode":-1},"mol/dom":{"mol/vary":-2},"mol/dom/context":{"mol/dom":-1},"mol/dom/context/context.ts":{"mol/dom/context":0}},"deps_out":{"mol/vary":{"mol":-999,"mol/fail":-3,"mol/charset/encode":-4,"mol/charset/decode/from":-4,"mol/dom":-2},"mol":{"":-999},"mol/fail":{"mol":-999},"mol/charset/encode":{"mol/charset":-999},"mol/charset":{"mol":-999},"mol/charset/decode/from":{"mol/charset/decode":-999},"mol/charset/decode":{"mol/charset":-999,"mol/charset/encoding":-1},"mol/charset/encoding":{"mol/charset":-999},"mol/dom":{"mol":-999,"mol/dom/context":-1},"mol/dom/context":{"mol/dom/context/context.ts":0},"mol/dom/context/context.ts":{}},"sloc":{"ts":
|
|
1
|
+
{"files":["mam.ts","LICENSE","README.md","mam.jam.js","tsfmt.json","package.json","tsconfig.json","lang.lang.tree","meta.lang.tree","sandbox.config.json","mol/CNAME","mol/LICENSE","mol/readme.md","mol/mol.meta.tree","mol/CONTRIBUTING.md","mol/CODE_OF_CONDUCT.md","mol/bigint/encode/encode.ts","mol/fail/fail.ts","mol/charset/encode/encode.ts","mol/bigint/decode/decode.ts","mol/charset/encoding/encoding.ts","mol/charset/decode/decode.ts","mol/charset/decode/from/from.ts","mol/dom/context/context.ts","mol/dom/context/context.web.ts","mol/dom/dom.ts","mol/vary/vary.ts","mol/vary/readme.md"],"mods":{},"deps_in":{"mol":{"mol/vary":-999,"mol/bigint":-999,"mol/fail":-999,"mol/charset":-999,"mol/dom":-999},"":{"mol":-999},"mol/bigint/encode":{"mol/vary":-4},"mol/bigint":{"mol/bigint/encode":-999,"mol/bigint/decode":-999},"mol/fail":{"mol/vary":-3},"mol/charset/encode":{"mol/vary":-4},"mol/charset":{"mol/charset/encode":-999,"mol/charset/decode":-999,"mol/charset/encoding":-999},"mol/bigint/decode":{"mol/vary":-5},"mol/charset/decode/from":{"mol/vary":-4},"mol/charset/decode":{"mol/charset/decode/from":-999},"mol/charset/encoding":{"mol/charset/decode":-1},"mol/dom":{"mol/vary":-2},"mol/dom/context":{"mol/dom":-1},"mol/dom/context/context.ts":{"mol/dom/context":0}},"deps_out":{"mol/vary":{"mol":-999,"mol/bigint/encode":-4,"mol/fail":-3,"mol/charset/encode":-4,"mol/bigint/decode":-5,"mol/charset/decode/from":-4,"mol/dom":-2},"mol":{"":-999},"mol/bigint/encode":{"mol/bigint":-999},"mol/bigint":{"mol":-999},"mol/fail":{"mol":-999},"mol/charset/encode":{"mol/charset":-999},"mol/charset":{"mol":-999},"mol/bigint/decode":{"mol/bigint":-999},"mol/charset/decode/from":{"mol/charset/decode":-999},"mol/charset/decode":{"mol/charset":-999,"mol/charset/encoding":-1},"mol/charset/encoding":{"mol/charset":-999},"mol/dom":{"mol":-999,"mol/dom/context":-1},"mol/dom/context":{"mol/dom/context/context.ts":0},"mol/dom/context/context.ts":{}},"sloc":{"ts":601,"LICENSE":113,"md":530,"js":9,"json":82,"tree":41,"CNAME":1},"deps":{"mol/vary":{"..":-999,"/mol/vary/tip":-1,"/mol/vary/len":-1,"/mol/vary/spec":-1,"/mol/vary/tip/spec":-2,"/mol/vary":-1,"/mol/bigint/encode":-4,"/mol/fail":-3,"/mol/vary/tip/link":-4,"/mol/vary/tip/text":-4,"/mol/charset/encode/to":-4,"/mol/vary/tip/blob":-4,"/mol/vary/tip/uint":-4,"/mol/vary/tip/sint":-4,"/mol/vary/spec/fp16":-4,"/mol/vary/spec/fp32":-4,"/mol/vary/spec/fp64":-4,"/mol/vary/tip/list":-4,"/mol/vary/keys":-1,"/mol/vary/lean":-1,"/mol/vary/tip/tupl":-4,"/mol/vary/spec/both":-5,"/mol/vary/spec/true":-5,"/mol/vary/spec/fake":-5,"/mol/vary/spec/none":-5,"/mol/bigint/decode":-5,"/mol/charset/decode/from":-4,"/mol/vary/type":-1,"/mol/dom":-2,"/mol/dom/document/create/element":-3,"/mol/dom/document/create/text/node":-4},"mol":{"..":-999},"":{},"mol/bigint/encode":{"..":-999,"/mol/bigint/encode":-1},"mol/bigint":{"..":-999},"mol/fail":{"..":-999,"/mol/fail":-1},"mol/charset/encode":{"..":-999,"/mol/charset/encode":-1,"/mol/charset/encode/to":-1,"/mol/charset/encode/size":-1},"mol/charset":{"..":-999},"mol/bigint/decode":{"..":-999,"/mol/bigint/decode":-1},"mol/charset/decode/from":{"..":-999,"/mol/charset/decode/from":-1},"mol/charset/decode":{"..":-999,"/mol/charset/encoding":-1,"/mol/charset/decode":-1},"mol/charset/encoding":{"..":-999,"/mol/charset/encoding":-1},"mol/dom":{"..":-999,"/mol/dom":-1,"/mol/dom/context":-1},"mol/dom/context":{"..":-999,"/mol/dom/context":-1,"./context.ts":0},"mol/dom/context/context.ts":{"/mol/dom/context":-1}}}
|
package/web.js
CHANGED
|
@@ -28,6 +28,28 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
28
28
|
var $ = ( typeof module === 'object' ) ? ( module['export'+'s'] = globalThis ) : globalThis
|
|
29
29
|
$.$$ = $
|
|
30
30
|
|
|
31
|
+
;
|
|
32
|
+
"use strict";
|
|
33
|
+
var $;
|
|
34
|
+
(function ($) {
|
|
35
|
+
function $mol_bigint_encode(num) {
|
|
36
|
+
const minus = num < 0n ? 255 : 0;
|
|
37
|
+
num = minus ? -num - 1n : num;
|
|
38
|
+
const bytes = [];
|
|
39
|
+
do {
|
|
40
|
+
let byte = minus ^ Number(num % 256n);
|
|
41
|
+
bytes.push(byte);
|
|
42
|
+
if (num >>= 8n)
|
|
43
|
+
continue;
|
|
44
|
+
if ((minus & 128) !== (byte & 128))
|
|
45
|
+
bytes.push(minus);
|
|
46
|
+
break;
|
|
47
|
+
} while (num);
|
|
48
|
+
return new Uint8Array(bytes);
|
|
49
|
+
}
|
|
50
|
+
$.$mol_bigint_encode = $mol_bigint_encode;
|
|
51
|
+
})($ || ($ = {}));
|
|
52
|
+
|
|
31
53
|
;
|
|
32
54
|
"use strict";
|
|
33
55
|
var $;
|
|
@@ -95,6 +117,32 @@ var $;
|
|
|
95
117
|
$.$mol_charset_encode_size = $mol_charset_encode_size;
|
|
96
118
|
})($ || ($ = {}));
|
|
97
119
|
|
|
120
|
+
;
|
|
121
|
+
"use strict";
|
|
122
|
+
var $;
|
|
123
|
+
(function ($) {
|
|
124
|
+
function $mol_bigint_decode(buf) {
|
|
125
|
+
if (buf.length === 8)
|
|
126
|
+
return new BigInt64Array(buf.buffer, buf.byteOffset, 1)[0];
|
|
127
|
+
if (buf.length === 4)
|
|
128
|
+
return BigInt(new Int32Array(buf.buffer, buf.byteOffset, 1)[0]);
|
|
129
|
+
if (buf.length === 2)
|
|
130
|
+
return BigInt(new Int16Array(buf.buffer, buf.byteOffset, 1)[0]);
|
|
131
|
+
if (buf.length === 1)
|
|
132
|
+
return BigInt(new Int8Array(buf.buffer, buf.byteOffset, 1)[0]);
|
|
133
|
+
const minus = (buf.at(-1) & 128) ? 255 : 0;
|
|
134
|
+
let result = 0n;
|
|
135
|
+
let offset = 0n;
|
|
136
|
+
for (let i = 0; i < buf.length; i++, offset += 8n) {
|
|
137
|
+
result |= BigInt(buf[i] ^ minus) << offset;
|
|
138
|
+
}
|
|
139
|
+
if (minus)
|
|
140
|
+
result = (result + 1n) * -1n;
|
|
141
|
+
return result;
|
|
142
|
+
}
|
|
143
|
+
$.$mol_bigint_decode = $mol_bigint_decode;
|
|
144
|
+
})($ || ($ = {}));
|
|
145
|
+
|
|
98
146
|
;
|
|
99
147
|
"use strict";
|
|
100
148
|
|
|
@@ -200,12 +248,14 @@ var $;
|
|
|
200
248
|
$mol_vary_tip[$mol_vary_tip["tupl"] = 192] = "tupl";
|
|
201
249
|
$mol_vary_tip[$mol_vary_tip["sint"] = 224] = "sint";
|
|
202
250
|
})($mol_vary_tip = $.$mol_vary_tip || ($.$mol_vary_tip = {}));
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
251
|
+
let $mol_vary_len;
|
|
252
|
+
(function ($mol_vary_len) {
|
|
253
|
+
$mol_vary_len[$mol_vary_len["L1"] = 28] = "L1";
|
|
254
|
+
$mol_vary_len[$mol_vary_len["L2"] = 29] = "L2";
|
|
255
|
+
$mol_vary_len[$mol_vary_len["L4"] = 30] = "L4";
|
|
256
|
+
$mol_vary_len[$mol_vary_len["L8"] = 31] = "L8";
|
|
257
|
+
$mol_vary_len[$mol_vary_len["LA"] = 32] = "LA";
|
|
258
|
+
})($mol_vary_len = $.$mol_vary_len || ($.$mol_vary_len = {}));
|
|
209
259
|
let $mol_vary_spec;
|
|
210
260
|
(function ($mol_vary_spec) {
|
|
211
261
|
$mol_vary_spec[$mol_vary_spec["none"] = 'N'.charCodeAt(0)] = "none";
|
|
@@ -237,66 +287,76 @@ var $;
|
|
|
237
287
|
const release = (size) => {
|
|
238
288
|
capacity -= size;
|
|
239
289
|
};
|
|
240
|
-
const
|
|
241
|
-
|
|
242
|
-
|
|
290
|
+
const dump_bint = (val) => {
|
|
291
|
+
const buf = $mol_bigint_encode(val);
|
|
292
|
+
acquire(buf.byteLength - 7);
|
|
293
|
+
if (buf.byteLength > 264)
|
|
294
|
+
$mol_fail(new Error('Number too high', { cause: { val } }));
|
|
295
|
+
buffer[pos++] = -$mol_vary_len.LA;
|
|
296
|
+
buffer[pos++] = buf.byteLength - 9;
|
|
297
|
+
buffer.set(buf, pos);
|
|
298
|
+
pos += buf.byteLength;
|
|
299
|
+
};
|
|
300
|
+
const dump_unum = (tip, val) => {
|
|
301
|
+
if (val < $mol_vary_len.L1) {
|
|
302
|
+
buffer[pos++] = tip | Number(val);
|
|
243
303
|
release(8);
|
|
244
304
|
}
|
|
245
|
-
else if (val
|
|
246
|
-
buffer[pos++] =
|
|
305
|
+
else if (val < 2 ** 8) {
|
|
306
|
+
buffer[pos++] = tip | $mol_vary_len.L1;
|
|
247
307
|
buffer[pos++] = Number(val);
|
|
248
308
|
release(7);
|
|
249
309
|
}
|
|
250
|
-
else if (val
|
|
251
|
-
buffer[pos++] =
|
|
252
|
-
pack.
|
|
310
|
+
else if (val < 2 ** 16) {
|
|
311
|
+
buffer[pos++] = tip | $mol_vary_len.L2;
|
|
312
|
+
pack.setUint16(pos, Number(val), true);
|
|
253
313
|
pos += 2;
|
|
254
314
|
release(6);
|
|
255
315
|
}
|
|
256
|
-
else if (val
|
|
257
|
-
buffer[pos++] =
|
|
258
|
-
pack.
|
|
316
|
+
else if (val < 2 ** 32) {
|
|
317
|
+
buffer[pos++] = tip | $mol_vary_len.L4;
|
|
318
|
+
pack.setUint32(pos, Number(val), true);
|
|
259
319
|
pos += 4;
|
|
260
320
|
release(4);
|
|
261
321
|
}
|
|
262
|
-
else if (val
|
|
263
|
-
buffer[pos++] =
|
|
264
|
-
pack.
|
|
322
|
+
else if (val < 2n ** 64n) {
|
|
323
|
+
buffer[pos++] = tip | $mol_vary_len.L8;
|
|
324
|
+
pack.setBigUint64(pos, BigInt(val), true);
|
|
265
325
|
pos += 8;
|
|
266
326
|
}
|
|
267
327
|
else {
|
|
268
|
-
|
|
328
|
+
dump_bint(val);
|
|
269
329
|
}
|
|
270
330
|
};
|
|
271
|
-
const
|
|
272
|
-
if (val
|
|
273
|
-
buffer[pos++] =
|
|
331
|
+
const dump_snum = (val) => {
|
|
332
|
+
if (val > -$mol_vary_len.L1) {
|
|
333
|
+
buffer[pos++] = Number(val);
|
|
274
334
|
release(8);
|
|
275
335
|
}
|
|
276
|
-
else if (val
|
|
277
|
-
buffer[pos++] =
|
|
336
|
+
else if (val >= -(2 ** 7)) {
|
|
337
|
+
buffer[pos++] = -$mol_vary_len.L1;
|
|
278
338
|
buffer[pos++] = Number(val);
|
|
279
339
|
release(7);
|
|
280
340
|
}
|
|
281
|
-
else if (val
|
|
282
|
-
buffer[pos++] =
|
|
283
|
-
pack.
|
|
341
|
+
else if (val >= -(2 ** 15)) {
|
|
342
|
+
buffer[pos++] = -$mol_vary_len.L2;
|
|
343
|
+
pack.setInt16(pos, Number(val), true);
|
|
284
344
|
pos += 2;
|
|
285
345
|
release(6);
|
|
286
346
|
}
|
|
287
|
-
else if (val
|
|
288
|
-
buffer[pos++] =
|
|
289
|
-
pack.
|
|
347
|
+
else if (val >= -(2 ** 31)) {
|
|
348
|
+
buffer[pos++] = -$mol_vary_len.L4;
|
|
349
|
+
pack.setInt32(pos, Number(val), true);
|
|
290
350
|
pos += 4;
|
|
291
351
|
release(4);
|
|
292
352
|
}
|
|
293
|
-
else if (val
|
|
294
|
-
buffer[pos++] =
|
|
295
|
-
pack.
|
|
353
|
+
else if (val >= -(2n ** 63n)) {
|
|
354
|
+
buffer[pos++] = -$mol_vary_len.L8;
|
|
355
|
+
pack.setBigInt64(pos, BigInt(val), true);
|
|
296
356
|
pos += 8;
|
|
297
357
|
}
|
|
298
358
|
else {
|
|
299
|
-
|
|
359
|
+
dump_bint(val);
|
|
300
360
|
}
|
|
301
361
|
};
|
|
302
362
|
const dump_string = (val) => {
|
|
@@ -322,21 +382,23 @@ var $;
|
|
|
322
382
|
}
|
|
323
383
|
dump_unum($mol_vary_tip.blob, val.byteLength);
|
|
324
384
|
if (val instanceof Uint8Array)
|
|
325
|
-
buffer[pos++] = $mol_vary_tip.uint |
|
|
385
|
+
buffer[pos++] = $mol_vary_tip.uint | $mol_vary_len.L1;
|
|
326
386
|
else if (val instanceof Uint16Array)
|
|
327
|
-
buffer[pos++] = $mol_vary_tip.uint |
|
|
387
|
+
buffer[pos++] = $mol_vary_tip.uint | $mol_vary_len.L2;
|
|
328
388
|
else if (val instanceof Uint32Array)
|
|
329
|
-
buffer[pos++] = $mol_vary_tip.uint |
|
|
389
|
+
buffer[pos++] = $mol_vary_tip.uint | $mol_vary_len.L4;
|
|
330
390
|
else if (val instanceof BigUint64Array)
|
|
331
|
-
buffer[pos++] = $mol_vary_tip.uint |
|
|
391
|
+
buffer[pos++] = $mol_vary_tip.uint | $mol_vary_len.L8;
|
|
332
392
|
else if (val instanceof Int8Array)
|
|
333
|
-
buffer[pos++] = $mol_vary_tip.sint |
|
|
393
|
+
buffer[pos++] = $mol_vary_tip.sint | ~$mol_vary_len.L1;
|
|
334
394
|
else if (val instanceof Int16Array)
|
|
335
|
-
buffer[pos++] = $mol_vary_tip.sint |
|
|
395
|
+
buffer[pos++] = $mol_vary_tip.sint | ~$mol_vary_len.L2;
|
|
336
396
|
else if (val instanceof Int32Array)
|
|
337
|
-
buffer[pos++] = $mol_vary_tip.sint |
|
|
397
|
+
buffer[pos++] = $mol_vary_tip.sint | ~$mol_vary_len.L4;
|
|
338
398
|
else if (val instanceof BigInt64Array)
|
|
339
|
-
buffer[pos++] = $mol_vary_tip.sint |
|
|
399
|
+
buffer[pos++] = $mol_vary_tip.sint | ~$mol_vary_len.L8;
|
|
400
|
+
else if (typeof Float16Array === 'function' && val instanceof Float16Array)
|
|
401
|
+
buffer[pos++] = $mol_vary_spec.fp16;
|
|
340
402
|
else if (val instanceof Float32Array)
|
|
341
403
|
buffer[pos++] = $mol_vary_spec.fp32;
|
|
342
404
|
else if (val instanceof Float64Array)
|
|
@@ -432,21 +494,21 @@ var $;
|
|
|
432
494
|
const read_unum = (kind) => {
|
|
433
495
|
++pos;
|
|
434
496
|
const num = kind & 0b11111;
|
|
435
|
-
if (num <
|
|
497
|
+
if (num < $mol_vary_len.L1)
|
|
436
498
|
return num;
|
|
437
499
|
let res = 0;
|
|
438
|
-
if (num ===
|
|
500
|
+
if (num === $mol_vary_len.L1) {
|
|
439
501
|
res = pack.getUint8(pos++);
|
|
440
502
|
}
|
|
441
|
-
else if (num ===
|
|
503
|
+
else if (num === $mol_vary_len.L2) {
|
|
442
504
|
res = pack.getUint16(pos, true);
|
|
443
505
|
pos += 2;
|
|
444
506
|
}
|
|
445
|
-
else if (num ===
|
|
507
|
+
else if (num === $mol_vary_len.L4) {
|
|
446
508
|
res = pack.getUint32(pos, true);
|
|
447
509
|
pos += 4;
|
|
448
510
|
}
|
|
449
|
-
else if (num ===
|
|
511
|
+
else if (num === $mol_vary_len.L8) {
|
|
450
512
|
res = pack.getBigUint64(pos, true);
|
|
451
513
|
if (res <= Number.MAX_SAFE_INTEGER)
|
|
452
514
|
res = Number(res);
|
|
@@ -459,27 +521,31 @@ var $;
|
|
|
459
521
|
};
|
|
460
522
|
const read_snum = (kind) => {
|
|
461
523
|
const num = pack.getInt8(pos++);
|
|
462
|
-
if (num
|
|
524
|
+
if (num > -$mol_vary_len.L1)
|
|
463
525
|
return num;
|
|
464
526
|
let res = 0;
|
|
465
|
-
if (num ===
|
|
466
|
-
res = pack.getInt8(pos);
|
|
467
|
-
pos += 1;
|
|
527
|
+
if (num === -$mol_vary_len.L1) {
|
|
528
|
+
res = pack.getInt8(pos++);
|
|
468
529
|
}
|
|
469
|
-
else if (num ===
|
|
530
|
+
else if (num === -$mol_vary_len.L2) {
|
|
470
531
|
res = pack.getInt16(pos, true);
|
|
471
532
|
pos += 2;
|
|
472
533
|
}
|
|
473
|
-
else if (num ===
|
|
534
|
+
else if (num === -$mol_vary_len.L4) {
|
|
474
535
|
res = pack.getInt32(pos, true);
|
|
475
536
|
pos += 4;
|
|
476
537
|
}
|
|
477
|
-
else if (num ===
|
|
538
|
+
else if (num === -$mol_vary_len.L8) {
|
|
478
539
|
res = pack.getBigInt64(pos, true);
|
|
479
540
|
if (res >= Number.MIN_SAFE_INTEGER && res <= Number.MAX_SAFE_INTEGER)
|
|
480
541
|
res = Number(res);
|
|
481
542
|
pos += 8;
|
|
482
543
|
}
|
|
544
|
+
else if (num === -$mol_vary_len.LA) {
|
|
545
|
+
const len = pack.getUint8(pos++) + 9;
|
|
546
|
+
res = $mol_bigint_decode(new Uint8Array(pack.buffer, pack.byteOffset + pos, len));
|
|
547
|
+
pos += len;
|
|
548
|
+
}
|
|
483
549
|
else {
|
|
484
550
|
$mol_fail(new Error('Unsupported snum', { cause: { num } }));
|
|
485
551
|
}
|
|
@@ -504,14 +570,14 @@ var $;
|
|
|
504
570
|
const len = read_unum(kind);
|
|
505
571
|
const kind_item = pack.getUint8(pos++);
|
|
506
572
|
switch (kind_item) {
|
|
507
|
-
case
|
|
508
|
-
case
|
|
509
|
-
case
|
|
510
|
-
case
|
|
511
|
-
case
|
|
512
|
-
case
|
|
513
|
-
case
|
|
514
|
-
case
|
|
573
|
+
case $mol_vary_len.L1: return read_buffer(len, Uint8Array);
|
|
574
|
+
case $mol_vary_len.L2: return read_buffer(len, Uint16Array);
|
|
575
|
+
case $mol_vary_len.L4: return read_buffer(len, Uint32Array);
|
|
576
|
+
case $mol_vary_len.L8: return read_buffer(len, BigUint64Array);
|
|
577
|
+
case ~$mol_vary_len.L1 + 256: return read_buffer(len, Int8Array);
|
|
578
|
+
case ~$mol_vary_len.L2 + 256: return read_buffer(len, Int16Array);
|
|
579
|
+
case ~$mol_vary_len.L4 + 256: return read_buffer(len, Int32Array);
|
|
580
|
+
case ~$mol_vary_len.L8 + 256: return read_buffer(len, BigInt64Array);
|
|
515
581
|
case $mol_vary_tip.spec | $mol_vary_spec.fp16: return read_buffer(len, Float16Array);
|
|
516
582
|
case $mol_vary_tip.spec | $mol_vary_spec.fp32: return read_buffer(len, Float32Array);
|
|
517
583
|
case $mol_vary_tip.spec | $mol_vary_spec.fp64: return read_buffer(len, Float64Array);
|