MCPcopy Create free account
hub / github.com/microsoft/SandDance / cache

Function cache

docs/tests/v2/es6/js/sanddance.js:135647–135676  ·  view source on GitHub ↗
(scope, ds, name, optype, field, counts, index)

Source from the content-addressed store, hash-verified

135645}
135646
135647function cache(scope, ds, name, optype, field, counts, index) {
135648 var cache = ds[name] || (ds[name] = {}),
135649 sort = (0, _util.sortKey)(counts),
135650 k = fieldKey(field),
135651 v,
135652 op;
135653
135654 if (k != null) {
135655 scope = ds.scope;
135656 k = k + (sort ? '|' + sort : '');
135657 v = cache[k];
135658 }
135659
135660 if (!v) {
135661 var params = counts ? {
135662 field: _util.keyFieldRef,
135663 pulse: ds.countsRef(scope, field, counts)
135664 } : {
135665 field: scope.fieldRef(field),
135666 pulse: (0, _util.ref)(ds.output)
135667 };
135668 if (sort) params.sort = scope.sortRef(counts);
135669 op = scope.add((0, _util.entry)(optype, undefined, params));
135670 if (index) ds.index[field] = op;
135671 v = (0, _util.ref)(op);
135672 if (k != null) cache[k] = v;
135673 }
135674
135675 return v;
135676}
135677
135678prototype.tuplesRef = function () {
135679 return (0, _util.ref)(this.values);

Callers 1

sanddance.jsFile · 0.70

Calls 2

fieldKeyFunction · 0.70
addMethod · 0.45

Tested by

no test coverage detected