mol_wire_pub 1.0.32 → 1.0.33
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.test.js +29 -27
- package/node.test.js.map +1 -1
- package/package.json +1 -1
- package/web.test.js +29 -27
- package/web.test.js.map +1 -1
package/node.test.js
CHANGED
|
@@ -1928,8 +1928,9 @@ var $;
|
|
|
1928
1928
|
$.$mol_wire_mem = $mol_wire_mem;
|
|
1929
1929
|
function $mol_wire_mem_func(keys) {
|
|
1930
1930
|
return (func) => {
|
|
1931
|
+
const persist = $mol_wire_fiber.persist(func, keys);
|
|
1931
1932
|
const wrapper = function (...args) {
|
|
1932
|
-
let atom =
|
|
1933
|
+
let atom = persist.call(this, ...args.slice(0, keys));
|
|
1933
1934
|
if (args.length <= keys || args[keys] === undefined)
|
|
1934
1935
|
return atom.sync();
|
|
1935
1936
|
try {
|
|
@@ -2503,36 +2504,37 @@ var $;
|
|
|
2503
2504
|
}
|
|
2504
2505
|
return new this(host, task, `${host?.[Symbol.toStringTag] ?? host}.${task.name}(#)`, ...args);
|
|
2505
2506
|
}
|
|
2506
|
-
static persist(
|
|
2507
|
+
static persist(task, keys) {
|
|
2507
2508
|
const field = task.name + '()';
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2509
|
+
if (keys) {
|
|
2510
|
+
return function $mol_wire_fiber_persist(...args) {
|
|
2511
|
+
let dict, key, fiber;
|
|
2512
|
+
key = `${this?.[Symbol.toStringTag] ?? this}.${task.name}(${args.map(v => $mol_key(v)).join(',')})`;
|
|
2513
|
+
dict = Object.getOwnPropertyDescriptor(this ?? task, field)?.value;
|
|
2514
|
+
if (dict) {
|
|
2515
|
+
const existen = dict.get(key);
|
|
2516
|
+
if (existen)
|
|
2517
|
+
return existen;
|
|
2518
|
+
}
|
|
2519
|
+
else {
|
|
2520
|
+
dict = (this ?? task)[field] = new Map();
|
|
2521
|
+
}
|
|
2522
|
+
fiber = new $mol_wire_fiber(this, task, key, ...args);
|
|
2523
|
+
dict.set(key, fiber);
|
|
2524
|
+
return fiber;
|
|
2525
|
+
};
|
|
2516
2526
|
}
|
|
2517
2527
|
else {
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
break reuse;
|
|
2528
|
-
return existen;
|
|
2528
|
+
return function $mol_wire_fiber_persist(...args) {
|
|
2529
|
+
const existen = Object.getOwnPropertyDescriptor(this ?? task, field)?.value;
|
|
2530
|
+
if (existen)
|
|
2531
|
+
return existen;
|
|
2532
|
+
const key = `${this?.[Symbol.toStringTag] ?? this}.${field}`;
|
|
2533
|
+
const fiber = new $mol_wire_fiber(this, task, key, ...args);
|
|
2534
|
+
(this ?? task)[field] = fiber;
|
|
2535
|
+
return fiber;
|
|
2536
|
+
};
|
|
2529
2537
|
}
|
|
2530
|
-
fiber = new this(host, task, key, ...args);
|
|
2531
|
-
if (args.length)
|
|
2532
|
-
dict.set(key, fiber);
|
|
2533
|
-
else
|
|
2534
|
-
(host ?? task)[field] = fiber;
|
|
2535
|
-
return fiber;
|
|
2536
2538
|
}
|
|
2537
2539
|
static warm = true;
|
|
2538
2540
|
static planning = [];
|