gson-query
Advanced tools
Comparing version 4.2.0 to 4.3.0
@@ -1,3 +0,3 @@ | ||
!function(r){var t={};function o(e){if(t[e])return t[e].exports;var n=t[e]={i:e,l:!1,exports:{}};return r[e].call(n.exports,n,n.exports,o),n.l=!0,n.exports}o.m=r,o.c=t,o.d=function(e,n,r){o.o(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:r})},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.t=function(n,e){if(1&e&&(n=o(n)),8&e)return n;if(4&e&&"object"==typeof n&&n&&n.__esModule)return n;var r=Object.create(null);if(o.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:n}),2&e&&"string"!=typeof n)for(var t in n)o.d(r,t,function(e){return n[e]}.bind(null,t));return r},o.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(n,"a",n),n},o.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},o.p="",o(o.s=7)}([function(e,n,r){"use strict";var i=r(2),t=/~1/g,o=/~0/g,u=/\/+/g,a=/(^[#/]*|\/+$)/g;function c(e){return e.replace(t,"/").replace(o,"~")}function f(e){return c(decodeURIComponent(e))}e.exports=function(e){if(null==e||"string"!=typeof e||i(e))return Array.isArray(e)?e:[];for(var n=0<=e.indexOf("#")?f:c,r=(e=(e=e.replace(u,"/")).replace(a,"")).split("/"),t=0,o=r.length;t<o;t+=1)r[t]=n(r[t]);return r}},function(e,n){e.exports={VALUE_INDEX:0,KEY_INDEX:1,PARENT_INDEX:2,POINTER_INDEX:3}},function(e,n){e.exports=function(e){return"#"===e||""===e}},function(e,n,r){function i(e){return function(e){if(Array.isArray(e)){for(var n=0,r=new Array(e.length);n<e.length;n++)r[n]=e[n];return r}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}var u=r(8).parse,t=r(14),a=t.run,o=t.VALUE_INDEX,c=t.POINTER_INDEX,f={value:function(e){return e.map(function(e){return e[o]})},pointer:function(e){return e.map(function(e){return e[c]})},all:function(e){return e},map:function(e){var n={};return e.forEach(function(e){return n[e[c]]=e[o]}),n}};function l(e,n){var r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:"value";if(null==n)return[];""===(n=n.replace(/(\/$)/g,""))&&(n="#");var t=u(n);if(null==t)throw new Error("empty ast for '".concat(n,"'"));if(""!==t.rest)throw new Error("Failed parsing queryString from: '".concat(t.rest,"'"));var o=a(e,t);return f[r]?f[r](o):"function"==typeof r?o.map(function(e){return r.apply(void 0,i(e))}):o}Object.keys(f).forEach(function(e){return l[e.toUpperCase()]=e}),e.exports=l},function(e,n,r){"use strict";e.exports=function(n,r){Array.isArray(n)?n.forEach(r):"[object Object]"===Object.prototype.toString.call(n)&&Object.keys(n).forEach(function(e){r(n[e],e,n)})}},function(e,n,r){"use strict";var o=r(0),i=r(2);e.exports=function(e,n,r){if(null==n||null==e)return r;if(i(n))return e;var t=function e(n,r){var t=r.shift();{if(void 0===n)return;if(void 0!==t)return e(n[t],r)}return n}(e,o(n));return void 0===t?r:t}},function(e,n,r){"use strict";e.exports=function(e){for(var n=0,r=0;n+r<e.length;)void 0===e[n+r]&&(r+=1),e[n]=e[n+r],n+=1;return e.length=e.length-r,e}},function(e,n,r){n.get=r(3),n.remove=r(21)},function(e,n,r){var t=r(9).default,o=r(13).enbf,i=/(children|text|type|start|end|rest|errors|fullText|\d+)/,u=/(children|text|type|\d+)/,a=new t.Parser(o);e.exports={parse:function(e){return a.getAST(e)},reduce:function(e){return JSON.parse(function(e){return JSON.stringify(e,function(e,n){return""===e||"rest"===e&&""!==n||u.test(e)?n:void 0},2)}(e))},toJSON:function(e){return JSON.stringify(e,function(e,n){return""===e||i.test(e)?n:void 0},2)}}},function(e,n,r){"use strict";function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function h(e,n){for(var r=0;r<n.length;r++){var t=n[r];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(e,t.key,t)}}function m(e,n){return!n||"object"!==t(n)&&"function"!=typeof n?function(e){if(void 0!==e)return e;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}(e):n}function d(e){return(d=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function g(e,n){return(g=Object.setPrototypeOf||function(e,n){return e.__proto__=n,e})(e,n)}Object.defineProperty(n,"__esModule",{value:!0});var o,v=r(10);!function(t){t.RULES=[{name:"Grammar",bnf:[["RULE_S*","%Atomic*","EOF"]]},{name:"%Atomic",bnf:[["Production","RULE_S*"]],fragment:!0},{name:"Production",bnf:[["NCName","RULE_S*",'"::="',"RULE_WHITESPACE*","Choice","RULE_WHITESPACE*","RULE_EOL+","RULE_S*"]]},{name:"NCName",bnf:[[/[a-zA-Z][a-zA-Z_0-9]*/]]},{name:"Choice",bnf:[["SequenceOrDifference","%_Choice_1*"]],fragment:!0},{name:"%_Choice_1",bnf:[["RULE_WHITESPACE*",'"|"',"RULE_WHITESPACE*","SequenceOrDifference"]],fragment:!0},{name:"SequenceOrDifference",bnf:[["Item","RULE_WHITESPACE*","%_Item_1?"]]},{name:"%_Item_1",bnf:[["Minus","Item"],["Item*"]],fragment:!0},{name:"Minus",bnf:[['"-"']]},{name:"Item",bnf:[["RULE_WHITESPACE*","%Primary","PrimaryDecoration?"]],fragment:!0},{name:"PrimaryDecoration",bnf:[['"?"'],['"*"'],['"+"']]},{name:"DecorationName",bnf:[['"ebnf://"',/[^\x5D#]+/]]},{name:"%Primary",bnf:[["NCName"],["StringLiteral"],["CharCode"],["CharClass"],["SubItem"]],fragment:!0},{name:"SubItem",bnf:[['"("',"RULE_WHITESPACE*","Choice","RULE_WHITESPACE*",'")"']]},{name:"StringLiteral",bnf:[["'\"'",/[^"]*/,"'\"'"],['"\'"',/[^']*/,'"\'"']],pinned:1},{name:"CharCode",bnf:[['"#x"',/[0-9a-zA-Z]+/]]},{name:"CharClass",bnf:[["'['","'^'?","%RULE_CharClass_1+",'"]"']]},{name:"%RULE_CharClass_1",bnf:[["CharCodeRange"],["CharRange"],["CharCode"],["RULE_Char"]],fragment:!0},{name:"RULE_Char",bnf:[[/\x09/],[/\x0A/],[/\x0D/],[/[\x20-\x5c]/],[/[\x5e-\uD7FF]/],[/[\uE000-\uFFFD]/]]},{name:"CharRange",bnf:[["RULE_Char",'"-"',"RULE_Char"]]},{name:"CharCodeRange",bnf:[["CharCode",'"-"',"CharCode"]]},{name:"RULE_WHITESPACE",bnf:[["%RULE_WHITESPACE_CHAR*"],["Comment","RULE_WHITESPACE*"]]},{name:"RULE_S",bnf:[["RULE_WHITESPACE","RULE_S*"],["RULE_EOL","RULE_S*"]]},{name:"%RULE_WHITESPACE_CHAR",bnf:[[/\x09/],[/\x20/]],fragment:!0},{name:"Comment",bnf:[['"/*"',"%RULE_Comment_Body*",'"*/"']]},{name:"%RULE_Comment_Body",bnf:[['!"*/"',/[^*]/]],fragment:!0},{name:"RULE_EOL",bnf:[[/\x0D/,/\x0A/],[/\x0A/],[/\x0D/]]},{name:"Link",bnf:[["'['","Url","']'"]]},{name:"Url",bnf:[[/[^\x5D:/?#]/,'"://"',/[^\x5D#]+/,"%Url1?"]]},{name:"%Url1",bnf:[['"#"',"NCName"]],fragment:!0}],t.parser=new v.Parser(t.RULES,{});var o=/^(!|&)/,i=/(\?|\+|\*)$/,u=/^%/;function a(e,n){if("string"!=typeof e)return e.source.replace(/\\(?:x|u)([a-zA-Z0-9]+)/g,"#x$1").replace(/\[\\(?:x|u)([a-zA-Z0-9]+)-\\(?:x|u)([a-zA-Z0-9]+)\]/g,"[#x$1-#x$2]");if(o.test(e))return"";if(u.test(e)){var r=i.exec(e),t=r?r[0]+" ":"";return function(e,n){var r=v.findRuleByName(e,n);return r&&1==r.bnf.length&&1==r.bnf[0].length&&(r.bnf[0][0]instanceof RegExp||'"'==r.bnf[0][0][0]||"'"==r.bnf[0][0][0])}(e,n)?c(e,n)+t:"("+c(e,n)+")"+t}return e}function c(e,n){var r=v.findRuleByName(e,n);return r?r.bnf.map(function(e){return function(e,n){return e.map(function(e){return a(e,n)}).join(" ")}(e,n)}).join(" | "):"RULE_NOT_FOUND {"+e+"}"}function e(r){var t=[];return r.grammarRules.forEach(function(e){if(!/^%/.test(e.name)){var n=e.recover?" /* { recoverUntil="+e.recover+" } */":"";t.push(e.name+" ::= "+c(e.name,r)+n)}}),t.join("\n")}t.emit=e;var l=0;function s(e){return new RegExp(e.replace(/#x([a-zA-Z0-9]{4})/g,"\\u$1").replace(/#x([a-zA-Z0-9]{3})/g,"\\u0$1").replace(/#x([a-zA-Z0-9]{2})/g,"\\x$1").replace(/#x([a-zA-Z0-9]{1})/g,"\\x0$1"))}function f(i,u,a){var c=null,f=[];return u.children.forEach(function(e,n){"Minus"==e.type&&function(e,n){throw console.log("reberia restar "+n+" a "+e),new Error("Difference not supported yet")}(c,e);var r=u.children[n+1];r=r&&"PrimaryDecoration"==r.type&&r.text||"";switch(e.type){case"SubItem":var t="%"+(a+l++);p(i,e,t),f.push(t+r);break;case"NCName":case"StringLiteral":f.push(""+e.text+r);break;case"CharCode":case"CharClass":if(r){var o={name:"%"+(a+l++),bnf:[[s(e.text)]]};i.push(o),f.push(""+o.name+r)}else f.push(s(e.text));break;case"PrimaryDecoration":break;default:throw new Error(" HOW SHOULD I PARSE THIS? "+e.type+" -> "+JSON.stringify(e.text))}c=e}),f}function p(n,e,r){var t=e.children.filter(function(e){return"SequenceOrDifference"==e.type}).map(function(e){return f(n,e,r)}),o={name:r,bnf:t},i=null;t.forEach(function(e){i=i||e.recover,delete e.recover}),0==r.indexOf("%")&&(o.fragment=!0),i&&(o.recover=i),n.push(o)}function y(e){var n=t.parser.getAST(e);if(!n)throw new Error("Could not parse "+e);if(n.errors&&n.errors.length)throw n.errors[0];var r=[];return n.children.filter(function(e){return"Production"==e.type}).map(function(e){var n=e.children.filter(function(e){return"NCName"==e.type})[0].text;p(r,e,n)}),r}t.getRules=y,t.Transform=function(e){return y(e.join(""))};var n=function(){function r(e,n){return function(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}(this,r),m(this,d(r).call(this,y(e),n))}return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(n&&n.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),n&&g(e,n)}(r,v.Parser),function(e,n,r){n&&h(e.prototype,n),r&&h(e,r)}(r,[{key:"emitSource",value:function(){return e(this)}}]),r}();t.Parser=n}(o=o||{}),n.default=o},function(e,n,r){"use strict";(function(a){function t(e,n){for(var r=0;r<n.length;r++){var t=n[r];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(e,t.key,t)}}Object.defineProperty(n,"__esModule",{value:!0});var c=/^[A-Z0-9_]+$/,u=/(\?|\+|\*)$/,f=/^(@|&|!)/,b=r(12);function x(e,n){var r=n.exec(e);return r&&0==r.index?0==r[0].length&&0<n.source.length?null:{type:null,text:r[0],rest:e.substr(r[0].length),start:0,end:r[0].length-1,fullText:r[0],errors:[],children:[],parent:null}:null}function S(e){var n=u.exec(e),r=f.exec(e),t=n&&n[0]||"",o=r&&r[0]||"",i={raw:e,name:e.replace(u,"").replace(f,""),isOptional:"?"==t||"*"==t,allowRepetition:"+"==t||"*"==t,atLeastOne:"+"==t,lookupPositive:"&"==o,lookupNegative:"!"==o,pinned:"@"==o,lookup:!1,isLiteral:!1};return i.isLiteral="'"==i.name[0]||'"'==i.name[0],i.lookup=i.lookupNegative||i.lookupPositive,i}function l(e,n){var r=S(e);return n.cachedRules[r.name]||null}function i(e,n){if(e.children){for(var r=e.children.filter(function(e){return e.type&&n.test(e.type)}),t=0;t<r.length;t++){var o=e.children.indexOf(r[t]);-1!=o&&e.children.splice(o,1)}e.children.forEach(function(e){return i(e,n)})}}n.readToken=x,n.parseRuleName=S,n.findRuleByName=l;var s=["EOF"],e=function(){function r(e,n){var t=this;!function(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}(this,r),this.grammarRules=e,this.options=n,this.debug=!1,this.cachedRules={};var o=[],i=[];if(e.forEach(function(r){var e=S(r.name);if(e.name in t.cachedRules)o.push("Duplicated rule "+e.name);else{if((t.cachedRules[e.name]=r).bnf&&r.bnf.length)r.bnf.forEach(function(e){if("string"==typeof e[0]&&S(e[0]).name==r.name){var n="Left recursion is not allowed, rule: "+r.name;-1==o.indexOf(n)&&o.push(n)}e.forEach(function(e){if("string"==typeof e){var n=S(e);n.isLiteral||-1!=i.indexOf(n.name)||-1!=s.indexOf(n.name)||i.push(n.name)}})});else{var n="Missing rule content, rule: "+r.name;-1==o.indexOf(n)&&o.push(n)}"WS"==r.name&&(r.implicitWs=!1),r.implicitWs&&-1==i.indexOf("WS")&&i.push("WS"),r.recover&&-1==i.indexOf(r.recover)&&i.push(r.recover)}}),i.forEach(function(e){e in t.cachedRules||o.push("Missing rule "+e)}),o.length)throw new Error(o.join("\n"))}return function(e,n,r){n&&t(e.prototype,n),r&&t(e,r)}(r,[{key:"getAST",value:function(e,n){n=n||this.grammarRules.filter(function(e){return!e.fragment&&0!=e.name.indexOf("%")})[0].name;var r=this.parse(e,n);if(r){!function n(r,e){e.errors&&e.errors.length&&e.errors.forEach(function(e){return r.push(e)}),e.children&&e.children.forEach(function(e){return n(r,e)})}(r.errors,r),function n(r,e){r.start+=e,r.end+=e,r.children&&r.children.forEach(function(e){return n(e,r.start)})}(r,0),i(r,/^%/),this.options&&this.options.keepUpperRules||i(r,c);var t=r.rest;t&&new b.TokenError("Unexpected end of input: \n"+t,r),function n(e){e.rest="",e.children&&e.children.forEach(function(e){return n(e)})}(r),r.rest=t}return r}},{key:"emitSource",value:function(){return"CANNOT EMIT SOURCE FROM BASE Parser"}},{key:"parse",value:function(y,e,n){var r,h=this,m=2<arguments.length&&void 0!==n?n:0,d=null,g=S(e),v=this.debug&& | ||
!function(r){var t={};function o(e){if(t[e])return t[e].exports;var n=t[e]={i:e,l:!1,exports:{}};return r[e].call(n.exports,n,n.exports,o),n.l=!0,n.exports}o.m=r,o.c=t,o.d=function(e,n,r){o.o(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:r})},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.t=function(n,e){if(1&e&&(n=o(n)),8&e)return n;if(4&e&&"object"==typeof n&&n&&n.__esModule)return n;var r=Object.create(null);if(o.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:n}),2&e&&"string"!=typeof n)for(var t in n)o.d(r,t,function(e){return n[e]}.bind(null,t));return r},o.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(n,"a",n),n},o.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},o.p="",o(o.s=10)}([function(e,n,r){"use strict";var i=r(3),t=/~1/g,o=/~0/g,u=/\/+/g,a=/(^[#/]*|\/+$)/g;function c(e){return e.replace(t,"/").replace(o,"~")}function f(e){return c(decodeURIComponent(e))}e.exports=function(e){if(null==e||"string"!=typeof e||i(e))return Array.isArray(e)?e:[];for(var n=0<=e.indexOf("#")?f:c,r=(e=(e=e.replace(u,"/")).replace(a,"")).split("/"),t=0,o=r.length;t<o;t+=1)r[t]=n(r[t]);return r}},function(e,n,r){function i(e){return function(e){if(Array.isArray(e)){for(var n=0,r=new Array(e.length);n<e.length;n++)r[n]=e[n];return r}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}var u=r(4).parse,t=r(15),a=t.run,o=t.VALUE_INDEX,c=t.POINTER_INDEX,f={value:function(e){return e.map(function(e){return e[o]})},pointer:function(e){return e.map(function(e){return e[c]})},all:function(e){return e},map:function(e){var n={};return e.forEach(function(e){return n[e[c]]=e[o]}),n}};function l(e,n){var r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:"value";if(null==n)return[];""===(n=n.replace(/(\/$)/g,""))&&(n="#");var t=u(n);if(null==t)throw new Error("empty ast for '".concat(n,"'"));if(""!==t.rest)throw new Error("Failed parsing queryString from: '".concat(t.rest,"'"));var o=a(e,t);return f[r]?f[r](o):"function"==typeof r?o.map(function(e){return r.apply(void 0,i(e))}):o}Object.keys(f).forEach(function(e){return l[e.toUpperCase()]=e}),e.exports=l},function(e,n){e.exports={VALUE_INDEX:0,KEY_INDEX:1,PARENT_INDEX:2,POINTER_INDEX:3}},function(e,n){e.exports=function(e){return"#"===e||""===e}},function(e,n,r){var t=r(11).default,o=r(5).enbf,i=/(children|text|type|start|end|rest|errors|fullText|\d+)/,u=/(children|text|type|\d+)/,a=new t.Parser(o);e.exports={parse:function(e){return a.getAST(e)},reduce:function(e){return JSON.parse(function(e){return JSON.stringify(e,function(e,n){return""===e||"rest"===e&&""!==n||u.test(e)?n:void 0},2)}(e))},toJSON:function(e){return JSON.stringify(e,function(e,n){return""===e||i.test(e)?n:void 0},2)}}},function(e,n){var r="[^?/{}*,()#]+",t='\nroot ::= ("#" recursion | recursion | (query | pattern) recursion* | "#" SEP? | SEP)\nrecursion ::= (SEP query | pattern)*\n\nquery ::= (ESC escaped ESC | property | all | any | regex) typecheck? lookahead?\nproperty ::= '.concat(r,'\nregex ::= "{" [^}]+ "}"\nSEP ::= "/"\nall ::= "**"\nany ::= "*"\n\ntypecheck ::= "?:" ("value" | "boolean" | "string" | "number" | "object" | "array")\nlookahead ::= "?" expression ((andExpr | orExpr) expression)*\nandExpr ::= S? "&&" S?\norExpr ::= S? "||" S?\n\nexpression ::= (exprProperty | ESC escaped ESC) ((isnot | is) (exprProperty | regex | ESC escaped ESC))*\nexprProperty ::= [a-zA-Z0-9-_ $]+\nescaped ::= [^"]+\nis ::= ":"\nisnot ::= ":!"\nESC ::= \'"\'\n\npattern ::= S? "(" (SEP query | pattern (orPattern? pattern)*)* ")" quantifier? S? lookahead?\nquantifier ::= "+" | "*" | [0-9]+\norPattern ::= S? "," S?\n\nS ::= [ ]*\n');e.exports={enbf:t,propertyRegex:r}},function(e,n,r){"use strict";e.exports=function(n,r){Array.isArray(n)?n.forEach(r):"[object Object]"===Object.prototype.toString.call(n)&&Object.keys(n).forEach(function(e){r(n[e],e,n)})}},function(e,n,r){var t=r(4).parse,o=["root","recursion"];e.exports=function(e){return null==e||""===e?[]:function n(e,r){var t=1<arguments.length&&void 0!==r?r:[];return o.includes(e.type)?e.children.forEach(function(e){return n(e,t)}):t.push(e.text),t}(t(e))}},function(e,n,r){"use strict";var o=r(0),i=r(3);e.exports=function(e,n,r){if(null==n||null==e)return r;if(i(n))return e;var t=function e(n,r){var t=r.shift();{if(void 0===n)return;if(void 0!==t)return e(n[t],r)}return n}(e,o(n));return void 0===t?r:t}},function(e,n,r){"use strict";e.exports=function(e){for(var n=0,r=0;n+r<e.length;)void 0===e[n+r]&&(r+=1),e[n]=e[n+r],n+=1;return e.length=e.length-r,e}},function(e,n,r){n.get=r(1),n.set=r(22),n.split=r(7),n.remove=r(23)},function(e,n,r){"use strict";function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function h(e,n){for(var r=0;r<n.length;r++){var t=n[r];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(e,t.key,t)}}function m(e,n){return!n||"object"!==t(n)&&"function"!=typeof n?function(e){if(void 0!==e)return e;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}(e):n}function d(e){return(d=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function g(e,n){return(g=Object.setPrototypeOf||function(e,n){return e.__proto__=n,e})(e,n)}Object.defineProperty(n,"__esModule",{value:!0});var o,v=r(12);!function(t){t.RULES=[{name:"Grammar",bnf:[["RULE_S*","%Atomic*","EOF"]]},{name:"%Atomic",bnf:[["Production","RULE_S*"]],fragment:!0},{name:"Production",bnf:[["NCName","RULE_S*",'"::="',"RULE_WHITESPACE*","Choice","RULE_WHITESPACE*","RULE_EOL+","RULE_S*"]]},{name:"NCName",bnf:[[/[a-zA-Z][a-zA-Z_0-9]*/]]},{name:"Choice",bnf:[["SequenceOrDifference","%_Choice_1*"]],fragment:!0},{name:"%_Choice_1",bnf:[["RULE_WHITESPACE*",'"|"',"RULE_WHITESPACE*","SequenceOrDifference"]],fragment:!0},{name:"SequenceOrDifference",bnf:[["Item","RULE_WHITESPACE*","%_Item_1?"]]},{name:"%_Item_1",bnf:[["Minus","Item"],["Item*"]],fragment:!0},{name:"Minus",bnf:[['"-"']]},{name:"Item",bnf:[["RULE_WHITESPACE*","%Primary","PrimaryDecoration?"]],fragment:!0},{name:"PrimaryDecoration",bnf:[['"?"'],['"*"'],['"+"']]},{name:"DecorationName",bnf:[['"ebnf://"',/[^\x5D#]+/]]},{name:"%Primary",bnf:[["NCName"],["StringLiteral"],["CharCode"],["CharClass"],["SubItem"]],fragment:!0},{name:"SubItem",bnf:[['"("',"RULE_WHITESPACE*","Choice","RULE_WHITESPACE*",'")"']]},{name:"StringLiteral",bnf:[["'\"'",/[^"]*/,"'\"'"],['"\'"',/[^']*/,'"\'"']],pinned:1},{name:"CharCode",bnf:[['"#x"',/[0-9a-zA-Z]+/]]},{name:"CharClass",bnf:[["'['","'^'?","%RULE_CharClass_1+",'"]"']]},{name:"%RULE_CharClass_1",bnf:[["CharCodeRange"],["CharRange"],["CharCode"],["RULE_Char"]],fragment:!0},{name:"RULE_Char",bnf:[[/\x09/],[/\x0A/],[/\x0D/],[/[\x20-\x5c]/],[/[\x5e-\uD7FF]/],[/[\uE000-\uFFFD]/]]},{name:"CharRange",bnf:[["RULE_Char",'"-"',"RULE_Char"]]},{name:"CharCodeRange",bnf:[["CharCode",'"-"',"CharCode"]]},{name:"RULE_WHITESPACE",bnf:[["%RULE_WHITESPACE_CHAR*"],["Comment","RULE_WHITESPACE*"]]},{name:"RULE_S",bnf:[["RULE_WHITESPACE","RULE_S*"],["RULE_EOL","RULE_S*"]]},{name:"%RULE_WHITESPACE_CHAR",bnf:[[/\x09/],[/\x20/]],fragment:!0},{name:"Comment",bnf:[['"/*"',"%RULE_Comment_Body*",'"*/"']]},{name:"%RULE_Comment_Body",bnf:[['!"*/"',/[^*]/]],fragment:!0},{name:"RULE_EOL",bnf:[[/\x0D/,/\x0A/],[/\x0A/],[/\x0D/]]},{name:"Link",bnf:[["'['","Url","']'"]]},{name:"Url",bnf:[[/[^\x5D:/?#]/,'"://"',/[^\x5D#]+/,"%Url1?"]]},{name:"%Url1",bnf:[['"#"',"NCName"]],fragment:!0}],t.parser=new v.Parser(t.RULES,{});var o=/^(!|&)/,i=/(\?|\+|\*)$/,u=/^%/;function a(e,n){if("string"!=typeof e)return e.source.replace(/\\(?:x|u)([a-zA-Z0-9]+)/g,"#x$1").replace(/\[\\(?:x|u)([a-zA-Z0-9]+)-\\(?:x|u)([a-zA-Z0-9]+)\]/g,"[#x$1-#x$2]");if(o.test(e))return"";if(u.test(e)){var r=i.exec(e),t=r?r[0]+" ":"";return function(e,n){var r=v.findRuleByName(e,n);return r&&1==r.bnf.length&&1==r.bnf[0].length&&(r.bnf[0][0]instanceof RegExp||'"'==r.bnf[0][0][0]||"'"==r.bnf[0][0][0])}(e,n)?c(e,n)+t:"("+c(e,n)+")"+t}return e}function c(e,n){var r=v.findRuleByName(e,n);return r?r.bnf.map(function(e){return function(e,n){return e.map(function(e){return a(e,n)}).join(" ")}(e,n)}).join(" | "):"RULE_NOT_FOUND {"+e+"}"}function e(r){var t=[];return r.grammarRules.forEach(function(e){if(!/^%/.test(e.name)){var n=e.recover?" /* { recoverUntil="+e.recover+" } */":"";t.push(e.name+" ::= "+c(e.name,r)+n)}}),t.join("\n")}t.emit=e;var l=0;function s(e){return new RegExp(e.replace(/#x([a-zA-Z0-9]{4})/g,"\\u$1").replace(/#x([a-zA-Z0-9]{3})/g,"\\u0$1").replace(/#x([a-zA-Z0-9]{2})/g,"\\x$1").replace(/#x([a-zA-Z0-9]{1})/g,"\\x0$1"))}function f(i,u,a){var c=null,f=[];return u.children.forEach(function(e,n){"Minus"==e.type&&function(e,n){throw console.log("reberia restar "+n+" a "+e),new Error("Difference not supported yet")}(c,e);var r=u.children[n+1];r=r&&"PrimaryDecoration"==r.type&&r.text||"";switch(e.type){case"SubItem":var t="%"+(a+l++);p(i,e,t),f.push(t+r);break;case"NCName":case"StringLiteral":f.push(""+e.text+r);break;case"CharCode":case"CharClass":if(r){var o={name:"%"+(a+l++),bnf:[[s(e.text)]]};i.push(o),f.push(""+o.name+r)}else f.push(s(e.text));break;case"PrimaryDecoration":break;default:throw new Error(" HOW SHOULD I PARSE THIS? "+e.type+" -> "+JSON.stringify(e.text))}c=e}),f}function p(n,e,r){var t=e.children.filter(function(e){return"SequenceOrDifference"==e.type}).map(function(e){return f(n,e,r)}),o={name:r,bnf:t},i=null;t.forEach(function(e){i=i||e.recover,delete e.recover}),0==r.indexOf("%")&&(o.fragment=!0),i&&(o.recover=i),n.push(o)}function y(e){var n=t.parser.getAST(e);if(!n)throw new Error("Could not parse "+e);if(n.errors&&n.errors.length)throw n.errors[0];var r=[];return n.children.filter(function(e){return"Production"==e.type}).map(function(e){var n=e.children.filter(function(e){return"NCName"==e.type})[0].text;p(r,e,n)}),r}t.getRules=y,t.Transform=function(e){return y(e.join(""))};var n=function(){function r(e,n){return function(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}(this,r),m(this,d(r).call(this,y(e),n))}return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(n&&n.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),n&&g(e,n)}(r,v.Parser),function(e,n,r){n&&h(e.prototype,n),r&&h(e,r)}(r,[{key:"emitSource",value:function(){return e(this)}}]),r}();t.Parser=n}(o=o||{}),n.default=o},function(e,n,r){"use strict";(function(a){function t(e,n){for(var r=0;r<n.length;r++){var t=n[r];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(e,t.key,t)}}Object.defineProperty(n,"__esModule",{value:!0});var c=/^[A-Z0-9_]+$/,u=/(\?|\+|\*)$/,f=/^(@|&|!)/,b=r(14);function x(e,n){var r=n.exec(e);return r&&0==r.index?0==r[0].length&&0<n.source.length?null:{type:null,text:r[0],rest:e.substr(r[0].length),start:0,end:r[0].length-1,fullText:r[0],errors:[],children:[],parent:null}:null}function S(e){var n=u.exec(e),r=f.exec(e),t=n&&n[0]||"",o=r&&r[0]||"",i={raw:e,name:e.replace(u,"").replace(f,""),isOptional:"?"==t||"*"==t,allowRepetition:"+"==t||"*"==t,atLeastOne:"+"==t,lookupPositive:"&"==o,lookupNegative:"!"==o,pinned:"@"==o,lookup:!1,isLiteral:!1};return i.isLiteral="'"==i.name[0]||'"'==i.name[0],i.lookup=i.lookupNegative||i.lookupPositive,i}function l(e,n){var r=S(e);return n.cachedRules[r.name]||null}function i(e,n){if(e.children){for(var r=e.children.filter(function(e){return e.type&&n.test(e.type)}),t=0;t<r.length;t++){var o=e.children.indexOf(r[t]);-1!=o&&e.children.splice(o,1)}e.children.forEach(function(e){return i(e,n)})}}n.readToken=x,n.parseRuleName=S,n.findRuleByName=l;var s=["EOF"],e=function(){function r(e,n){var t=this;!function(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}(this,r),this.grammarRules=e,this.options=n,this.debug=!1,this.cachedRules={};var o=[],i=[];if(e.forEach(function(r){var e=S(r.name);if(e.name in t.cachedRules)o.push("Duplicated rule "+e.name);else{if((t.cachedRules[e.name]=r).bnf&&r.bnf.length)r.bnf.forEach(function(e){if("string"==typeof e[0]&&S(e[0]).name==r.name){var n="Left recursion is not allowed, rule: "+r.name;-1==o.indexOf(n)&&o.push(n)}e.forEach(function(e){if("string"==typeof e){var n=S(e);n.isLiteral||-1!=i.indexOf(n.name)||-1!=s.indexOf(n.name)||i.push(n.name)}})});else{var n="Missing rule content, rule: "+r.name;-1==o.indexOf(n)&&o.push(n)}"WS"==r.name&&(r.implicitWs=!1),r.implicitWs&&-1==i.indexOf("WS")&&i.push("WS"),r.recover&&-1==i.indexOf(r.recover)&&i.push(r.recover)}}),i.forEach(function(e){e in t.cachedRules||o.push("Missing rule "+e)}),o.length)throw new Error(o.join("\n"))}return function(e,n,r){n&&t(e.prototype,n),r&&t(e,r)}(r,[{key:"getAST",value:function(e,n){n=n||this.grammarRules.filter(function(e){return!e.fragment&&0!=e.name.indexOf("%")})[0].name;var r=this.parse(e,n);if(r){!function n(r,e){e.errors&&e.errors.length&&e.errors.forEach(function(e){return r.push(e)}),e.children&&e.children.forEach(function(e){return n(r,e)})}(r.errors,r),function n(r,e){r.start+=e,r.end+=e,r.children&&r.children.forEach(function(e){return n(e,r.start)})}(r,0),i(r,/^%/),this.options&&this.options.keepUpperRules||i(r,c);var t=r.rest;t&&new b.TokenError("Unexpected end of input: \n"+t,r),function n(e){e.rest="",e.children&&e.children.forEach(function(e){return n(e)})}(r),r.rest=t}return r}},{key:"emitSource",value:function(){return"CANNOT EMIT SOURCE FROM BASE Parser"}},{key:"parse",value:function(y,e,n){var r,h=this,m=2<arguments.length&&void 0!==n?n:0,d=null,g=S(e),v=this.debug&& | ||
/*!isLiteral &*/ | ||
!c.test(g.name);v&&console.log(new Array(m).join("│ ")+"Trying to get "+e+" from "+JSON.stringify(y.split("\n")[0]));var t=g.name,E=l(g.name,this);if("EOF"==g.name){if(y.length)return null;if(0==y.length)return{type:"EOF",text:"",rest:"",start:0,end:0,fullText:"",errors:[],children:[],parent:null}}try{if(!E&&g.isLiteral){var o=a.eval(g.name);if(""===o)return{type:"%%EMPTY%%",text:"",rest:y,start:0,end:0,fullText:"",errors:[],children:[],parent:null};r=new RegExp(function(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")}(o)),t=null}}catch(e){return null}if(r){var i=x(y,r);if(i)return i.type=t,i}else{var u=E.bnf;u instanceof Array&&u.forEach(function(e){if(!d){var n=null,r={type:g.name,text:"",children:[],end:0,errors:[],fullText:"",parent:null,start:0,rest:y};E.fragment&&(r.fragment=!0);for(var t=y,o=0,i=0<e.length,u=!1,a=0;a<e.length;a++)if("string"==typeof e[a]){var c=S(e[a]);i=i&&c.isOptional;var f=void 0,l=!1;do{if(f=null,E.implicitWs&&!(f=h.parse(t,c.name,m+1))){var s=void 0;do{if(!(s=h.parse(t,"WS",m+1)))break;r.text=r.text+s.text,r.end=r.text.length,(s.parent=r).children.push(s),t=t.substr(s.text.length),o+=s.text.length}while(s&&s.text.length)}if(f=f||h.parse(t,c.name,m+1),c.lookupNegative){if(f)return;break}if(c.lookupPositive&&!f)return;if(!f){if(c.isOptional)break;if(c.atLeastOne&&l)break}if(f&&E.pinned==a+1&&(n=f,v&&console.log(new Array(m+1).join("│ ")+"└─ "+f.type+" PINNED")),!(f=f||h.parseRecovery(E,t,m+1))){if(!n)return;d=r,f={type:"SyntaxError",text:t,children:[],end:t.length,errors:[],fullText:"",parent:null,start:0,rest:""},t.length?new b.TokenError("Unexpected end of input. Expecting ".concat(c.name," Got: ").concat(t),f):new b.TokenError("Unexpected end of input. Missing ".concat(c.name),f),v&&console.log(new Array(m+1).join("│ ")+"└─ "+f.type+" "+JSON.stringify(f.text))}if(u=l=!0,"%%EMPTY%%"==f.type)break;f.start+=o,f.end+=o,!c.lookupPositive&&f.type&&(f.fragment?f.children&&f.children.forEach(function(e){e.start+=o,e.end+=o,(e.parent=r).children.push(e)}):(f.parent=r).children.push(f)),c.lookup&&(f.lookup=!0),v&&console.log(new Array(m+1).join("│ ")+"└─ "+f.type+" "+JSON.stringify(f.text)),c.lookup||f.lookup||(r.text=r.text+f.text,r.end=r.text.length,t=t.substr(f.text.length),o+=f.text.length),r.rest=t}while(f&&c.allowRepetition&&t.length&&!f.lookup)}else{var p=x(t,e[a]);if(!p)return;v&&console.log(new Array(m+1).join("│ ")+"└> "+JSON.stringify(p.text)+e[a].source),u=!0,p.start+=o,p.end+=o,r.text=r.text+p.text,r.end=r.text.length,t=t.substr(p.text.length),o+=p.text.length,r.rest=t}u&&(d=r,v&&console.log(new Array(m).join("│ ")+"├<─┴< PUSHING "+d.type+" "+JSON.stringify(d.text)))}}),d&&E.simplifyWhenOneChildren&&1==d.children.length&&(d=d.children[0])}return d||v&&console.log(e+" NOT RESOLVED FROM "+y),d}},{key:"parseRecovery",value:function(e,n,r){if(e.recover&&n.length){var t=this.debug;t&&console.log(new Array(r+1).join("│ ")+"Trying to recover until token "+e.recover+" from "+JSON.stringify(n.split("\n")[0]+n.split("\n")[1]));var o,i={type:"SyntaxError",text:"",children:[],end:0,errors:[],fullText:"",parent:null,start:0,rest:""};do{if(o=this.parse(n,e.recover,r+1)){new b.TokenError('Unexpected input: "'+i.text+'" Expecting: '.concat(e.name),i);break}i.text=i.text+n[0],i.end=i.text.length,n=n.substr(1)}while(!o&&0<n.length);if(0<i.text.length&&o)return t&&console.log(new Array(r+1).join("│ ")+"Recovered text: "+JSON.stringify(i.text)),i}return null}}]),r}();n.Parser=e,n.default=e}).call(this,r(11))},function(e,n){function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var t;t=function(){return this}();try{t=t||new Function("return this")()}catch(e){"object"===("undefined"==typeof window?"undefined":r(window))&&(t=window)}e.exports=t},function(e,n,r){"use strict";function o(e){return(o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function i(e,n){for(var r=0;r<n.length;r++){var t=n[r];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(e,t.key,t)}}function u(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function a(e){var r="function"==typeof Map?new Map:void 0;return(a=function(e){if(null===e||!function(e){return-1!==Function.toString.call(e).indexOf("[native code]")}(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==r){if(r.has(e))return r.get(e);r.set(e,n)}function n(){return t(e,arguments,f(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),c(n,e)})(e)}function t(e,n,r){return(t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(e){return!1}}()?Reflect.construct:function(e,n,r){var t=[null];t.push.apply(t,n);var o=new(Function.bind.apply(e,t));return r&&c(o,r.prototype),o}).apply(null,arguments)}function c(e,n){return(c=Object.setPrototypeOf||function(e,n){return e.__proto__=n,e})(e,n)}function f(e){return(f=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}Object.defineProperty(n,"__esModule",{value:!0});var l=function(){function t(e,n){var r;if(function(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}(this,t),(r=function(e,n){return!n||"object"!==o(n)&&"function"!=typeof n?u(e):n}(this,f(t).call(this,e))).message=e,!(r.token=n)||!n.errors)throw u(r);return n.errors.push(u(r)),r}return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(n&&n.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),n&&c(e,n)}(t,a(Error)),function(e,n,r){n&&i(e.prototype,n),r&&i(e,r)}(t,[{key:"inspect",value:function(){return"SyntaxError: "+this.message}}]),t}();n.TokenError=l},function(e,n){e.exports={enbf:'\nroot ::= ("#" recursion | recursion | (query | pattern) recursion* | "#" SEP? | SEP)\nrecursion ::= (SEP query | pattern)*\n\nquery ::= (ESC escaped ESC | property | all | any | regex) typecheck? lookahead?\nproperty ::= [^?/{}*,()#]+\nregex ::= "{" [^}]+ "}"\nSEP ::= "/"\nall ::= "**"\nany ::= "*"\n\ntypecheck ::= "?:" ("value" | "boolean" | "string" | "number" | "object" | "array")\nlookahead ::= "?" expression ((andExpr | orExpr) expression)*\nandExpr ::= S? "&&" S?\norExpr ::= S? "||" S?\n\nexpression ::= (exprProperty | ESC escaped ESC) ((isnot | is) (exprProperty | regex | ESC escaped ESC))*\nexprProperty ::= [a-zA-Z0-9-_ $]+\nescaped ::= [^"]+\nis ::= ":"\nisnot ::= ":!"\nESC ::= \'"\'\n\npattern ::= S? "(" (SEP query | pattern (orPattern? pattern)*)* ")" quantifier? S? lookahead?\nquantifier ::= "+"\norPattern ::= S? "," S?\n\nS ::= [ ]*\n'}},function(e,n,r){function c(e){return function(e){if(Array.isArray(e)){for(var n=0,r=new Array(e.length);n<e.length;n++)r[n]=e[n];return r}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}var t=r(15),o=t.expand,i=t.select,u=t.cache,a=r(1),f=a.VALUE_INDEX,l=a.KEY_INDEX,s=a.PARENT_INDEX,p=a.POINTER_INDEX;function y(e,n,r){var t=e;return n.children.forEach(function(e){if(o[e.type])t=function(e,n,r,t){for(var o=[],i=0,u=n.length;i<u;i+=1)o.push.apply(o,c(e(r,n[i],r,t)));return o}(o[e.type],t,e,r);else{if(!i[e.type])throw new Error("Unknown filter ".concat(e.type));t=function(e,n,r,t){for(var o=[],i=0,u=n.length;i<u;i+=1){var a=e(r,n[i],t);a&&o.push(a)}return o}(i[e.type],t,e,r)}}),t}function h(n,e,r){var t=[],o=n;return e.children.forEach(function(e){if("orPattern"===e.type)return t.push.apply(t,c(o)),void(o=n);o=m(o,e,r)}),t.push.apply(t,c(o)),t}function m(e,n,r){return"query"===n.type?y(e,n,r):"pattern"===n.type?function(e,n,r){for(var t=[],o=n.children.find(function(e){return"quantifier"===e.type}),i=o&&"+"===o.text?1/0:1,u=e,a=0;0<u.length&&a<i;)u=h(u,n,r),t.push.apply(t,c(u)),a+=1;return t}(e,n,r):function(e,n,r){var t=e;return n.children.forEach(function(e){return t=m(t,e,r)}),t}(e,n,r)}e.exports={VALUE_INDEX:f,KEY_INDEX:l,PARENT_INDEX:s,POINTER_INDEX:p,run:function(e,n){return u.reset(),u.mem.push(e),m([[e,null,null,"#"]],n)}}},function(e,n,r){function u(e){return function(e){if(Array.isArray(e)){for(var n=0,r=new Array(e.length);n<e.length;n++)r[n]=e[n];return r}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function o(e,n){return"".concat(e,"/").concat(n)}function a(e){return s.test(l.call(e))}var c=r(16),t=r(1),f=t.VALUE_INDEX,i=t.POINTER_INDEX,l=Object.prototype.toString,s=/Object|Array/;function p(e){return new RegExp(e.text.replace(/(^{|}$)/g,""))}var y={mem:[],get:function(e,n){var r=e[f][n];if(!y.mem.includes(r))return a(r)&&y.mem.push(r),[r,n,e[f],o(e[i],n)]},reset:function(){y.mem.length=0}},h={any:function(e,n){var r=n[f];return c.keys(r).map(function(e){return[r[e],e,r,o(n[i],e)]})},all:function(t,o){var i=[o];return c.forEach(o[f],function(e,n){var r=y.get(o,n);r&&i.push.apply(i,u(h.all(t,r)))}),i},regex:function(e,n){var r=p(e),t=n[f];return c.keys(t).filter(function(e){return r.test(e)}).map(function(e){return[t[e],e,t,o(n[i],e)]})}},m={escaped:function(e,n){return m.property(e,n)},property:function(e,n){var r=e.text;if(n[f]&&void 0!==n[f][r])return[n[f][r],r,n[f],o(n[i],r)]},typecheck:function(e,n){var r=e.text.replace(/^\?:/,"");return"value"===r?a(n[f])?void 0:n:function(e){return l.call(e).match(/\s([^\]]+)\]/).pop().toLowerCase()}(n[f])===r?n:void 0},lookahead:function(e,r){var t=!0,o=!1;return e.children.forEach(function(e){if("expression"===e.type){var n=void 0!==m.expression(e,r);t=!0===o?t||n:t&&n}else o="orExpr"===e.type}),t?r:void 0},expression:function(e,n){var r=e.children[0].text,t=e.children[1],o=e.children[2],i=n[f];if(!1!==a(i))return function(e,n,r){if(void 0===n)return void 0!==e;var t,o=""+e;if("regex"===r.type){var i=p(r);t=i.test(o)}else t=o===r.text;"isnot"===n.type&&(t=!1===t&&void 0!==e);return t}(i[r],t,o)?n:void 0}};e.exports={expand:h,select:m,cache:y}},function(e,n,r){"use strict";n.values=r(17),n.asArray=r(18),n.forEach=r(4),n.keyOf=r(19),n.keys=r(20)},function(e,n,r){"use strict";e.exports=function(n){return Array.isArray(n)?n:"[object Object]"===Object.prototype.toString.call(n)?Object.keys(n).map(function(e){return n[e]}):null!=n?[n]:[]}},function(e,n,r){"use strict";e.exports=function(n){return Array.isArray(n)?n:"[object Object]"===Object.prototype.toString.call(n)?Object.keys(n).map(function(e){return n[e]}):[]}},function(e,n,r){"use strict";var o=r(4);e.exports=function(e,r){var t=null;return o(e,function(e,n){r===e&&(t=n)}),t}},function(e,n,r){"use strict";e.exports=function(e){var n;if(Array.isArray(e))n=e.map(function(e,n){return n});else{if("[object Object]"===Object.prototype.toString.call(e))return Object.keys(e);n=[]}return n}},function(e,n,r){var i=r(22).delete,u=r(6),a=r(3),t=r(1),c=t.PARENT_INDEX,f=t.POINTER_INDEX;e.exports=function(n,e){var r=2<arguments.length&&void 0!==arguments[2]&&arguments[2],t=[],o=a(n,e,"all");return o.forEach(function(e){t.push(e[0]),i(n,e[f],!0)}),o.forEach(function(e){Array.isArray(e[c])&&u(e[c])}),r?t:n}},function(e,n,r){"use strict";n.get=r(5),n.set=r(23),n.delete=r(24),n.join=r(25),n.split=r(0),n.isRoot=r(2)},function(e,n,r){"use strict";var i=r(0),u=/^\[.*\]$/,o=/^\[(.+)\]$/;function a(e,n,r){var t=n.match(o);"[]"===n&&Array.isArray(e)?e.push(r):t?e[t.pop()]=r:e[n]=r}function c(e,n,r){if(null!=e[n])return e[n];var t=r?[]:{};return a(e,n,t),t}e.exports=function(e,n,r){if(null==n)return e;var t=i(n);if(0===t.length)return e;null==e&&(e=u.test(t[0])?[]:{});for(var o=e;1<t.length;)o=c(o,t.shift(),u.test(t[0]));return a(o,t.pop(),r),e}},function(e,n,r){"use strict";var u=r(0),a=r(5),c=r(6);e.exports=function(e,n,r){var t=u(n),o=t.pop(),i=a(e,t);return i&&delete i[o],Array.isArray(i)&&!0!==r&&c(i),e}},function(e,n,r){"use strict";var a=r(0),o=(Object.prototype.toString,Array.prototype.join,/\/+/g),i=/~/g,u=/\//g;function c(e,n){if(0===e.length)return n?"#":"";e.join("/");for(var r=0,t=e.length;r<t;r+=1)e[r]=e[r].replace(i,"~0").replace(u,"~1"),n&&(e[r]=encodeURIComponent(e[r]));return((n?"#/":"/")+e.join("/")).replace(o,"/")}e.exports=function(e){var n=[];if(Array.isArray(e))return c(e,!0===arguments[1]);for(var r=arguments[arguments.length-1],t="boolean"==typeof r?r:e&&"#"===e[0],o=0,i=arguments.length;o<i;o+=1)n.push.apply(n,a(arguments[o]));var u=[];for(o=0,i=n.length;o<i;o+=1)if(".."===n[o]){if(0===u.length)return t?"#":"";u.pop()}else u.push(n[o]);return c(u,t)}}]); | ||
!c.test(g.name);v&&console.log(new Array(m).join("│ ")+"Trying to get "+e+" from "+JSON.stringify(y.split("\n")[0]));var t=g.name,E=l(g.name,this);if("EOF"==g.name){if(y.length)return null;if(0==y.length)return{type:"EOF",text:"",rest:"",start:0,end:0,fullText:"",errors:[],children:[],parent:null}}try{if(!E&&g.isLiteral){var o=a.eval(g.name);if(""===o)return{type:"%%EMPTY%%",text:"",rest:y,start:0,end:0,fullText:"",errors:[],children:[],parent:null};r=new RegExp(function(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")}(o)),t=null}}catch(e){return null}if(r){var i=x(y,r);if(i)return i.type=t,i}else{var u=E.bnf;u instanceof Array&&u.forEach(function(e){if(!d){var n=null,r={type:g.name,text:"",children:[],end:0,errors:[],fullText:"",parent:null,start:0,rest:y};E.fragment&&(r.fragment=!0);for(var t=y,o=0,i=0<e.length,u=!1,a=0;a<e.length;a++)if("string"==typeof e[a]){var c=S(e[a]);i=i&&c.isOptional;var f=void 0,l=!1;do{if(f=null,E.implicitWs&&!(f=h.parse(t,c.name,m+1))){var s=void 0;do{if(!(s=h.parse(t,"WS",m+1)))break;r.text=r.text+s.text,r.end=r.text.length,(s.parent=r).children.push(s),t=t.substr(s.text.length),o+=s.text.length}while(s&&s.text.length)}if(f=f||h.parse(t,c.name,m+1),c.lookupNegative){if(f)return;break}if(c.lookupPositive&&!f)return;if(!f){if(c.isOptional)break;if(c.atLeastOne&&l)break}if(f&&E.pinned==a+1&&(n=f,v&&console.log(new Array(m+1).join("│ ")+"└─ "+f.type+" PINNED")),!(f=f||h.parseRecovery(E,t,m+1))){if(!n)return;d=r,f={type:"SyntaxError",text:t,children:[],end:t.length,errors:[],fullText:"",parent:null,start:0,rest:""},t.length?new b.TokenError("Unexpected end of input. Expecting ".concat(c.name," Got: ").concat(t),f):new b.TokenError("Unexpected end of input. Missing ".concat(c.name),f),v&&console.log(new Array(m+1).join("│ ")+"└─ "+f.type+" "+JSON.stringify(f.text))}if(u=l=!0,"%%EMPTY%%"==f.type)break;f.start+=o,f.end+=o,!c.lookupPositive&&f.type&&(f.fragment?f.children&&f.children.forEach(function(e){e.start+=o,e.end+=o,(e.parent=r).children.push(e)}):(f.parent=r).children.push(f)),c.lookup&&(f.lookup=!0),v&&console.log(new Array(m+1).join("│ ")+"└─ "+f.type+" "+JSON.stringify(f.text)),c.lookup||f.lookup||(r.text=r.text+f.text,r.end=r.text.length,t=t.substr(f.text.length),o+=f.text.length),r.rest=t}while(f&&c.allowRepetition&&t.length&&!f.lookup)}else{var p=x(t,e[a]);if(!p)return;v&&console.log(new Array(m+1).join("│ ")+"└> "+JSON.stringify(p.text)+e[a].source),u=!0,p.start+=o,p.end+=o,r.text=r.text+p.text,r.end=r.text.length,t=t.substr(p.text.length),o+=p.text.length,r.rest=t}u&&(d=r,v&&console.log(new Array(m).join("│ ")+"├<─┴< PUSHING "+d.type+" "+JSON.stringify(d.text)))}}),d&&E.simplifyWhenOneChildren&&1==d.children.length&&(d=d.children[0])}return d||v&&console.log(e+" NOT RESOLVED FROM "+y),d}},{key:"parseRecovery",value:function(e,n,r){if(e.recover&&n.length){var t=this.debug;t&&console.log(new Array(r+1).join("│ ")+"Trying to recover until token "+e.recover+" from "+JSON.stringify(n.split("\n")[0]+n.split("\n")[1]));var o,i={type:"SyntaxError",text:"",children:[],end:0,errors:[],fullText:"",parent:null,start:0,rest:""};do{if(o=this.parse(n,e.recover,r+1)){new b.TokenError('Unexpected input: "'+i.text+'" Expecting: '.concat(e.name),i);break}i.text=i.text+n[0],i.end=i.text.length,n=n.substr(1)}while(!o&&0<n.length);if(0<i.text.length&&o)return t&&console.log(new Array(r+1).join("│ ")+"Recovered text: "+JSON.stringify(i.text)),i}return null}}]),r}();n.Parser=e,n.default=e}).call(this,r(13))},function(e,n){function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var t;t=function(){return this}();try{t=t||new Function("return this")()}catch(e){"object"===("undefined"==typeof window?"undefined":r(window))&&(t=window)}e.exports=t},function(e,n,r){"use strict";function o(e){return(o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function i(e,n){for(var r=0;r<n.length;r++){var t=n[r];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(e,t.key,t)}}function u(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function a(e){var r="function"==typeof Map?new Map:void 0;return(a=function(e){if(null===e||!function(e){return-1!==Function.toString.call(e).indexOf("[native code]")}(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==r){if(r.has(e))return r.get(e);r.set(e,n)}function n(){return t(e,arguments,f(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),c(n,e)})(e)}function t(e,n,r){return(t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(e){return!1}}()?Reflect.construct:function(e,n,r){var t=[null];t.push.apply(t,n);var o=new(Function.bind.apply(e,t));return r&&c(o,r.prototype),o}).apply(null,arguments)}function c(e,n){return(c=Object.setPrototypeOf||function(e,n){return e.__proto__=n,e})(e,n)}function f(e){return(f=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}Object.defineProperty(n,"__esModule",{value:!0});var l=function(){function t(e,n){var r;if(function(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}(this,t),(r=function(e,n){return!n||"object"!==o(n)&&"function"!=typeof n?u(e):n}(this,f(t).call(this,e))).message=e,!(r.token=n)||!n.errors)throw u(r);return n.errors.push(u(r)),r}return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(n&&n.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),n&&c(e,n)}(t,a(Error)),function(e,n,r){n&&i(e.prototype,n),r&&i(e,r)}(t,[{key:"inspect",value:function(){return"SyntaxError: "+this.message}}]),t}();n.TokenError=l},function(e,n,r){function c(e){return function(e){if(Array.isArray(e)){for(var n=0,r=new Array(e.length);n<e.length;n++)r[n]=e[n];return r}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}var t=r(16),o=t.expand,i=t.select,u=t.cache,a=r(2),f=a.VALUE_INDEX,l=a.KEY_INDEX,s=a.PARENT_INDEX,p=a.POINTER_INDEX;function y(e,n,r){var t=e;return n.children.forEach(function(e){if(o[e.type])t=function(e,n,r,t){for(var o=[],i=0,u=n.length;i<u;i+=1)o.push.apply(o,c(e(r,n[i],r,t)));return o}(o[e.type],t,e,r);else{if(!i[e.type])throw new Error("Unknown filter ".concat(e.type));t=function(e,n,r,t){for(var o=[],i=0,u=n.length;i<u;i+=1){var a=e(r,n[i],t);a&&o.push(a)}return o}(i[e.type],t,e,r)}}),t}function h(n,e,r){var t=[],o=n;return e.children.forEach(function(e){if("orPattern"===e.type)return t.push.apply(t,c(o)),void(o=n);o=d(o,e,r)}),t.push.apply(t,c(o)),t}function m(e,n,r){var t=[],o=n.children.find(function(e){return"quantifier"===e.type}),i=function(e){return null==e?1:"*"===e||"+"===e?1/0:(e=parseInt(e),isNaN(e)?1:e)}(o&&o.text),u=e;o&&"*"===o.text&&t.push.apply(t,c(u));for(var a=0;0<u.length&&a<i;)u=h(u,n,r),t.push.apply(t,c(u)),a+=1;return t}function d(e,n,r){var t;return t="query"===n.type?y(e,n,r):"pattern"===n.type?m(e,n,r):function(e,n,r){var t=e;return n.children.forEach(function(e){return t=d(t,e,r)}),t}(e,n,r),u.reset(),u.mem.push(e),t}e.exports={VALUE_INDEX:f,KEY_INDEX:l,PARENT_INDEX:s,POINTER_INDEX:p,run:function(e,n){return u.reset(),u.mem.push(e),d([[e,null,null,"#"]],n)}}},function(e,n,r){function u(e){return function(e){if(Array.isArray(e)){for(var n=0,r=new Array(e.length);n<e.length;n++)r[n]=e[n];return r}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function o(e,n){return"".concat(e,"/").concat(n)}function a(e){return s.test(l.call(e))}var c=r(17),t=r(2),f=t.VALUE_INDEX,i=t.POINTER_INDEX,l=Object.prototype.toString,s=/Object|Array/;function p(e){return new RegExp(e.text.replace(/(^{|}$)/g,""))}var y={mem:[],get:function(e,n){var r=e[f][n];if(!y.mem.includes(r))return a(r)&&y.mem.push(r),[r,n,e[f],o(e[i],n)]},reset:function(){y.mem.length=0}},h={any:function(e,n){var r=n[f];return c.keys(r).map(function(e){return[r[e],e,r,o(n[i],e)]})},all:function(t,o){var i=[o];return c.forEach(o[f],function(e,n){var r=y.get(o,n);r&&i.push.apply(i,u(h.all(t,r)))}),i},regex:function(e,n){var r=p(e),t=n[f];return c.keys(t).filter(function(e){return r.test(e)}).map(function(e){return[t[e],e,t,o(n[i],e)]})}},m={escaped:function(e,n){return m.property(e,n)},property:function(e,n){var r=e.text;if(n[f]&&void 0!==n[f][r])return[n[f][r],r,n[f],o(n[i],r)]},typecheck:function(e,n){var r=e.text.replace(/^\?:/,"");return"value"===r?a(n[f])?void 0:n:function(e){return l.call(e).match(/\s([^\]]+)\]/).pop().toLowerCase()}(n[f])===r?n:void 0},lookahead:function(e,r){var t=!0,o=!1;return e.children.forEach(function(e){if("expression"===e.type){var n=void 0!==m.expression(e,r);t=!0===o?t||n:t&&n}else o="orExpr"===e.type}),t?r:void 0},expression:function(e,n){var r=e.children[0].text,t=e.children[1],o=e.children[2],i=n[f];if(!1!==a(i))return function(e,n,r){if(void 0===n)return void 0!==e;var t,o=""+e;if("regex"===r.type){var i=p(r);t=i.test(o)}else t=o===r.text;"isnot"===n.type&&(t=!1===t&&void 0!==e);return t}(i[r],t,o)?n:void 0}};e.exports={expand:h,select:m,cache:y}},function(e,n,r){"use strict";n.values=r(18),n.asArray=r(19),n.forEach=r(6),n.keyOf=r(20),n.keys=r(21)},function(e,n,r){"use strict";e.exports=function(n){return Array.isArray(n)?n:"[object Object]"===Object.prototype.toString.call(n)?Object.keys(n).map(function(e){return n[e]}):null!=n?[n]:[]}},function(e,n,r){"use strict";e.exports=function(n){return Array.isArray(n)?n:"[object Object]"===Object.prototype.toString.call(n)?Object.keys(n).map(function(e){return n[e]}):[]}},function(e,n,r){"use strict";var o=r(6);e.exports=function(e,r){var t=null;return o(e,function(e,n){r===e&&(t=n)}),t}},function(e,n,r){"use strict";e.exports=function(e){var n;if(Array.isArray(e))n=e.map(function(e,n){return n});else{if("[object Object]"===Object.prototype.toString.call(e))return Object.keys(e);n=[]}return n}},function(e,n,r){function f(e){return function(e){if(Array.isArray(e)){for(var n=0,r=new Array(e.length);n<e.length;n++)r[n]=e[n];return r}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}var t=r(5).propertyRegex,l=r(7),s=r(1),p=function(e){return JSON.parse(JSON.stringify(e))},o=Object.prototype.toString,y=function(e){return o.call(e).match(/\s([^\]]+)\]/).pop().toLowerCase()},h=new RegExp('^("[^"]+"|'.concat(t,")$")),m=["string","number","boolean","null"],d=/^\[\d*\]$/,g=/^\[(\d+)\]$/,i=/^".+"$/,v=/(^\[\d*\]$|^\d+$)/;function u(e){return parseInt(e.replace(/^(\[|\]$)/,""))}function E(e){return i.test(e)?e.replace(/(^"|"$)/g,""):e}function b(e,n,r,t){var o=e[0];if(/^\[\]$/.test(n)){o.push(r);var i=o.length-1;return[o[i],i,o,"".concat(e[3],"/").concat(i,"}")]}if(t===a.INSERT_ITEMS||null==t&&g.test(n))return function(e,n,r){e.length<=n?e[n]=r:e.splice(n,0,r)}(o,n=u(n),r),[o[n],n,o,"".concat(e[3],"/").concat(n,"}")];if(t===a.REPLACE_ITEMS||null==t)return o[n=u(n)]=r,[o[n],n,o,"".concat(e[3],"/").concat(n,"}")];throw new Error("Unknown array index '".concat(n,"' with force-option '").concat(t,"'"))}function a(e,n,t,o){if(null==n)return p(e);if(""===(n=n.replace(/(\/$)/g,"")))return p(t);var r=p(e),i=[[r,null,null,"#"]],u=l(n),a=u.pop(),c=d.test(a)&&!1===g.test(a);if(!1===h.test(a)||c)throw new Error("Unsupported query '".concat(n,"' ending with non-property"));return u.forEach(function(e,n){if(!1!==h.test(e)){var r=n>=u.length-1?a:u[n+1],t=v.test(r);i=function(e,t,o,i){return t=E(t),e.filter(function(e){return!(!Array.isArray(e[0])||!v.test(t))||!1===m.includes(y(e[0][t]))}).map(function(e){var n=o?[]:{},r=e[0];return Array.isArray(r)?b(e,t,n,i):(r[t]=r[t]||n,[r[t],t,r,"".concat(e[3],"/").concat(t)])})}(i,e,t,o)}else i=function(e,n){var r=[];return e.forEach(function(e){return r.push.apply(r,f(s(e[0],n,s.ALL)))}),r}(i,e)}),i.forEach(function(e){var n=t;"function"===y(t)&&(n=t(e[3],a,e[0],"".concat(e[3],"/").concat(a)));var r=e[0];Array.isArray(r)?b(e,a,n,o):r[E(a)]=n}),r}a.REPLACE_ITEMS="replace",a.INSERT_ITEMS="insert",e.exports=a},function(e,n,r){var i=r(24).delete,u=r(9),a=r(1),t=r(2),c=t.PARENT_INDEX,f=t.POINTER_INDEX;e.exports=function(n,e){var r=2<arguments.length&&void 0!==arguments[2]&&arguments[2],t=[],o=a(n,e,"all");return o.forEach(function(e){t.push(e[0]),i(n,e[f],!0)}),o.forEach(function(e){Array.isArray(e[c])&&u(e[c])}),r?t:n}},function(e,n,r){"use strict";n.get=r(8),n.set=r(25),n.delete=r(26),n.join=r(27),n.split=r(0),n.isRoot=r(3)},function(e,n,r){"use strict";var i=r(0),u=/^\[.*\]$/,o=/^\[(.+)\]$/;function a(e,n,r){var t=n.match(o);"[]"===n&&Array.isArray(e)?e.push(r):t?e[t.pop()]=r:e[n]=r}function c(e,n,r){if(null!=e[n])return e[n];var t=r?[]:{};return a(e,n,t),t}e.exports=function(e,n,r){if(null==n)return e;var t=i(n);if(0===t.length)return e;null==e&&(e=u.test(t[0])?[]:{});for(var o=e;1<t.length;)o=c(o,t.shift(),u.test(t[0]));return a(o,t.pop(),r),e}},function(e,n,r){"use strict";var u=r(0),a=r(8),c=r(9);e.exports=function(e,n,r){var t=u(n),o=t.pop(),i=a(e,t);return i&&delete i[o],Array.isArray(i)&&!0!==r&&c(i),e}},function(e,n,r){"use strict";var a=r(0),o=(Object.prototype.toString,Array.prototype.join,/\/+/g),i=/~/g,u=/\//g;function c(e,n){if(0===e.length)return n?"#":"";e.join("/");for(var r=0,t=e.length;r<t;r+=1)e[r]=e[r].replace(i,"~0").replace(u,"~1"),n&&(e[r]=encodeURIComponent(e[r]));return((n?"#/":"/")+e.join("/")).replace(o,"/")}e.exports=function(e){var n=[];if(Array.isArray(e))return c(e,!0===arguments[1]);for(var r=arguments[arguments.length-1],t="boolean"==typeof r?r:e&&"#"===e[0],o=0,i=arguments.length;o<i;o+=1)n.push.apply(n,a(arguments[o]));var u=[];for(o=0,i=n.length;o<i;o+=1)if(".."===n[o]){if(0===u.length)return t?"#":"";u.pop()}else u.push(n[o]);return c(u,t)}}]); |
@@ -36,3 +36,2 @@ const { parse } = require("./parser"); | ||
const result = run(data, ast); | ||
@@ -39,0 +38,0 @@ if (returnTypes[returnType]) { |
exports.get = require("./get"); | ||
exports.set = require("./set"); | ||
exports.split = require("./split"); | ||
exports.remove = require("./remove"); |
@@ -58,8 +58,22 @@ const { expand, select, cache } = require("./nodes"); | ||
function getIterationCount(quantifier) { | ||
if (quantifier == null) { | ||
return 1; // default, simple group | ||
} | ||
if (quantifier === "*" || quantifier === "+") { | ||
return Infinity; | ||
} | ||
quantifier = parseInt(quantifier); | ||
return isNaN(quantifier) ? 1 : quantifier; | ||
} | ||
function pattern(data, ast, pointer) { | ||
const result = []; | ||
const quantifier = ast.children.find(node => node.type === "quantifier"); | ||
const iterationCount = (quantifier && quantifier.text === "+") ? Infinity : 1; | ||
const iterationCount = getIterationCount(quantifier && quantifier.text); | ||
let workingSet = data; | ||
if (quantifier && quantifier.text === "*") { | ||
result.push(...workingSet); | ||
} | ||
let count = 0; | ||
@@ -91,2 +105,5 @@ while (workingSet.length > 0 && count < iterationCount) { | ||
} | ||
// after each query or pattern, reset the cache, to (re)enable nested queries | ||
cache.reset(); | ||
cache.mem.push(data); | ||
return result; | ||
@@ -93,0 +110,0 @@ } |
@@ -0,1 +1,3 @@ | ||
const propertyRegex = "[^?/{}*,()#]+"; | ||
// W3C ENBF grammar | ||
@@ -9,3 +11,3 @@ // https://github.com/lys-lang/node-ebnf/blob/master/test/W3CEBNF.spec.ts | ||
query ::= (ESC escaped ESC | property | all | any | regex) typecheck? lookahead? | ||
property ::= [^?/{}*,()#]+ | ||
property ::= ${propertyRegex} | ||
regex ::= "{" [^}]+ "}" | ||
@@ -29,3 +31,3 @@ SEP ::= "/" | ||
pattern ::= S? "(" (SEP query | pattern (orPattern? pattern)*)* ")" quantifier? S? lookahead? | ||
quantifier ::= "+" | ||
quantifier ::= "+" | "*" | [0-9]+ | ||
orPattern ::= S? "," S? | ||
@@ -38,3 +40,4 @@ | ||
module.exports = { | ||
enbf | ||
enbf, | ||
propertyRegex | ||
}; |
{ | ||
"name": "gson-query", | ||
"version": "4.2.0", | ||
"version": "4.3.0", | ||
"description": "json-pointer utilities for querying and transforming data", | ||
"main": "lib/index.js", | ||
"types": "lib/index.d.ts", | ||
"repository": { | ||
@@ -27,2 +28,5 @@ "type": "git", | ||
"@babel/preset-env": "^7.6.2", | ||
"@types/node": "^12.12.4", | ||
"@typescript-eslint/eslint-plugin": "^2.6.0", | ||
"@typescript-eslint/parser": "^2.6.0", | ||
"babel-loader": "^8.0.6", | ||
@@ -33,2 +37,3 @@ "chai": "^4.2.0", | ||
"nyc": "^14.1.1", | ||
"typescript": "^3.6.4", | ||
"uglifyjs-webpack-plugin": "^2.2.0", | ||
@@ -35,0 +40,0 @@ "watch": "^1.0.1", |
112
README.md
@@ -152,4 +152,4 @@ <h1 align="left"><img src="./docs/gson-query.png" width="256" alt="gson-query"></h1> | ||
- escape property-name: `'/root/*/"strange/property"'` is split to `["root", "*", "strange/property"]` | ||
- escape query-property `'/root/*?"strange/property"':42` | ||
- escape query-value `'/root/*?id:"#/pointer/value"` | ||
- escape query-property `'/root/*?"strange/property":42'` | ||
- escape query-value `'/root/*?id:"#/pointer/value"'` | ||
@@ -169,11 +169,13 @@ | ||
*gson-query* exposes two methods `get` and `remove` | ||
*gson-query* exposes `get`, `set`, `remove` and a `split`-helper | ||
method | signature | description | ||
--------|-------------------------------------------------------------------|------------------------------ | ||
get | (input:any, query: string, returnType?:string\|function) | query data, returns results | ||
get | (input:any, query:string, returnType?:string\|function) | query data, returns results | ||
set | (input:any, query:string, value:string\|function, replace?:string)| set value, returns modified input | ||
split | (query: string) | returns a list properties and queries | ||
remove | (input:any, query: string, returnRemoved?:boolean) | delete query targets, returns input | ||
**get** | ||
### get | ||
@@ -220,2 +222,4 @@ per default, *get* returns a list of all values | ||
### remove | ||
**remove** deletes any match from the input data. | ||
@@ -241,2 +245,98 @@ Note: the input will be modified. If this is unwanted behaviour, copy your data up front. | ||
### set | ||
**set** inserts given input-value on result and creates missing properties and arrays. | ||
Note: Any expanding queries like `*` or patterns will not create any intermediate values | ||
`set` has the following signature | ||
```ts | ||
set(input:any, query:string, value:string\|function, force?:string): any | ||
``` | ||
instead of value, you can also pass a function to generate the values to set: | ||
```ts | ||
value(pointerOfParent:string, lastPropertyName:string, parentObject:string, pointerAtValue:string): any | ||
``` | ||
Create data from simple properties | ||
```js | ||
import { set } from "gson-query"; | ||
const result = set({}, "/object/id", 42); // { object: { id: 42 }} | ||
``` | ||
Add properties to multiple existing objects | ||
```js | ||
import { set } from "gson-query"; | ||
const result = set({ list: [ { id: 1 }, { id: 2 } ] }, "/list/*/index", 42); | ||
// { list: [ { id: 1, index: 42 }, { id: 2, index: 42 } ] } | ||
``` | ||
Or using a value-function | ||
```js | ||
import { set } from "gson-query"; | ||
const result = set({ list: [ { id: 1 }, { id: 2 } ] }, "/list/*/index", | ||
( _, _, parent) => `id-${parent.id}` | ||
); | ||
// { list: [ { id: 1, index: "id-1" }, { id: 2, index: "id-2" } ] } | ||
``` | ||
Currently, `set` will not override simple values | ||
```js | ||
import { set } from "gson-query"; | ||
const result = set({ value: 2 }, "/value/id", 3); | ||
// { value: 2 } | ||
``` | ||
And queries will not add values to the data | ||
```js | ||
import { set } from "gson-query"; | ||
const result = set({ a: { id: 2 } }, "((/a), (/b))/id", true); | ||
// { a: { id: true } } | ||
``` | ||
When working with arrays, you have to choose between the following actions | ||
- insert item at index *1*: `/list/[1]/id` | ||
- replace item at index *1*: `/list/1/id` | ||
- append item `/list/[]/id` | ||
Using the `force` option, you can enforce insertion or replacement, independent of the syntax (same for the whole query) | ||
```js | ||
set(data, "/list/[1]/id", 42, set.REPLACE_ITEMS); // will always replace index | ||
// and | ||
set(data, "/list/1/id", 42, set.INSERT_ITEMS); // will always insert at index | ||
``` | ||
Numbers will always be interpreted as arrays | ||
```js | ||
set({}, "/list/0/id", 42); // { list: [{ id: 42 }]} | ||
set({}, "/list/[]/id", 42); // { list: [{ id: 42 }]} | ||
set({}, "/list/[0]/id", 42); // { list: [{ id: 42 }]} | ||
// but setting an index is respected | ||
set({}, "/list/2/id", 42); // { list: [undefined, undefined, { id: 42 }]} | ||
``` | ||
In order to treat numbers as objects, escape them using double-quotes | ||
```js | ||
set({}, '/list/"2"/id', 42); // { list: { 2: { id: 42 } } } | ||
// or "/list/\"2\"/id" | ||
``` | ||
## About patterns | ||
@@ -304,1 +404,3 @@ | ||
- [query.get](https://github.com/sagold/json-query/blob/master/test/unit/get.test.js) | ||
- [query.set](https://github.com/sagold/json-query/blob/master/test/unit/set.test.js) | ||
- [query.split](https://github.com/sagold/json-query/blob/master/test/unit/split.test.js) |
Sorry, the diff of this file is not supported yet
65686
22
658
402
15