MCPcopy Index your code
hub / github.com/microsoft/SandDance / UniqueList

Function UniqueList

docs/app/js/sanddance-app.js:107165–107185  ·  view source on GitHub ↗
(idFunc)

Source from the content-addressed store, hash-verified

107163var _vegaLoader = require("vega-loader");
107164var _vegaFormat = require("vega-format");
107165function UniqueList(idFunc) {
107166 const $ = idFunc || (0, _vegaUtil.identity), list = [], ids = {};
107167 list.add = (_)=>{
107168 const id = $(_);
107169 if (!ids[id]) {
107170 ids[id] = 1;
107171 list.push(_);
107172 }
107173 return list;
107174 };
107175 list.remove = (_)=>{
107176 const id = $(_);
107177 if (ids[id]) {
107178 ids[id] = 0;
107179 const idx = list.indexOf(_);
107180 if (idx >= 0) list.splice(idx, 1);
107181 }
107182 return list;
107183 };
107184 return list;
107185}
107186/**
107187 * Invoke and await a potentially async callback function. If
107188 * an error occurs, trap it and route to Dataflow.error.

Callers 3

targetsFunction · 0.70
evaluateFunction · 0.70
DataflowFunction · 0.70

Calls 1

$Function · 0.70

Tested by

no test coverage detected