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

Function splitAccessPath

docs/app/js/sanddance-app.js:106528–106574  ·  view source on GitHub ↗
(p)

Source from the content-addressed store, hash-verified

106526 throw Error(message);
106527}
106528function splitAccessPath(p) {
106529 const path = [], n = p.length;
106530 let q = null, b = 0, s = "", i, j, c;
106531 p = p + "";
106532 function push() {
106533 path.push(s + p.substring(i, j));
106534 s = "";
106535 i = j + 1;
106536 }
106537 for(i = j = 0; j < n; ++j){
106538 c = p[j];
106539 if (c === "\\") {
106540 s += p.substring(i, j);
106541 s += p.substring(++j, ++j);
106542 i = j;
106543 } else if (c === q) {
106544 push();
106545 q = null;
106546 b = -1;
106547 } else if (q) continue;
106548 else if (i === b && c === '"') {
106549 i = j + 1;
106550 q = c;
106551 } else if (i === b && c === "'") {
106552 i = j + 1;
106553 q = c;
106554 } else if (c === "." && !b) {
106555 if (j > i) push();
106556 else i = j + 1;
106557 } else if (c === "[") {
106558 if (j > i) push();
106559 b = i = j + 1;
106560 } else if (c === "]") {
106561 if (!b) error("Access path missing open bracket: " + p);
106562 if (b > 0) push();
106563 b = 0;
106564 i = j + 1;
106565 }
106566 }
106567 if (b) error("Access path missing closing bracket: " + p);
106568 if (q) error("Access path missing closing quote: " + p);
106569 if (j > i) {
106570 j++;
106571 push();
106572 }
106573 return path;
106574}
106575function field(field2, name, opt) {
106576 const path = splitAccessPath(field2);
106577 field2 = path.length === 1 ? path[0] : field2;

Callers 2

fieldFunction · 0.70
mapFunction · 0.70

Calls 2

pushFunction · 0.70
errorFunction · 0.70

Tested by

no test coverage detected