MCPcopy
hub / github.com/microsoft/SandDance / key

Function key

docs/app/js/sanddance-app.js:107023–107046  ·  view source on GitHub ↗
(fields, flat, opt)

Source from the content-addressed store, hash-verified

107021 return typeof _ === "string";
107022}
107023function key(fields, flat, opt) {
107024 if (fields) fields = flat ? array(fields).map((f)=>f.replace(/\\(.)/g, "$1")) : array(fields);
107025 const len = fields && fields.length, gen = opt && opt.get || getter, map = (f)=>gen(flat ? [
107026 f
107027 ] : splitAccessPath(f));
107028 let fn;
107029 if (!len) fn = function() {
107030 return "";
107031 };
107032 else if (len === 1) {
107033 const get = map(fields[0]);
107034 fn = function(_) {
107035 return "" + get(_);
107036 };
107037 } else {
107038 const get = fields.map(map);
107039 fn = function(_) {
107040 let s = "" + get[0](_), i = 0;
107041 while(++i < len)s += "|" + get[i](_);
107042 return s;
107043 };
107044 }
107045 return accessor(fn, fields, "key");
107046}
107047function lerp(array4, frac) {
107048 const lo = array4[0], hi = peek(array4), f = +frac;
107049 return !f ? lo : f === 1 ? hi : lo + f * (hi - lo);

Callers 9

partitionFunction · 0.70
getFunction · 0.70
pivotKeysFunction · 0.70
groupFunction · 0.70
newMapFunction · 0.70
transformFunction · 0.70
lookupFunction · 0.70
applyFunction · 0.70
insertFunction · 0.70

Calls 5

replaceMethod · 0.80
arrayFunction · 0.70
mapFunction · 0.70
getFunction · 0.70
accessorFunction · 0.70

Tested by

no test coverage detected