MCPcopy Create free account
hub / github.com/apache/pouchdb / pop

Function pop

lib/index.js:3383–3404  ·  view source on GitHub ↗
(stack, metaStack)

Source from the content-addressed store, hash-verified

3381// move up the stack while parsing
3382// this function moved outside of parseIndexableString for performance
3383function pop(stack, metaStack) {
3384 var obj = stack.pop();
3385
3386 if (metaStack.length) {
3387 var lastMetaElement = metaStack[metaStack.length - 1];
3388 if (obj === lastMetaElement.element) {
3389 // popping a meta-element, e.g. an object whose value is another object
3390 metaStack.pop();
3391 lastMetaElement = metaStack[metaStack.length - 1];
3392 }
3393 var element = lastMetaElement.element;
3394 var lastElementIndex = lastMetaElement.index;
3395 if (Array.isArray(element)) {
3396 element.push(obj);
3397 } else if (lastElementIndex === stack.length - 2) { // obj with key+value
3398 var key = stack.pop();
3399 element[key] = obj;
3400 } else {
3401 stack.push(obj); // obj with key only
3402 }
3403 }
3404}
3405
3406function parseIndexableString(str) {
3407 var stack = [];

Callers 1

parseIndexableStringFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected