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

Function changeset

docs/app/js/sanddance-app.js:107275–107386  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

107273 return v && v.constructor === changeset;
107274}
107275function changeset() {
107276 const add1 = [], // insert tuples
107277 rem = [], // remove tuples
107278 mod = [], // modify tuples
107279 remp = [], // remove by predicate
107280 modp = []; // modify by predicate
107281 let clean = null, reflow = false;
107282 return {
107283 constructor: changeset,
107284 insert (t) {
107285 const d = (0, _vegaUtil.array)(t), n = d.length;
107286 for(let i = 0; i < n; ++i)add1.push(d[i]);
107287 return this;
107288 },
107289 remove (t) {
107290 const a = (0, _vegaUtil.isFunction)(t) ? remp : rem, d = (0, _vegaUtil.array)(t), n = d.length;
107291 for(let i = 0; i < n; ++i)a.push(d[i]);
107292 return this;
107293 },
107294 modify (t, field, value) {
107295 const m = {
107296 field: field,
107297 value: (0, _vegaUtil.constant)(value)
107298 };
107299 if ((0, _vegaUtil.isFunction)(t)) {
107300 m.filter = t;
107301 modp.push(m);
107302 } else {
107303 m.tuple = t;
107304 mod.push(m);
107305 }
107306 return this;
107307 },
107308 encode (t, set) {
107309 if ((0, _vegaUtil.isFunction)(t)) modp.push({
107310 filter: t,
107311 field: set
107312 });
107313 else mod.push({
107314 tuple: t,
107315 field: set
107316 });
107317 return this;
107318 },
107319 clean (value) {
107320 clean = value;
107321 return this;
107322 },
107323 reflow () {
107324 reflow = true;
107325 return this;
107326 },
107327 pulse (pulse1, tuples) {
107328 const cur = {}, out = {};
107329 let i, n, m, f1, t1, id; // build lookup table of current tuples
107330 for(i = 0, n = tuples.length; i < n; ++i)cur[tupleid(tuples[i])] = 1;
107331 // process individual tuples to remove
107332 for(i = 0, n = rem.length; i < n; ++i){

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected