mol_key 0.0.1177 → 0.0.1179
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 +26 -2
- package/node.test.js.map +1 -1
- package/package.json +1 -1
package/node.test.js
CHANGED
|
@@ -2552,18 +2552,42 @@ var $;
|
|
|
2552
2552
|
factories.set(val, make);
|
|
2553
2553
|
return make;
|
|
2554
2554
|
}
|
|
2555
|
+
const getters = new WeakMap();
|
|
2556
|
+
function get_prop(host, field) {
|
|
2557
|
+
let props = getters.get(host);
|
|
2558
|
+
let get_val = props?.[field];
|
|
2559
|
+
if (get_val)
|
|
2560
|
+
return get_val;
|
|
2561
|
+
get_val = (next) => {
|
|
2562
|
+
if (next !== undefined)
|
|
2563
|
+
host[field] = next;
|
|
2564
|
+
return host[field];
|
|
2565
|
+
};
|
|
2566
|
+
Object.defineProperty(get_val, 'name', { value: field });
|
|
2567
|
+
if (!props) {
|
|
2568
|
+
props = {};
|
|
2569
|
+
getters.set(host, props);
|
|
2570
|
+
}
|
|
2571
|
+
props[field] = get_val;
|
|
2572
|
+
return get_val;
|
|
2573
|
+
}
|
|
2555
2574
|
function $mol_wire_sync(obj) {
|
|
2556
2575
|
return new Proxy(obj, {
|
|
2557
2576
|
get(obj, field) {
|
|
2558
2577
|
let val = obj[field];
|
|
2578
|
+
const temp = $mol_wire_task.getter(typeof val === 'function' ? val : get_prop(obj, field));
|
|
2559
2579
|
if (typeof val !== 'function')
|
|
2560
|
-
return
|
|
2561
|
-
const temp = $mol_wire_task.getter(val);
|
|
2580
|
+
return temp(obj, []).sync();
|
|
2562
2581
|
return function $mol_wire_sync(...args) {
|
|
2563
2582
|
const fiber = temp(obj, args);
|
|
2564
2583
|
return fiber.sync();
|
|
2565
2584
|
};
|
|
2566
2585
|
},
|
|
2586
|
+
set(obj, field, next) {
|
|
2587
|
+
const temp = $mol_wire_task.getter(get_prop(obj, field));
|
|
2588
|
+
temp(obj, [next]).sync();
|
|
2589
|
+
return true;
|
|
2590
|
+
},
|
|
2567
2591
|
construct(obj, args) {
|
|
2568
2592
|
const temp = $mol_wire_task.getter(factory(obj));
|
|
2569
2593
|
return temp(obj, args).sync();
|