@expressive/mvc 0.7.0 → 0.7.1

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/lib/index.js CHANGED
@@ -806,18 +806,24 @@ function get(arg0, arg1, arg2) {
806
806
  });
807
807
  }
808
808
 
809
- function ref(arg) {
809
+ function ref(arg, mapper) {
810
810
  return apply(function ref(key) {
811
811
  let value = {};
812
- if (typeof arg == "object") {
813
- const source = ensure(arg);
814
- for (const key of source.state.keys())
815
- defineProperty(value, key, {
812
+ if (typeof arg != "object")
813
+ value = createRef(this, key, arg);
814
+ else
815
+ ensure(arg).state.forEach((_val, key) => {
816
+ defineProperty(value, key, mapper ? {
817
+ configurable: true,
818
+ get() {
819
+ const out = mapper(key);
820
+ defineProperty(value, key, { value: out });
821
+ return out;
822
+ }
823
+ } : {
816
824
  value: createRef(this, key)
817
825
  });
818
- }
819
- else
820
- value = createRef(this, key, arg);
826
+ });
821
827
  return { value, explicit: true };
822
828
  });
823
829
  }