mol_text_distance 0.0.1103 → 0.0.1105

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 CHANGED
@@ -1714,18 +1714,42 @@ var $;
1714
1714
  factories.set(val, make);
1715
1715
  return make;
1716
1716
  }
1717
+ const getters = new WeakMap();
1718
+ function get_prop(host, field) {
1719
+ let props = getters.get(host);
1720
+ let get_val = props?.[field];
1721
+ if (get_val)
1722
+ return get_val;
1723
+ get_val = (next) => {
1724
+ if (next !== undefined)
1725
+ host[field] = next;
1726
+ return host[field];
1727
+ };
1728
+ Object.defineProperty(get_val, 'name', { value: field });
1729
+ if (!props) {
1730
+ props = {};
1731
+ getters.set(host, props);
1732
+ }
1733
+ props[field] = get_val;
1734
+ return get_val;
1735
+ }
1717
1736
  function $mol_wire_sync(obj) {
1718
1737
  return new Proxy(obj, {
1719
1738
  get(obj, field) {
1720
1739
  let val = obj[field];
1740
+ const temp = $mol_wire_task.getter(typeof val === 'function' ? val : get_prop(obj, field));
1721
1741
  if (typeof val !== 'function')
1722
- return val;
1723
- const temp = $mol_wire_task.getter(val);
1742
+ return temp(obj, []).sync();
1724
1743
  return function $mol_wire_sync(...args) {
1725
1744
  const fiber = temp(obj, args);
1726
1745
  return fiber.sync();
1727
1746
  };
1728
1747
  },
1748
+ set(obj, field, next) {
1749
+ const temp = $mol_wire_task.getter(get_prop(obj, field));
1750
+ temp(obj, [next]).sync();
1751
+ return true;
1752
+ },
1729
1753
  construct(obj, args) {
1730
1754
  const temp = $mol_wire_task.getter(factory(obj));
1731
1755
  return temp(obj, args).sync();