MCPcopy Index your code
hub / github.com/apache/pouchdb / parseIndexableString

Function parseIndexableString

lib/index-browser.js:3566–3632  ·  view source on GitHub ↗
(str)

Source from the content-addressed store, hash-verified

3564}
3565
3566function parseIndexableString(str) {
3567 var stack = [];
3568 var metaStack = []; // stack for arrays and objects
3569 var i = 0;
3570
3571 /*eslint no-constant-condition: ["error", { "checkLoops": false }]*/
3572 while (true) {
3573 var collationIndex = str[i++];
3574 if (collationIndex === '\u0000') {
3575 if (stack.length === 1) {
3576 return stack.pop();
3577 } else {
3578 pop(stack, metaStack);
3579 continue;
3580 }
3581 }
3582 switch (collationIndex) {
3583 case '1':
3584 stack.push(null);
3585 break;
3586 case '2':
3587 stack.push(str[i] === '1');
3588 i++;
3589 break;
3590 case '3':
3591 var parsedNum = parseNumber(str, i);
3592 stack.push(parsedNum.num);
3593 i += parsedNum.length;
3594 break;
3595 case '4':
3596 var parsedStr = '';
3597 /*eslint no-constant-condition: ["error", { "checkLoops": false }]*/
3598 while (true) {
3599 var ch = str[i];
3600 if (ch === '\u0000') {
3601 break;
3602 }
3603 parsedStr += ch;
3604 i++;
3605 }
3606 // perform the reverse of the order-preserving replacement
3607 // algorithm (see above)
3608 /* eslint-disable no-control-regex */
3609 parsedStr = parsedStr.replace(/\u0001\u0001/g, '\u0000')
3610 .replace(/\u0001\u0002/g, '\u0001')
3611 .replace(/\u0002\u0002/g, '\u0002');
3612 /* eslint-enable no-control-regex */
3613 stack.push(parsedStr);
3614 break;
3615 case '5':
3616 var arrayElement = { element: [], index: stack.length };
3617 stack.push(arrayElement.element);
3618 metaStack.push(arrayElement);
3619 break;
3620 case '6':
3621 var objElement = { element: {}, index: stack.length };
3622 stack.push(objElement.element);
3623 metaStack.push(objElement);

Callers 1

fetchFromViewFunction · 0.70

Calls 2

popFunction · 0.70
parseNumberFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…