mol_vary 0.0.42 → 0.0.44
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/node.d.ts +5 -2
- package/node.d.ts.map +1 -1
- package/node.deps.json +1 -1
- package/node.js +15 -3
- package/node.js.map +1 -1
- package/node.meta.tree +1 -1
- package/node.mjs +15 -3
- package/node.test.js +18 -6
- package/node.test.js.map +1 -1
- package/package.json +1 -1
- package/web.d.ts +5 -2
- package/web.d.ts.map +1 -1
- package/web.deps.json +1 -1
- package/web.js +15 -3
- package/web.js.map +1 -1
- package/web.meta.tree +1 -1
- package/web.mjs +15 -3
- package/web.test.js +3 -3
- package/web.test.js.map +1 -1
package/node.meta.tree
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
\/
|
|
2
2
|
pack bun git \https://github.com/spleekz/mam_bun.git
|
|
3
|
-
pack
|
|
3
|
+
pack giper git \https://github.com/giper-dev/gd.git
|
|
4
4
|
pack hyoo git \https://github.com/hyoo-ru/mam_hyoo.git
|
|
5
5
|
pack iva git \https://github.com/thenesterov/mam_iva.git
|
|
6
6
|
pack jin git \https://github.com/nin-jin/mam_jin.git
|
package/node.mjs
CHANGED
|
@@ -2339,8 +2339,9 @@ var $;
|
|
|
2339
2339
|
$mol_vary_spec[$mol_vary_spec["fp16"] = 'H'.charCodeAt(0)] = "fp16";
|
|
2340
2340
|
$mol_vary_spec[$mol_vary_spec["fp32"] = 'S'.charCodeAt(0)] = "fp32";
|
|
2341
2341
|
$mol_vary_spec[$mol_vary_spec["fp64"] = 'D'.charCodeAt(0)] = "fp64";
|
|
2342
|
+
$mol_vary_spec[$mol_vary_spec["f128"] = 'Q'.charCodeAt(0)] = "f128";
|
|
2343
|
+
$mol_vary_spec[$mol_vary_spec["f256"] = 'O'.charCodeAt(0)] = "f256";
|
|
2342
2344
|
})($mol_vary_spec = $.$mol_vary_spec || ($.$mol_vary_spec = {}));
|
|
2343
|
-
$.$mol_vary_lean = Symbol.for('$mol_vary_lean');
|
|
2344
2345
|
const pojo_maker = (keys) => (vals) => {
|
|
2345
2346
|
const obj = {};
|
|
2346
2347
|
for (let i = 0; i < keys.length; ++i)
|
|
@@ -2348,6 +2349,7 @@ var $;
|
|
|
2348
2349
|
return obj;
|
|
2349
2350
|
};
|
|
2350
2351
|
class $mol_vary_class extends Object {
|
|
2352
|
+
lean_symbol = Symbol('$mol_vary_lean');
|
|
2351
2353
|
array = new Uint8Array(256);
|
|
2352
2354
|
buffer = new DataView(this.array.buffer);
|
|
2353
2355
|
pack(data) {
|
|
@@ -2540,7 +2542,7 @@ var $;
|
|
|
2540
2542
|
const offset = offsets.get(val);
|
|
2541
2543
|
if (offset !== undefined)
|
|
2542
2544
|
return dump_unum($mol_vary_tip.link, offset);
|
|
2543
|
-
const [keys, vals] = val
|
|
2545
|
+
const [keys, vals] = this.lean_find(val)?.(val) ?? [shape(val), Object.values(val)];
|
|
2544
2546
|
dump_unum($mol_vary_tip.tupl, vals.length);
|
|
2545
2547
|
acquire((vals.length + 1) * 9);
|
|
2546
2548
|
dump_list(keys);
|
|
@@ -2787,6 +2789,7 @@ var $;
|
|
|
2787
2789
|
]);
|
|
2788
2790
|
room() {
|
|
2789
2791
|
const room = new $mol_vary_class;
|
|
2792
|
+
Object.setPrototypeOf(room, this);
|
|
2790
2793
|
const index_clone = (map) => new Map([...map].map(([k, v]) => [k, k === null ? v : index_clone(v)]));
|
|
2791
2794
|
room.rich_index = index_clone(this.rich_index);
|
|
2792
2795
|
return room;
|
|
@@ -2802,9 +2805,18 @@ var $;
|
|
|
2802
2805
|
}
|
|
2803
2806
|
return node;
|
|
2804
2807
|
}
|
|
2808
|
+
lean_find(val) {
|
|
2809
|
+
const lean = val[this.lean_symbol];
|
|
2810
|
+
if (lean)
|
|
2811
|
+
return lean;
|
|
2812
|
+
const sup = Object.getPrototypeOf(this);
|
|
2813
|
+
if (sup === Object.prototype)
|
|
2814
|
+
return;
|
|
2815
|
+
return sup.lean_find(val);
|
|
2816
|
+
}
|
|
2805
2817
|
type({ type, keys, rich, lean }) {
|
|
2806
2818
|
this.rich_node(keys).set(null, rich);
|
|
2807
|
-
type.prototype[
|
|
2819
|
+
type.prototype[this.lean_symbol] = (val) => [keys, lean(val)];
|
|
2808
2820
|
}
|
|
2809
2821
|
}
|
|
2810
2822
|
$.$mol_vary_class = $mol_vary_class;
|
package/node.test.js
CHANGED
|
@@ -2330,8 +2330,9 @@ var $;
|
|
|
2330
2330
|
$mol_vary_spec[$mol_vary_spec["fp16"] = 'H'.charCodeAt(0)] = "fp16";
|
|
2331
2331
|
$mol_vary_spec[$mol_vary_spec["fp32"] = 'S'.charCodeAt(0)] = "fp32";
|
|
2332
2332
|
$mol_vary_spec[$mol_vary_spec["fp64"] = 'D'.charCodeAt(0)] = "fp64";
|
|
2333
|
+
$mol_vary_spec[$mol_vary_spec["f128"] = 'Q'.charCodeAt(0)] = "f128";
|
|
2334
|
+
$mol_vary_spec[$mol_vary_spec["f256"] = 'O'.charCodeAt(0)] = "f256";
|
|
2333
2335
|
})($mol_vary_spec = $.$mol_vary_spec || ($.$mol_vary_spec = {}));
|
|
2334
|
-
$.$mol_vary_lean = Symbol.for('$mol_vary_lean');
|
|
2335
2336
|
const pojo_maker = (keys) => (vals) => {
|
|
2336
2337
|
const obj = {};
|
|
2337
2338
|
for (let i = 0; i < keys.length; ++i)
|
|
@@ -2339,6 +2340,7 @@ var $;
|
|
|
2339
2340
|
return obj;
|
|
2340
2341
|
};
|
|
2341
2342
|
class $mol_vary_class extends Object {
|
|
2343
|
+
lean_symbol = Symbol('$mol_vary_lean');
|
|
2342
2344
|
array = new Uint8Array(256);
|
|
2343
2345
|
buffer = new DataView(this.array.buffer);
|
|
2344
2346
|
pack(data) {
|
|
@@ -2531,7 +2533,7 @@ var $;
|
|
|
2531
2533
|
const offset = offsets.get(val);
|
|
2532
2534
|
if (offset !== undefined)
|
|
2533
2535
|
return dump_unum($mol_vary_tip.link, offset);
|
|
2534
|
-
const [keys, vals] = val
|
|
2536
|
+
const [keys, vals] = this.lean_find(val)?.(val) ?? [shape(val), Object.values(val)];
|
|
2535
2537
|
dump_unum($mol_vary_tip.tupl, vals.length);
|
|
2536
2538
|
acquire((vals.length + 1) * 9);
|
|
2537
2539
|
dump_list(keys);
|
|
@@ -2778,6 +2780,7 @@ var $;
|
|
|
2778
2780
|
]);
|
|
2779
2781
|
room() {
|
|
2780
2782
|
const room = new $mol_vary_class;
|
|
2783
|
+
Object.setPrototypeOf(room, this);
|
|
2781
2784
|
const index_clone = (map) => new Map([...map].map(([k, v]) => [k, k === null ? v : index_clone(v)]));
|
|
2782
2785
|
room.rich_index = index_clone(this.rich_index);
|
|
2783
2786
|
return room;
|
|
@@ -2793,9 +2796,18 @@ var $;
|
|
|
2793
2796
|
}
|
|
2794
2797
|
return node;
|
|
2795
2798
|
}
|
|
2799
|
+
lean_find(val) {
|
|
2800
|
+
const lean = val[this.lean_symbol];
|
|
2801
|
+
if (lean)
|
|
2802
|
+
return lean;
|
|
2803
|
+
const sup = Object.getPrototypeOf(this);
|
|
2804
|
+
if (sup === Object.prototype)
|
|
2805
|
+
return;
|
|
2806
|
+
return sup.lean_find(val);
|
|
2807
|
+
}
|
|
2796
2808
|
type({ type, keys, rich, lean }) {
|
|
2797
2809
|
this.rich_node(keys).set(null, rich);
|
|
2798
|
-
type.prototype[
|
|
2810
|
+
type.prototype[this.lean_symbol] = (val) => [keys, lean(val)];
|
|
2799
2811
|
}
|
|
2800
2812
|
}
|
|
2801
2813
|
$.$mol_vary_class = $mol_vary_class;
|
|
@@ -4926,8 +4938,8 @@ var $;
|
|
|
4926
4938
|
const str = $mol_charset_encode;
|
|
4927
4939
|
function check(vary, ideal, Vary = $mol_vary) {
|
|
4928
4940
|
const pack = Vary.pack(vary);
|
|
4929
|
-
$mol_assert_equal(pack, new Uint8Array(ideal));
|
|
4930
4941
|
$mol_assert_equal(Vary.take(pack), vary);
|
|
4942
|
+
$mol_assert_equal(pack, new Uint8Array(ideal));
|
|
4931
4943
|
}
|
|
4932
4944
|
$mol_test({
|
|
4933
4945
|
"vary pack logical"($) {
|
|
@@ -5104,7 +5116,7 @@ var $;
|
|
|
5104
5116
|
tupl | 2, list | 2, text | 6, ...str('target'), text | 4, ...str('text'), text | 3, ...str('foo'), text | 3, ...str('bar'),
|
|
5105
5117
|
]);
|
|
5106
5118
|
},
|
|
5107
|
-
"vary pack custom
|
|
5119
|
+
"vary pack custom types in rooms"($) {
|
|
5108
5120
|
class Foo {
|
|
5109
5121
|
a;
|
|
5110
5122
|
b;
|
|
@@ -5125,7 +5137,7 @@ var $;
|
|
|
5125
5137
|
rich: ([summ, diff]) => new Foo((summ + diff) / 2, (summ - diff) / 2),
|
|
5126
5138
|
});
|
|
5127
5139
|
check(new Foo(4, 2), [tupl | 2, list | 2, text | 4, ...str('summ'), text | 4, ...str('diff'), 6, 2], Vary);
|
|
5128
|
-
$mol_assert_equal($mol_vary.take($mol_vary.pack(new Foo(4, 2))), {
|
|
5140
|
+
$mol_assert_equal($mol_vary.take($mol_vary.pack(new Foo(4, 2))), { a: 4, b: 2 });
|
|
5129
5141
|
$mol_assert_equal(Vary.take(Vary.pack(new Map([[1, 2]]))), new Map([[1, 2]]));
|
|
5130
5142
|
},
|
|
5131
5143
|
});
|