Critical severity9.8NVD Advisory· Published Oct 11, 2024· Updated Apr 15, 2026
CVE-2024-21534
CVE-2024-21534
Description
All versions of the package jsonpath-plus are vulnerable to Remote Code Execution (RCE) due to improper input sanitization. An attacker can execute aribitrary code on the system by exploiting the unsafe default usage of vm in Node. Note: There were several attempts to fix it in versions 10.0.0-10.1.0 but it could still be exploited using different payloads.
Affected packages
Versions sourced from the GitHub Security Advisory.
| Package | Affected versions | Patched versions |
|---|---|---|
jsonpath-plusnpm | < 10.2.0 | 10.2.0 |
org.webjars.npm:jsonpath-plusMaven | <= 6.0.1 | — |
Patches
373ad72e5ee78fix(eval): improve security of safe-eval (#233)
22 files changed · +173 −172
badges/coverage-badge.svg+1 −1 modified@@ -1 +1 @@ -<svg xmlns="http://www.w3.org/2000/svg" width="417" height="20"><defs><style>text{font-size:11px;font-family:Verdana,DejaVu Sans,Geneva,sans-serif}text.shadow{fill:#010101;fill-opacity:.3}text.high{fill:#fff}</style><linearGradient id="smooth" x2="0" y2="100%"><stop offset="0" stop-color="#aaa" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><mask id="round"><rect width="100%" height="100%" rx="3" fill="#fff"/></mask></defs><g id="bg" mask="url(#round)"><path fill="orange" stroke="#000" d="M0 0h120v20H0zM120 0h109v20H120zM229 0h87v20h-87z"/><path fill="green" stroke="#000" d="M316 0h101v20H316z"/><path fill="url(#smooth)" d="M0 0h417v20H0z"/></g><g id="fg"><text class="shadow" x="5.5" y="15">Statements 98.67%</text><text class="high" x="5" y="14">Statements 98.67%</text><text class="shadow" x="125.5" y="15">Branches 97.79%</text><text class="high" x="125" y="14">Branches 97.79%</text><text class="shadow" x="234.5" y="15">Lines 98.67%</text><text class="high" x="234" y="14">Lines 98.67%</text><text class="shadow" x="321.5" y="15">Functions 100%</text><text class="high" x="321" y="14">Functions 100%</text></g></svg> +<svg xmlns="http://www.w3.org/2000/svg" width="384" height="20"><defs><style>text{font-size:11px;font-family:Verdana,DejaVu Sans,Geneva,sans-serif}text.shadow{fill:#010101;fill-opacity:.3}text.high{fill:#fff}</style><linearGradient id="smooth" x2="0" y2="100%"><stop offset="0" stop-color="#aaa" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><mask id="round"><rect width="100%" height="100%" rx="3" fill="#fff"/></mask></defs><g id="bg" mask="url(#round)"><path fill="green" stroke="#000" d="M0 0h109v20H0zM109 0h98v20h-98zM207 0h76v20h-76zM283 0h101v20H283z"/><path fill="url(#smooth)" d="M0 0h384v20H0z"/></g><g id="fg"><text class="shadow" x="5.5" y="15">Statements 100%</text><text class="high" x="5" y="14">Statements 100%</text><text class="shadow" x="114.5" y="15">Branches 100%</text><text class="high" x="114" y="14">Branches 100%</text><text class="shadow" x="212.5" y="15">Lines 100%</text><text class="high" x="212" y="14">Lines 100%</text><text class="shadow" x="288.5" y="15">Functions 100%</text><text class="high" x="288" y="14">Functions 100%</text></g></svg>
badges/licenses-badge-dev.svg+1 −1 modified@@ -1 +1 @@ -<svg xmlns="http://www.w3.org/2000/svg" width="585" height="176"><defs><style>text{font-size:11px;font-family:Verdana,DejaVu Sans,Geneva,sans-serif}text.shadow{fill:#010101;fill-opacity:.3}text.high{fill:#fff}</style><linearGradient id="smooth" x2="0" y2="100%"><stop offset="0" stop-color="#aaa" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><mask id="round"><rect width="100%" height="100%" rx="3" fill="#fff"/></mask></defs><g id="bg" mask="url(#round)"><path fill="navy" d="M0 0h88v176H0z"/><path fill="#006400" d="M88 0h131v176H88z"/><path fill="green" d="M219 0h266v176H219z"/><path fill="#d3d3d3" d="M485 0h100v176H485z"/><path fill="url(#smooth)" d="M0 0h585v176H0z"/></g><g id="fg"><text class="shadow" x="5.5" y="15">License types</text><text class="high" x="5" y="14">License types</text><text class="shadow" x="5.5" y="27">(all devDeps)</text><text class="high" x="5" y="26">(all devDeps)</text><text class="shadow" x="93.5" y="15">Public</text><text class="high" x="93" y="14">Public</text><text class="shadow" x="93.5" y="27">domain</text><text class="high" x="93" y="26">domain</text><text class="shadow" x="93.5" y="51">1. (MIT OR CC0-1.0)</text><text class="high" x="93" y="50">1. (MIT OR CC0-1.0)</text><text class="shadow" x="93.5" y="63">2. CC0-1.0</text><text class="high" x="93" y="62">2. CC0-1.0</text><text class="shadow" x="224.5" y="15">Permissive</text><text class="high" x="224" y="14">Permissive</text><text class="shadow" x="224.5" y="39">1. (BSD-2-Clause OR (MIT OR Apache-2.0))</text><text class="high" x="224" y="38">1. (BSD-2-Clause OR (MIT OR Apache-2.0))</text><text class="shadow" x="224.5" y="51">2. (MIT OR CC0-1.0)</text><text class="high" x="224" y="50">2. (MIT OR CC0-1.0)</text><text class="shadow" x="224.5" y="63">3. (WTFPL OR MIT)</text><text class="high" x="224" y="62">3. (WTFPL OR MIT)</text><text class="shadow" x="224.5" y="75">4. Apache-2.0</text><text class="high" x="224" y="74">4. Apache-2.0</text><text class="shadow" x="224.5" y="87">5. BSD-2-Clause</text><text class="high" x="224" y="86">5. BSD-2-Clause</text><text class="shadow" x="224.5" y="99">6. BSD-3-Clause</text><text class="high" x="224" y="98">6. BSD-3-Clause</text><text class="shadow" x="224.5" y="111">7. BlueOak-1.0.0</text><text class="high" x="224" y="110">7. BlueOak-1.0.0</text><text class="shadow" x="224.5" y="123">8. CC-BY-3.0</text><text class="high" x="224" y="122">8. CC-BY-3.0</text><text class="shadow" x="224.5" y="135">9. CC-BY-4.0</text><text class="high" x="224" y="134">9. CC-BY-4.0</text><text class="shadow" x="224.5" y="147">10. ISC</text><text class="high" x="224" y="146">10. ISC</text><text class="shadow" x="224.5" y="159">11. MIT</text><text class="high" x="224" y="158">11. MIT</text><text class="shadow" x="224.5" y="171">12. Python-2.0</text><text class="high" x="224" y="170">12. Python-2.0</text><text class="shadow" x="490.5" y="15">Missing</text><text class="high" x="490" y="14">Missing</text><text class="shadow" x="490.5" y="39">1. union (0.5.0)</text><text class="high" x="490" y="38">1. union (0.5.0)</text></g></svg> \ No newline at end of file +<svg xmlns="http://www.w3.org/2000/svg" width="585" height="176"><defs><style>text{font-size:11px;font-family:Verdana,DejaVu Sans,Geneva,sans-serif}text.shadow{fill:#010101;fill-opacity:.3}text.high{fill:#fff}</style><linearGradient id="smooth" x2="0" y2="100%"><stop offset="0" stop-color="#aaa" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><mask id="round"><rect width="100%" height="100%" rx="3" fill="#fff"/></mask></defs><g id="bg" mask="url(#round)"><path fill="navy" d="M0 0h88v176H0z"/><path fill="#006400" d="M88 0h131v176H88z"/><path fill="green" d="M219 0h266v176H219z"/><path fill="#d3d3d3" d="M485 0h100v176H485z"/><path fill="url(#smooth)" d="M0 0h585v176H0z"/></g><g id="fg"><text class="shadow" x="5.5" y="15">License types</text><text class="high" x="5" y="14">License types</text><text class="shadow" x="5.5" y="27">(all devDeps)</text><text class="high" x="5" y="26">(all devDeps)</text><text class="shadow" x="93.5" y="15">Public</text><text class="high" x="93" y="14">Public</text><text class="shadow" x="93.5" y="27">domain</text><text class="high" x="93" y="26">domain</text><text class="shadow" x="93.5" y="51">1. (MIT OR CC0-1.0)</text><text class="high" x="93" y="50">1. (MIT OR CC0-1.0)</text><text class="shadow" x="93.5" y="63">2. CC0-1.0</text><text class="high" x="93" y="62">2. CC0-1.0</text><text class="shadow" x="224.5" y="15">Permissive</text><text class="high" x="224" y="14">Permissive</text><text class="shadow" x="224.5" y="39">1. (BSD-2-Clause OR (MIT OR Apache-2.0))</text><text class="high" x="224" y="38">1. (BSD-2-Clause OR (MIT OR Apache-2.0))</text><text class="shadow" x="224.5" y="51">2. (MIT OR CC0-1.0)</text><text class="high" x="224" y="50">2. (MIT OR CC0-1.0)</text><text class="shadow" x="224.5" y="63">3. (WTFPL OR MIT)</text><text class="high" x="224" y="62">3. (WTFPL OR MIT)</text><text class="shadow" x="224.5" y="75">4. Apache-2.0</text><text class="high" x="224" y="74">4. Apache-2.0</text><text class="shadow" x="224.5" y="87">5. BSD-2-Clause</text><text class="high" x="224" y="86">5. BSD-2-Clause</text><text class="shadow" x="224.5" y="99">6. BSD-3-Clause</text><text class="high" x="224" y="98">6. BSD-3-Clause</text><text class="shadow" x="224.5" y="111">7. BlueOak-1.0.0</text><text class="high" x="224" y="110">7. BlueOak-1.0.0</text><text class="shadow" x="224.5" y="123">8. CC-BY-3.0</text><text class="high" x="224" y="122">8. CC-BY-3.0</text><text class="shadow" x="224.5" y="135">9. CC-BY-4.0</text><text class="high" x="224" y="134">9. CC-BY-4.0</text><text class="shadow" x="224.5" y="147">10. ISC</text><text class="high" x="224" y="146">10. ISC</text><text class="shadow" x="224.5" y="159">11. MIT</text><text class="high" x="224" y="158">11. MIT</text><text class="shadow" x="224.5" y="171">12. Python-2.0</text><text class="high" x="224" y="170">12. Python-2.0</text><text class="shadow" x="490.5" y="15">Missing</text><text class="high" x="490" y="14">Missing</text><text class="shadow" x="490.5" y="39">1. union (0.5.0)</text><text class="high" x="490" y="38">1. union (0.5.0)</text></g></svg>
badges/tests-badge.svg+1 −1 modified@@ -1 +1 @@ -<svg xmlns="http://www.w3.org/2000/svg" width="97" height="20"><defs><style>text{font-size:11px;font-family:Verdana,DejaVu Sans,Geneva,sans-serif}text.shadow{fill:#010101;fill-opacity:.3}text.high{fill:#fff}</style><linearGradient id="smooth" x2="0" y2="100%"><stop offset="0" stop-color="#aaa" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><mask id="round"><rect width="100%" height="100%" rx="3" fill="#fff"/></mask></defs><g id="bg" mask="url(#round)"><path fill="#696969" d="M0 0h41v20H0z"/><path fill="#4c1" d="M41 0h56v20H41z"/><path fill="url(#smooth)" d="M0 0h97v20H0z"/></g><g id="fg"><text class="shadow" x="5.5" y="15">Tests</text><text class="high" x="5" y="14">Tests</text><text class="shadow" x="46.5" y="15">267/267</text><text class="high" x="46" y="14">267/267</text></g></svg> \ No newline at end of file +<svg xmlns="http://www.w3.org/2000/svg" width="97" height="20"><defs><style>text{font-size:11px;font-family:Verdana,DejaVu Sans,Geneva,sans-serif}text.shadow{fill:#010101;fill-opacity:.3}text.high{fill:#fff}</style><linearGradient id="smooth" x2="0" y2="100%"><stop offset="0" stop-color="#aaa" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><mask id="round"><rect width="100%" height="100%" rx="3" fill="#fff"/></mask></defs><g id="bg" mask="url(#round)"><path fill="#696969" d="M0 0h41v20H0z"/><path fill="#4c1" d="M41 0h56v20H41z"/><path fill="url(#smooth)" d="M0 0h97v20H0z"/></g><g id="fg"><text class="shadow" x="5.5" y="15">Tests</text><text class="high" x="5" y="14">Tests</text><text class="shadow" x="46.5" y="15">273/273</text><text class="high" x="46" y="14">273/273</text></g></svg> \ No newline at end of file
dist/index-browser-esm.js+13 −22 modified@@ -1203,6 +1203,7 @@ jsep.plugins.register(index, plugin); jsep.addUnaryOp('typeof'); jsep.addLiteral('null', null); jsep.addLiteral('undefined', undefined); +const BLOCKED_PROTO_PROPERTIES = new Set(['constructor', '__proto__', '__defineGetter__', '__defineSetter__']); const SafeEval = { /** * @param {jsep.Expression} ast @@ -1285,7 +1286,7 @@ const SafeEval = { return SafeEval.evalAst(ast.alternate, subs); }, evalIdentifier(ast, subs) { - if (ast.name in subs) { + if (Object.hasOwn(subs, ast.name)) { return subs[ast.name]; } throw ReferenceError(`${ast.name} is not defined`); @@ -1294,23 +1295,17 @@ const SafeEval = { return ast.value; }, evalMemberExpression(ast, subs) { - if (ast.property.type === 'Identifier' && ast.property.name === 'constructor' || ast.object.type === 'Identifier' && ast.object.name === 'constructor') { - throw new Error("'constructor' property is disabled"); - } const prop = ast.computed ? SafeEval.evalAst(ast.property) // `object[property]` : ast.property.name; // `object.property` property is Identifier const obj = SafeEval.evalAst(ast.object, subs); + if (obj === undefined || obj === null) { + throw TypeError(`Cannot read properties of ${obj} (reading '${prop}')`); + } + if (!Object.hasOwn(obj, prop) && BLOCKED_PROTO_PROPERTIES.has(prop)) { + throw TypeError(`Cannot read properties of ${obj} (reading '${prop}')`); + } const result = obj[prop]; if (typeof result === 'function') { - if (obj === Function && prop === 'bind') { - throw new Error('Function.prototype.bind is disabled'); - } - if (obj === Function && (prop === 'call' || prop === 'apply')) { - throw new Error('Function.prototype.call and ' + 'Function.prototype.apply are disabled'); - } - if (result === Function) { - return result; // Don't bind so can identify and throw later - } return result.bind(obj); // arrow functions aren't affected by bind. } return result; @@ -1332,19 +1327,16 @@ const SafeEval = { evalCallExpression(ast, subs) { const args = ast.arguments.map(arg => SafeEval.evalAst(arg, subs)); const func = SafeEval.evalAst(ast.callee, subs); - if (func === Function) { - throw new Error('Function constructor is disabled'); - } + // if (func === Function) { + // throw new Error('Function constructor is disabled'); + // } return func(...args); }, evalAssignmentExpression(ast, subs) { if (ast.left.type !== 'Identifier') { throw SyntaxError('Invalid left-hand side in assignment'); } const id = ast.left.name; - if (id === '__proto__') { - throw new Error('Assignment to __proto__ is disabled'); - } const value = SafeEval.evalAst(ast.right, subs); subs[id] = value; return subs[id]; @@ -1369,9 +1361,8 @@ class SafeScript { * @returns {EvaluatedResult} Result of evaluated code */ runInNewContext(context) { - const keyMap = { - ...context - }; + // `Object.create(null)` creates a prototypeless object + const keyMap = Object.assign(Object.create(null), context); return SafeEval.evalAst(this.ast, keyMap); } }
dist/index-browser-esm.min.js+1 −1 modified@@ -1,2 +1,2 @@ -class e{static get version(){return"1.3.9"}static toString(){return"JavaScript Expression Parser (JSEP) v"+e.version}static addUnaryOp(t){return e.max_unop_len=Math.max(t.length,e.max_unop_len),e.unary_ops[t]=1,e}static addBinaryOp(t,r,n){return e.max_binop_len=Math.max(t.length,e.max_binop_len),e.binary_ops[t]=r,n?e.right_associative.add(t):e.right_associative.delete(t),e}static addIdentifierChar(t){return e.additional_identifier_chars.add(t),e}static addLiteral(t,r){return e.literals[t]=r,e}static removeUnaryOp(t){return delete e.unary_ops[t],t.length===e.max_unop_len&&(e.max_unop_len=e.getMaxKeyLen(e.unary_ops)),e}static removeAllUnaryOps(){return e.unary_ops={},e.max_unop_len=0,e}static removeIdentifierChar(t){return e.additional_identifier_chars.delete(t),e}static removeBinaryOp(t){return delete e.binary_ops[t],t.length===e.max_binop_len&&(e.max_binop_len=e.getMaxKeyLen(e.binary_ops)),e.right_associative.delete(t),e}static removeAllBinaryOps(){return e.binary_ops={},e.max_binop_len=0,e}static removeLiteral(t){return delete e.literals[t],e}static removeAllLiterals(){return e.literals={},e}get char(){return this.expr.charAt(this.index)}get code(){return this.expr.charCodeAt(this.index)}constructor(e){this.expr=e,this.index=0}static parse(t){return new e(t).parse()}static getMaxKeyLen(e){return Math.max(0,...Object.keys(e).map((e=>e.length)))}static isDecimalDigit(e){return e>=48&&e<=57}static binaryPrecedence(t){return e.binary_ops[t]||0}static isIdentifierStart(t){return t>=65&&t<=90||t>=97&&t<=122||t>=128&&!e.binary_ops[String.fromCharCode(t)]||e.additional_identifier_chars.has(String.fromCharCode(t))}static isIdentifierPart(t){return e.isIdentifierStart(t)||e.isDecimalDigit(t)}throwError(e){const t=new Error(e+" at character "+this.index);throw t.index=this.index,t.description=e,t}runHook(t,r){if(e.hooks[t]){const n={context:this,node:r};return e.hooks.run(t,n),n.node}return r}searchHook(t){if(e.hooks[t]){const r={context:this};return e.hooks[t].find((function(e){return e.call(r.context,r),r.node})),r.node}}gobbleSpaces(){let t=this.code;for(;t===e.SPACE_CODE||t===e.TAB_CODE||t===e.LF_CODE||t===e.CR_CODE;)t=this.expr.charCodeAt(++this.index);this.runHook("gobble-spaces")}parse(){this.runHook("before-all");const t=this.gobbleExpressions(),r=1===t.length?t[0]:{type:e.COMPOUND,body:t};return this.runHook("after-all",r)}gobbleExpressions(t){let r,n,i=[];for(;this.index<this.expr.length;)if(r=this.code,r===e.SEMCOL_CODE||r===e.COMMA_CODE)this.index++;else if(n=this.gobbleExpression())i.push(n);else if(this.index<this.expr.length){if(r===t)break;this.throwError('Unexpected "'+this.char+'"')}return i}gobbleExpression(){const e=this.searchHook("gobble-expression")||this.gobbleBinaryExpression();return this.gobbleSpaces(),this.runHook("after-expression",e)}gobbleBinaryOp(){this.gobbleSpaces();let t=this.expr.substr(this.index,e.max_binop_len),r=t.length;for(;r>0;){if(e.binary_ops.hasOwnProperty(t)&&(!e.isIdentifierStart(this.code)||this.index+t.length<this.expr.length&&!e.isIdentifierPart(this.expr.charCodeAt(this.index+t.length))))return this.index+=r,t;t=t.substr(0,--r)}return!1}gobbleBinaryExpression(){let t,r,n,i,s,o,a,h,l;if(o=this.gobbleToken(),!o)return o;if(r=this.gobbleBinaryOp(),!r)return o;for(s={value:r,prec:e.binaryPrecedence(r),right_a:e.right_associative.has(r)},a=this.gobbleToken(),a||this.throwError("Expected expression after "+r),i=[o,s,a];r=this.gobbleBinaryOp();){if(n=e.binaryPrecedence(r),0===n){this.index-=r.length;break}s={value:r,prec:n,right_a:e.right_associative.has(r)},l=r;const h=e=>s.right_a&&e.right_a?n>e.prec:n<=e.prec;for(;i.length>2&&h(i[i.length-2]);)a=i.pop(),r=i.pop().value,o=i.pop(),t={type:e.BINARY_EXP,operator:r,left:o,right:a},i.push(t);t=this.gobbleToken(),t||this.throwError("Expected expression after "+l),i.push(s,t)}for(h=i.length-1,t=i[h];h>1;)t={type:e.BINARY_EXP,operator:i[h-1].value,left:i[h-2],right:t},h-=2;return t}gobbleToken(){let t,r,n,i;if(this.gobbleSpaces(),i=this.searchHook("gobble-token"),i)return this.runHook("after-token",i);if(t=this.code,e.isDecimalDigit(t)||t===e.PERIOD_CODE)return this.gobbleNumericLiteral();if(t===e.SQUOTE_CODE||t===e.DQUOTE_CODE)i=this.gobbleStringLiteral();else if(t===e.OBRACK_CODE)i=this.gobbleArray();else{for(r=this.expr.substr(this.index,e.max_unop_len),n=r.length;n>0;){if(e.unary_ops.hasOwnProperty(r)&&(!e.isIdentifierStart(this.code)||this.index+r.length<this.expr.length&&!e.isIdentifierPart(this.expr.charCodeAt(this.index+r.length)))){this.index+=n;const t=this.gobbleToken();return t||this.throwError("missing unaryOp argument"),this.runHook("after-token",{type:e.UNARY_EXP,operator:r,argument:t,prefix:!0})}r=r.substr(0,--n)}e.isIdentifierStart(t)?(i=this.gobbleIdentifier(),e.literals.hasOwnProperty(i.name)?i={type:e.LITERAL,value:e.literals[i.name],raw:i.name}:i.name===e.this_str&&(i={type:e.THIS_EXP})):t===e.OPAREN_CODE&&(i=this.gobbleGroup())}return i?(i=this.gobbleTokenProperty(i),this.runHook("after-token",i)):this.runHook("after-token",!1)}gobbleTokenProperty(t){this.gobbleSpaces();let r=this.code;for(;r===e.PERIOD_CODE||r===e.OBRACK_CODE||r===e.OPAREN_CODE||r===e.QUMARK_CODE;){let n;if(r===e.QUMARK_CODE){if(this.expr.charCodeAt(this.index+1)!==e.PERIOD_CODE)break;n=!0,this.index+=2,this.gobbleSpaces(),r=this.code}this.index++,r===e.OBRACK_CODE?((t={type:e.MEMBER_EXP,computed:!0,object:t,property:this.gobbleExpression()}).property||this.throwError('Unexpected "'+this.char+'"'),this.gobbleSpaces(),r=this.code,r!==e.CBRACK_CODE&&this.throwError("Unclosed ["),this.index++):r===e.OPAREN_CODE?t={type:e.CALL_EXP,arguments:this.gobbleArguments(e.CPAREN_CODE),callee:t}:(r===e.PERIOD_CODE||n)&&(n&&this.index--,this.gobbleSpaces(),t={type:e.MEMBER_EXP,computed:!1,object:t,property:this.gobbleIdentifier()}),n&&(t.optional=!0),this.gobbleSpaces(),r=this.code}return t}gobbleNumericLiteral(){let t,r,n="";for(;e.isDecimalDigit(this.code);)n+=this.expr.charAt(this.index++);if(this.code===e.PERIOD_CODE)for(n+=this.expr.charAt(this.index++);e.isDecimalDigit(this.code);)n+=this.expr.charAt(this.index++);if(t=this.char,"e"===t||"E"===t){for(n+=this.expr.charAt(this.index++),t=this.char,"+"!==t&&"-"!==t||(n+=this.expr.charAt(this.index++));e.isDecimalDigit(this.code);)n+=this.expr.charAt(this.index++);e.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+n+this.char+")")}return r=this.code,e.isIdentifierStart(r)?this.throwError("Variable names cannot start with a number ("+n+this.char+")"):(r===e.PERIOD_CODE||1===n.length&&n.charCodeAt(0)===e.PERIOD_CODE)&&this.throwError("Unexpected period"),{type:e.LITERAL,value:parseFloat(n),raw:n}}gobbleStringLiteral(){let t="";const r=this.index,n=this.expr.charAt(this.index++);let i=!1;for(;this.index<this.expr.length;){let e=this.expr.charAt(this.index++);if(e===n){i=!0;break}if("\\"===e)switch(e=this.expr.charAt(this.index++),e){case"n":t+="\n";break;case"r":t+="\r";break;case"t":t+="\t";break;case"b":t+="\b";break;case"f":t+="\f";break;case"v":t+="\v";break;default:t+=e}else t+=e}return i||this.throwError('Unclosed quote after "'+t+'"'),{type:e.LITERAL,value:t,raw:this.expr.substring(r,this.index)}}gobbleIdentifier(){let t=this.code,r=this.index;for(e.isIdentifierStart(t)?this.index++:this.throwError("Unexpected "+this.char);this.index<this.expr.length&&(t=this.code,e.isIdentifierPart(t));)this.index++;return{type:e.IDENTIFIER,name:this.expr.slice(r,this.index)}}gobbleArguments(t){const r=[];let n=!1,i=0;for(;this.index<this.expr.length;){this.gobbleSpaces();let s=this.code;if(s===t){n=!0,this.index++,t===e.CPAREN_CODE&&i&&i>=r.length&&this.throwError("Unexpected token "+String.fromCharCode(t));break}if(s===e.COMMA_CODE){if(this.index++,i++,i!==r.length)if(t===e.CPAREN_CODE)this.throwError("Unexpected token ,");else if(t===e.CBRACK_CODE)for(let e=r.length;e<i;e++)r.push(null)}else if(r.length!==i&&0!==i)this.throwError("Expected comma");else{const t=this.gobbleExpression();t&&t.type!==e.COMPOUND||this.throwError("Expected comma"),r.push(t)}}return n||this.throwError("Expected "+String.fromCharCode(t)),r}gobbleGroup(){this.index++;let t=this.gobbleExpressions(e.CPAREN_CODE);if(this.code===e.CPAREN_CODE)return this.index++,1===t.length?t[0]:!!t.length&&{type:e.SEQUENCE_EXP,expressions:t};this.throwError("Unclosed (")}gobbleArray(){return this.index++,{type:e.ARRAY_EXP,elements:this.gobbleArguments(e.CBRACK_CODE)}}}const t=new class{add(e,t,r){if("string"!=typeof arguments[0])for(let e in arguments[0])this.add(e,arguments[0][e],arguments[1]);else(Array.isArray(e)?e:[e]).forEach((function(e){this[e]=this[e]||[],t&&this[e][r?"unshift":"push"](t)}),this)}run(e,t){this[e]=this[e]||[],this[e].forEach((function(e){e.call(t&&t.context?t.context:t,t)}))}};Object.assign(e,{hooks:t,plugins:new class{constructor(e){this.jsep=e,this.registered={}}register(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];t.forEach((e=>{if("object"!=typeof e||!e.name||!e.init)throw new Error("Invalid JSEP plugin format");this.registered[e.name]||(e.init(this.jsep),this.registered[e.name]=e)}))}}(e),COMPOUND:"Compound",SEQUENCE_EXP:"SequenceExpression",IDENTIFIER:"Identifier",MEMBER_EXP:"MemberExpression",LITERAL:"Literal",THIS_EXP:"ThisExpression",CALL_EXP:"CallExpression",UNARY_EXP:"UnaryExpression",BINARY_EXP:"BinaryExpression",ARRAY_EXP:"ArrayExpression",TAB_CODE:9,LF_CODE:10,CR_CODE:13,SPACE_CODE:32,PERIOD_CODE:46,COMMA_CODE:44,SQUOTE_CODE:39,DQUOTE_CODE:34,OPAREN_CODE:40,CPAREN_CODE:41,OBRACK_CODE:91,CBRACK_CODE:93,QUMARK_CODE:63,SEMCOL_CODE:59,COLON_CODE:58,unary_ops:{"-":1,"!":1,"~":1,"+":1},binary_ops:{"||":1,"&&":2,"|":3,"^":4,"&":5,"==":6,"!=":6,"===":6,"!==":6,"<":7,">":7,"<=":7,">=":7,"<<":8,">>":8,">>>":8,"+":9,"-":9,"*":10,"/":10,"%":10},right_associative:new Set,additional_identifier_chars:new Set(["$","_"]),literals:{true:!0,false:!1,null:null},this_str:"this"}),e.max_unop_len=e.getMaxKeyLen(e.unary_ops),e.max_binop_len=e.getMaxKeyLen(e.binary_ops);const r=t=>new e(t).parse(),n=Object.getOwnPropertyNames(class{});Object.getOwnPropertyNames(e).filter((e=>!n.includes(e)&&void 0===r[e])).forEach((t=>{r[t]=e[t]})),r.Jsep=e;var i={name:"ternary",init(e){e.hooks.add("after-expression",(function(t){if(t.node&&this.code===e.QUMARK_CODE){this.index++;const r=t.node,n=this.gobbleExpression();if(n||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===e.COLON_CODE){this.index++;const i=this.gobbleExpression();if(i||this.throwError("Expected expression"),t.node={type:"ConditionalExpression",test:r,consequent:n,alternate:i},r.operator&&e.binary_ops[r.operator]<=.9){let n=r;for(;n.right.operator&&e.binary_ops[n.right.operator]<=.9;)n=n.right;t.node.test=n.right,n.right=t.node,t.node=r}}else this.throwError("Expected :")}}))}};r.plugins.register(i);var s={name:"regex",init(e){e.hooks.add("gobble-token",(function(t){if(47===this.code){const r=++this.index;let n=!1;for(;this.index<this.expr.length;){if(47===this.code&&!n){const n=this.expr.slice(r,this.index);let i,s="";for(;++this.index<this.expr.length;){const e=this.code;if(!(e>=97&&e<=122||e>=65&&e<=90||e>=48&&e<=57))break;s+=this.char}try{i=new RegExp(n,s)}catch(e){this.throwError(e.message)}return t.node={type:e.LITERAL,value:i,raw:this.expr.slice(r-1,this.index)},t.node=this.gobbleTokenProperty(t.node),t.node}this.code===e.OBRACK_CODE?n=!0:n&&this.code===e.CBRACK_CODE&&(n=!1),this.index+=92===this.code?2:1}this.throwError("Unclosed Regex")}}))}};const o={name:"assignment",assignmentOperators:new Set(["=","*=","**=","/=","%=","+=","-=","<<=",">>=",">>>=","&=","^=","|="]),updateOperators:[43,45],assignmentPrecedence:.9,init(e){const t=[e.IDENTIFIER,e.MEMBER_EXP];function r(e){o.assignmentOperators.has(e.operator)?(e.type="AssignmentExpression",r(e.left),r(e.right)):e.operator||Object.values(e).forEach((e=>{e&&"object"==typeof e&&r(e)}))}o.assignmentOperators.forEach((t=>e.addBinaryOp(t,o.assignmentPrecedence,!0))),e.hooks.add("gobble-token",(function(e){const r=this.code;o.updateOperators.some((e=>e===r&&e===this.expr.charCodeAt(this.index+1)))&&(this.index+=2,e.node={type:"UpdateExpression",operator:43===r?"++":"--",argument:this.gobbleTokenProperty(this.gobbleIdentifier()),prefix:!0},e.node.argument&&t.includes(e.node.argument.type)||this.throwError(`Unexpected ${e.node.operator}`))})),e.hooks.add("after-token",(function(e){if(e.node){const r=this.code;o.updateOperators.some((e=>e===r&&e===this.expr.charCodeAt(this.index+1)))&&(t.includes(e.node.type)||this.throwError(`Unexpected ${e.node.operator}`),this.index+=2,e.node={type:"UpdateExpression",operator:43===r?"++":"--",argument:e.node,prefix:!1})}})),e.hooks.add("after-expression",(function(e){e.node&&r(e.node)}))}};r.plugins.register(s,o),r.addUnaryOp("typeof"),r.addLiteral("null",null),r.addLiteral("undefined",void 0);const a={evalAst(e,t){switch(e.type){case"BinaryExpression":case"LogicalExpression":return a.evalBinaryExpression(e,t);case"Compound":return a.evalCompound(e,t);case"ConditionalExpression":return a.evalConditionalExpression(e,t);case"Identifier":return a.evalIdentifier(e,t);case"Literal":return a.evalLiteral(e,t);case"MemberExpression":return a.evalMemberExpression(e,t);case"UnaryExpression":return a.evalUnaryExpression(e,t);case"ArrayExpression":return a.evalArrayExpression(e,t);case"CallExpression":return a.evalCallExpression(e,t);case"AssignmentExpression":return a.evalAssignmentExpression(e,t);default:throw SyntaxError("Unexpected expression",e)}},evalBinaryExpression:(e,t)=>({"||":(e,t)=>e||t(),"&&":(e,t)=>e&&t(),"|":(e,t)=>e|t(),"^":(e,t)=>e^t(),"&":(e,t)=>e&t(),"==":(e,t)=>e==t(),"!=":(e,t)=>e!=t(),"===":(e,t)=>e===t(),"!==":(e,t)=>e!==t(),"<":(e,t)=>e<t(),">":(e,t)=>e>t(),"<=":(e,t)=>e<=t(),">=":(e,t)=>e>=t(),"<<":(e,t)=>e<<t(),">>":(e,t)=>e>>t(),">>>":(e,t)=>e>>>t(),"+":(e,t)=>e+t(),"-":(e,t)=>e-t(),"*":(e,t)=>e*t(),"/":(e,t)=>e/t(),"%":(e,t)=>e%t()}[e.operator](a.evalAst(e.left,t),(()=>a.evalAst(e.right,t)))),evalCompound(e,t){let r;for(let n=0;n<e.body.length;n++){"Identifier"===e.body[n].type&&["var","let","const"].includes(e.body[n].name)&&e.body[n+1]&&"AssignmentExpression"===e.body[n+1].type&&(n+=1);const i=e.body[n];r=a.evalAst(i,t)}return r},evalConditionalExpression:(e,t)=>a.evalAst(e.test,t)?a.evalAst(e.consequent,t):a.evalAst(e.alternate,t),evalIdentifier(e,t){if(e.name in t)return t[e.name];throw ReferenceError(`${e.name} is not defined`)},evalLiteral:e=>e.value,evalMemberExpression(e,t){if("Identifier"===e.property.type&&"constructor"===e.property.name||"Identifier"===e.object.type&&"constructor"===e.object.name)throw new Error("'constructor' property is disabled");const r=e.computed?a.evalAst(e.property):e.property.name,n=a.evalAst(e.object,t),i=n[r];if("function"==typeof i){if(n===Function&&"bind"===r)throw new Error("Function.prototype.bind is disabled");if(n===Function&&("call"===r||"apply"===r))throw new Error("Function.prototype.call and Function.prototype.apply are disabled");return i===Function?i:i.bind(n)}return i},evalUnaryExpression:(e,t)=>({"-":e=>-a.evalAst(e,t),"!":e=>!a.evalAst(e,t),"~":e=>~a.evalAst(e,t),"+":e=>+a.evalAst(e,t),typeof:e=>typeof a.evalAst(e,t)}[e.operator](e.argument)),evalArrayExpression:(e,t)=>e.elements.map((e=>a.evalAst(e,t))),evalCallExpression(e,t){const r=e.arguments.map((e=>a.evalAst(e,t))),n=a.evalAst(e.callee,t);if(n===Function)throw new Error("Function constructor is disabled");return n(...r)},evalAssignmentExpression(e,t){if("Identifier"!==e.left.type)throw SyntaxError("Invalid left-hand side in assignment");const r=e.left.name;if("__proto__"===r)throw new Error("Assignment to __proto__ is disabled");const n=a.evalAst(e.right,t);return t[r]=n,t[r]}};function h(e,t){return(e=e.slice()).push(t),e}function l(e,t){return(t=t.slice()).unshift(e),t}class c extends Error{constructor(e){super('JSONPath should not be called with "new" (it prevents return of (unwrapped) scalar values)'),this.avoidNew=!0,this.value=e,this.name="NewError"}}function p(e,t,r,n,i){if(!(this instanceof p))try{return new p(e,t,r,n,i)}catch(e){if(!e.avoidNew)throw e;return e.value}"string"==typeof e&&(i=n,n=r,r=t,t=e,e=null);const s=e&&"object"==typeof e;if(e=e||{},this.json=e.json||r,this.path=e.path||t,this.resultType=e.resultType||"value",this.flatten=e.flatten||!1,this.wrap=!Object.hasOwn(e,"wrap")||e.wrap,this.sandbox=e.sandbox||{},this.eval=void 0===e.eval?"safe":e.eval,this.ignoreEvalErrors=void 0!==e.ignoreEvalErrors&&e.ignoreEvalErrors,this.parent=e.parent||null,this.parentProperty=e.parentProperty||null,this.callback=e.callback||n||null,this.otherTypeCallback=e.otherTypeCallback||i||function(){throw new TypeError("You must supply an otherTypeCallback callback option with the @other() operator.")},!1!==e.autostart){const n={path:s?e.path:t};s?"json"in e&&(n.json=e.json):n.json=r;const i=this.evaluate(n);if(!i||"object"!=typeof i)throw new c(i);return i}}p.prototype.evaluate=function(e,t,r,n){let i=this.parent,s=this.parentProperty,{flatten:o,wrap:a}=this;if(this.currResultType=this.resultType,this.currEval=this.eval,this.currSandbox=this.sandbox,r=r||this.callback,this.currOtherTypeCallback=n||this.otherTypeCallback,t=t||this.json,(e=e||this.path)&&"object"==typeof e&&!Array.isArray(e)){if(!e.path&&""!==e.path)throw new TypeError('You must supply a "path" property when providing an object argument to JSONPath.evaluate().');if(!Object.hasOwn(e,"json"))throw new TypeError('You must supply a "json" property when providing an object argument to JSONPath.evaluate().');({json:t}=e),o=Object.hasOwn(e,"flatten")?e.flatten:o,this.currResultType=Object.hasOwn(e,"resultType")?e.resultType:this.currResultType,this.currSandbox=Object.hasOwn(e,"sandbox")?e.sandbox:this.currSandbox,a=Object.hasOwn(e,"wrap")?e.wrap:a,this.currEval=Object.hasOwn(e,"eval")?e.eval:this.currEval,r=Object.hasOwn(e,"callback")?e.callback:r,this.currOtherTypeCallback=Object.hasOwn(e,"otherTypeCallback")?e.otherTypeCallback:this.currOtherTypeCallback,i=Object.hasOwn(e,"parent")?e.parent:i,s=Object.hasOwn(e,"parentProperty")?e.parentProperty:s,e=e.path}if(i=i||null,s=s||null,Array.isArray(e)&&(e=p.toPathString(e)),!e&&""!==e||!t)return;const h=p.toPathArray(e);"$"===h[0]&&h.length>1&&h.shift(),this._hasParentSelector=null;const l=this._trace(h,t,["$"],i,s,r).filter((function(e){return e&&!e.isParentSelector}));return l.length?a||1!==l.length||l[0].hasArrExpr?l.reduce(((e,t)=>{const r=this._getPreferredOutput(t);return o&&Array.isArray(r)?e=e.concat(r):e.push(r),e}),[]):this._getPreferredOutput(l[0]):a?[]:void 0},p.prototype._getPreferredOutput=function(e){const t=this.currResultType;switch(t){case"all":{const t=Array.isArray(e.path)?e.path:p.toPathArray(e.path);return e.pointer=p.toPointer(t),e.path="string"==typeof e.path?e.path:p.toPathString(e.path),e}case"value":case"parent":case"parentProperty":return e[t];case"path":return p.toPathString(e[t]);case"pointer":return p.toPointer(e.path);default:throw new TypeError("Unknown result type")}},p.prototype._handleCallback=function(e,t,r){if(t){const n=this._getPreferredOutput(e);e.path="string"==typeof e.path?e.path:p.toPathString(e.path),t(n,r,e)}},p.prototype._trace=function(e,t,r,n,i,s,o,a){let c;if(!e.length)return c={path:r,value:t,parent:n,parentProperty:i,hasArrExpr:o},this._handleCallback(c,s,"value"),c;const p=e[0],u=e.slice(1),d=[];function f(e){Array.isArray(e)?e.forEach((e=>{d.push(e)})):d.push(e)}if(("string"!=typeof p||a)&&t&&Object.hasOwn(t,p))f(this._trace(u,t[p],h(r,p),t,p,s,o));else if("*"===p)this._walk(t,(e=>{f(this._trace(u,t[e],h(r,e),t,e,s,!0,!0))}));else if(".."===p)f(this._trace(u,t,r,n,i,s,o)),this._walk(t,(n=>{"object"==typeof t[n]&&f(this._trace(e.slice(),t[n],h(r,n),t,n,s,!0))}));else{if("^"===p)return this._hasParentSelector=!0,{path:r.slice(0,-1),expr:u,isParentSelector:!0};if("~"===p)return c={path:h(r,p),value:i,parent:n,parentProperty:null},this._handleCallback(c,s,"property"),c;if("$"===p)f(this._trace(u,t,r,null,null,s,o));else if(/^(-?\d*):(-?\d*):?(\d*)$/u.test(p))f(this._slice(p,u,t,r,n,i,s));else if(0===p.indexOf("?(")){if(!1===this.currEval)throw new Error("Eval [?(expr)] prevented in JSONPath expression.");const e=p.replace(/^\?\((.*?)\)$/u,"$1"),o=/@.?([^?]*)[['](\??\(.*?\))(?!.\)\])[\]']/gu.exec(e);o?this._walk(t,(e=>{const a=[o[2]],l=o[1]?t[e][o[1]]:t[e];this._trace(a,l,r,n,i,s,!0).length>0&&f(this._trace(u,t[e],h(r,e),t,e,s,!0))})):this._walk(t,(o=>{this._eval(e,t[o],o,r,n,i)&&f(this._trace(u,t[o],h(r,o),t,o,s,!0))}))}else if("("===p[0]){if(!1===this.currEval)throw new Error("Eval [(expr)] prevented in JSONPath expression.");f(this._trace(l(this._eval(p,t,r.at(-1),r.slice(0,-1),n,i),u),t,r,n,i,s,o))}else if("@"===p[0]){let e=!1;const o=p.slice(1,-2);switch(o){case"scalar":t&&["object","function"].includes(typeof t)||(e=!0);break;case"boolean":case"string":case"undefined":case"function":typeof t===o&&(e=!0);break;case"integer":!Number.isFinite(t)||t%1||(e=!0);break;case"number":Number.isFinite(t)&&(e=!0);break;case"nonFinite":"number"!=typeof t||Number.isFinite(t)||(e=!0);break;case"object":t&&typeof t===o&&(e=!0);break;case"array":Array.isArray(t)&&(e=!0);break;case"other":e=this.currOtherTypeCallback(t,r,n,i);break;case"null":null===t&&(e=!0);break;default:throw new TypeError("Unknown value type "+o)}if(e)return c={path:r,value:t,parent:n,parentProperty:i},this._handleCallback(c,s,"value"),c}else if("`"===p[0]&&t&&Object.hasOwn(t,p.slice(1))){const e=p.slice(1);f(this._trace(u,t[e],h(r,e),t,e,s,o,!0))}else if(p.includes(",")){const e=p.split(",");for(const o of e)f(this._trace(l(o,u),t,r,n,i,s,!0))}else!a&&t&&Object.hasOwn(t,p)&&f(this._trace(u,t[p],h(r,p),t,p,s,o,!0))}if(this._hasParentSelector)for(let e=0;e<d.length;e++){const r=d[e];if(r&&r.isParentSelector){const a=this._trace(r.expr,t,r.path,n,i,s,o);if(Array.isArray(a)){d[e]=a[0];const t=a.length;for(let r=1;r<t;r++)e++,d.splice(e,0,a[r])}else d[e]=a}}return d},p.prototype._walk=function(e,t){if(Array.isArray(e)){const r=e.length;for(let e=0;e<r;e++)t(e)}else e&&"object"==typeof e&&Object.keys(e).forEach((e=>{t(e)}))},p.prototype._slice=function(e,t,r,n,i,s,o){if(!Array.isArray(r))return;const a=r.length,h=e.split(":"),c=h[2]&&Number.parseInt(h[2])||1;let p=h[0]&&Number.parseInt(h[0])||0,u=h[1]&&Number.parseInt(h[1])||a;p=p<0?Math.max(0,p+a):Math.min(a,p),u=u<0?Math.max(0,u+a):Math.min(a,u);const d=[];for(let e=p;e<u;e+=c){this._trace(l(e,t),r,n,i,s,o,!0).forEach((e=>{d.push(e)}))}return d},p.prototype._eval=function(e,t,r,n,i,s){this.currSandbox._$_parentProperty=s,this.currSandbox._$_parent=i,this.currSandbox._$_property=r,this.currSandbox._$_root=this.json,this.currSandbox._$_v=t;const o=e.includes("@path");o&&(this.currSandbox._$_path=p.toPathString(n.concat([r])));const a=this.currEval+"Script:"+e;if(!p.cache[a]){let t=e.replaceAll("@parentProperty","_$_parentProperty").replaceAll("@parent","_$_parent").replaceAll("@property","_$_property").replaceAll("@root","_$_root").replaceAll(/@([.\s)[])/gu,"_$_v$1");if(o&&(t=t.replaceAll("@path","_$_path")),"safe"===this.currEval||!0===this.currEval||void 0===this.currEval)p.cache[a]=new this.safeVm.Script(t);else if("native"===this.currEval)p.cache[a]=new this.vm.Script(t);else if("function"==typeof this.currEval&&this.currEval.prototype&&Object.hasOwn(this.currEval.prototype,"runInNewContext")){const e=this.currEval;p.cache[a]=new e(t)}else{if("function"!=typeof this.currEval)throw new TypeError(`Unknown "eval" property "${this.currEval}"`);p.cache[a]={runInNewContext:e=>this.currEval(t,e)}}}try{return p.cache[a].runInNewContext(this.currSandbox)}catch(t){if(this.ignoreEvalErrors)return!1;throw new Error("jsonPath: "+t.message+": "+e)}},p.cache={},p.toPathString=function(e){const t=e,r=t.length;let n="$";for(let e=1;e<r;e++)/^(~|\^|@.*?\(\))$/u.test(t[e])||(n+=/^[0-9*]+$/u.test(t[e])?"["+t[e]+"]":"['"+t[e]+"']");return n},p.toPointer=function(e){const t=e,r=t.length;let n="";for(let e=1;e<r;e++)/^(~|\^|@.*?\(\))$/u.test(t[e])||(n+="/"+t[e].toString().replaceAll("~","~0").replaceAll("/","~1"));return n},p.toPathArray=function(e){const{cache:t}=p;if(t[e])return t[e].concat();const r=[],n=e.replaceAll(/@(?:null|boolean|number|string|integer|undefined|nonFinite|scalar|array|object|function|other)\(\)/gu,";$&;").replaceAll(/[['](\??\(.*?\))[\]'](?!.\])/gu,(function(e,t){return"[#"+(r.push(t)-1)+"]"})).replaceAll(/\[['"]([^'\]]*)['"]\]/gu,(function(e,t){return"['"+t.replaceAll(".","%@%").replaceAll("~","%%@@%%")+"']"})).replaceAll("~",";~;").replaceAll(/['"]?\.['"]?(?![^[]*\])|\[['"]?/gu,";").replaceAll("%@%",".").replaceAll("%%@@%%","~").replaceAll(/(?:;)?(\^+)(?:;)?/gu,(function(e,t){return";"+t.split("").join(";")+";"})).replaceAll(/;;;|;;/gu,";..;").replaceAll(/;$|'?\]|'$/gu,"").split(";").map((function(e){const t=e.match(/#(\d+)/u);return t&&t[1]?r[t[1]]:e}));return t[e]=n,t[e].concat()},p.prototype.safeVm={Script:class{constructor(e){this.code=e,this.ast=r(this.code)}runInNewContext(e){const t={...e};return a.evalAst(this.ast,t)}}};p.prototype.vm={Script:class{constructor(e){this.code=e}runInNewContext(e){let t=this.code;const r=Object.keys(e),n=[];!function(e,t,r){const n=e.length;for(let i=0;i<n;i++)r(e[i])&&t.push(e.splice(i--,1)[0])}(r,n,(t=>"function"==typeof e[t]));const i=r.map((t=>e[t]));t=n.reduce(((t,r)=>{let n=e[r].toString();return/function/u.test(n)||(n="function "+n),"var "+r+"="+n+";"+t}),"")+t,/(['"])use strict\1/u.test(t)||r.includes("arguments")||(t="var arguments = undefined;"+t),t=t.replace(/;\s*$/u,"");const s=t.lastIndexOf(";"),o=s>-1?t.slice(0,s+1)+" return "+t.slice(s+1):" return "+t;return new Function(...r,o)(...i)}}};export{p as JSONPath}; +class e{static get version(){return"1.3.9"}static toString(){return"JavaScript Expression Parser (JSEP) v"+e.version}static addUnaryOp(t){return e.max_unop_len=Math.max(t.length,e.max_unop_len),e.unary_ops[t]=1,e}static addBinaryOp(t,r,s){return e.max_binop_len=Math.max(t.length,e.max_binop_len),e.binary_ops[t]=r,s?e.right_associative.add(t):e.right_associative.delete(t),e}static addIdentifierChar(t){return e.additional_identifier_chars.add(t),e}static addLiteral(t,r){return e.literals[t]=r,e}static removeUnaryOp(t){return delete e.unary_ops[t],t.length===e.max_unop_len&&(e.max_unop_len=e.getMaxKeyLen(e.unary_ops)),e}static removeAllUnaryOps(){return e.unary_ops={},e.max_unop_len=0,e}static removeIdentifierChar(t){return e.additional_identifier_chars.delete(t),e}static removeBinaryOp(t){return delete e.binary_ops[t],t.length===e.max_binop_len&&(e.max_binop_len=e.getMaxKeyLen(e.binary_ops)),e.right_associative.delete(t),e}static removeAllBinaryOps(){return e.binary_ops={},e.max_binop_len=0,e}static removeLiteral(t){return delete e.literals[t],e}static removeAllLiterals(){return e.literals={},e}get char(){return this.expr.charAt(this.index)}get code(){return this.expr.charCodeAt(this.index)}constructor(e){this.expr=e,this.index=0}static parse(t){return new e(t).parse()}static getMaxKeyLen(e){return Math.max(0,...Object.keys(e).map((e=>e.length)))}static isDecimalDigit(e){return e>=48&&e<=57}static binaryPrecedence(t){return e.binary_ops[t]||0}static isIdentifierStart(t){return t>=65&&t<=90||t>=97&&t<=122||t>=128&&!e.binary_ops[String.fromCharCode(t)]||e.additional_identifier_chars.has(String.fromCharCode(t))}static isIdentifierPart(t){return e.isIdentifierStart(t)||e.isDecimalDigit(t)}throwError(e){const t=new Error(e+" at character "+this.index);throw t.index=this.index,t.description=e,t}runHook(t,r){if(e.hooks[t]){const s={context:this,node:r};return e.hooks.run(t,s),s.node}return r}searchHook(t){if(e.hooks[t]){const r={context:this};return e.hooks[t].find((function(e){return e.call(r.context,r),r.node})),r.node}}gobbleSpaces(){let t=this.code;for(;t===e.SPACE_CODE||t===e.TAB_CODE||t===e.LF_CODE||t===e.CR_CODE;)t=this.expr.charCodeAt(++this.index);this.runHook("gobble-spaces")}parse(){this.runHook("before-all");const t=this.gobbleExpressions(),r=1===t.length?t[0]:{type:e.COMPOUND,body:t};return this.runHook("after-all",r)}gobbleExpressions(t){let r,s,n=[];for(;this.index<this.expr.length;)if(r=this.code,r===e.SEMCOL_CODE||r===e.COMMA_CODE)this.index++;else if(s=this.gobbleExpression())n.push(s);else if(this.index<this.expr.length){if(r===t)break;this.throwError('Unexpected "'+this.char+'"')}return n}gobbleExpression(){const e=this.searchHook("gobble-expression")||this.gobbleBinaryExpression();return this.gobbleSpaces(),this.runHook("after-expression",e)}gobbleBinaryOp(){this.gobbleSpaces();let t=this.expr.substr(this.index,e.max_binop_len),r=t.length;for(;r>0;){if(e.binary_ops.hasOwnProperty(t)&&(!e.isIdentifierStart(this.code)||this.index+t.length<this.expr.length&&!e.isIdentifierPart(this.expr.charCodeAt(this.index+t.length))))return this.index+=r,t;t=t.substr(0,--r)}return!1}gobbleBinaryExpression(){let t,r,s,n,i,a,o,h,l;if(a=this.gobbleToken(),!a)return a;if(r=this.gobbleBinaryOp(),!r)return a;for(i={value:r,prec:e.binaryPrecedence(r),right_a:e.right_associative.has(r)},o=this.gobbleToken(),o||this.throwError("Expected expression after "+r),n=[a,i,o];r=this.gobbleBinaryOp();){if(s=e.binaryPrecedence(r),0===s){this.index-=r.length;break}i={value:r,prec:s,right_a:e.right_associative.has(r)},l=r;const h=e=>i.right_a&&e.right_a?s>e.prec:s<=e.prec;for(;n.length>2&&h(n[n.length-2]);)o=n.pop(),r=n.pop().value,a=n.pop(),t={type:e.BINARY_EXP,operator:r,left:a,right:o},n.push(t);t=this.gobbleToken(),t||this.throwError("Expected expression after "+l),n.push(i,t)}for(h=n.length-1,t=n[h];h>1;)t={type:e.BINARY_EXP,operator:n[h-1].value,left:n[h-2],right:t},h-=2;return t}gobbleToken(){let t,r,s,n;if(this.gobbleSpaces(),n=this.searchHook("gobble-token"),n)return this.runHook("after-token",n);if(t=this.code,e.isDecimalDigit(t)||t===e.PERIOD_CODE)return this.gobbleNumericLiteral();if(t===e.SQUOTE_CODE||t===e.DQUOTE_CODE)n=this.gobbleStringLiteral();else if(t===e.OBRACK_CODE)n=this.gobbleArray();else{for(r=this.expr.substr(this.index,e.max_unop_len),s=r.length;s>0;){if(e.unary_ops.hasOwnProperty(r)&&(!e.isIdentifierStart(this.code)||this.index+r.length<this.expr.length&&!e.isIdentifierPart(this.expr.charCodeAt(this.index+r.length)))){this.index+=s;const t=this.gobbleToken();return t||this.throwError("missing unaryOp argument"),this.runHook("after-token",{type:e.UNARY_EXP,operator:r,argument:t,prefix:!0})}r=r.substr(0,--s)}e.isIdentifierStart(t)?(n=this.gobbleIdentifier(),e.literals.hasOwnProperty(n.name)?n={type:e.LITERAL,value:e.literals[n.name],raw:n.name}:n.name===e.this_str&&(n={type:e.THIS_EXP})):t===e.OPAREN_CODE&&(n=this.gobbleGroup())}return n?(n=this.gobbleTokenProperty(n),this.runHook("after-token",n)):this.runHook("after-token",!1)}gobbleTokenProperty(t){this.gobbleSpaces();let r=this.code;for(;r===e.PERIOD_CODE||r===e.OBRACK_CODE||r===e.OPAREN_CODE||r===e.QUMARK_CODE;){let s;if(r===e.QUMARK_CODE){if(this.expr.charCodeAt(this.index+1)!==e.PERIOD_CODE)break;s=!0,this.index+=2,this.gobbleSpaces(),r=this.code}this.index++,r===e.OBRACK_CODE?((t={type:e.MEMBER_EXP,computed:!0,object:t,property:this.gobbleExpression()}).property||this.throwError('Unexpected "'+this.char+'"'),this.gobbleSpaces(),r=this.code,r!==e.CBRACK_CODE&&this.throwError("Unclosed ["),this.index++):r===e.OPAREN_CODE?t={type:e.CALL_EXP,arguments:this.gobbleArguments(e.CPAREN_CODE),callee:t}:(r===e.PERIOD_CODE||s)&&(s&&this.index--,this.gobbleSpaces(),t={type:e.MEMBER_EXP,computed:!1,object:t,property:this.gobbleIdentifier()}),s&&(t.optional=!0),this.gobbleSpaces(),r=this.code}return t}gobbleNumericLiteral(){let t,r,s="";for(;e.isDecimalDigit(this.code);)s+=this.expr.charAt(this.index++);if(this.code===e.PERIOD_CODE)for(s+=this.expr.charAt(this.index++);e.isDecimalDigit(this.code);)s+=this.expr.charAt(this.index++);if(t=this.char,"e"===t||"E"===t){for(s+=this.expr.charAt(this.index++),t=this.char,"+"!==t&&"-"!==t||(s+=this.expr.charAt(this.index++));e.isDecimalDigit(this.code);)s+=this.expr.charAt(this.index++);e.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+s+this.char+")")}return r=this.code,e.isIdentifierStart(r)?this.throwError("Variable names cannot start with a number ("+s+this.char+")"):(r===e.PERIOD_CODE||1===s.length&&s.charCodeAt(0)===e.PERIOD_CODE)&&this.throwError("Unexpected period"),{type:e.LITERAL,value:parseFloat(s),raw:s}}gobbleStringLiteral(){let t="";const r=this.index,s=this.expr.charAt(this.index++);let n=!1;for(;this.index<this.expr.length;){let e=this.expr.charAt(this.index++);if(e===s){n=!0;break}if("\\"===e)switch(e=this.expr.charAt(this.index++),e){case"n":t+="\n";break;case"r":t+="\r";break;case"t":t+="\t";break;case"b":t+="\b";break;case"f":t+="\f";break;case"v":t+="\v";break;default:t+=e}else t+=e}return n||this.throwError('Unclosed quote after "'+t+'"'),{type:e.LITERAL,value:t,raw:this.expr.substring(r,this.index)}}gobbleIdentifier(){let t=this.code,r=this.index;for(e.isIdentifierStart(t)?this.index++:this.throwError("Unexpected "+this.char);this.index<this.expr.length&&(t=this.code,e.isIdentifierPart(t));)this.index++;return{type:e.IDENTIFIER,name:this.expr.slice(r,this.index)}}gobbleArguments(t){const r=[];let s=!1,n=0;for(;this.index<this.expr.length;){this.gobbleSpaces();let i=this.code;if(i===t){s=!0,this.index++,t===e.CPAREN_CODE&&n&&n>=r.length&&this.throwError("Unexpected token "+String.fromCharCode(t));break}if(i===e.COMMA_CODE){if(this.index++,n++,n!==r.length)if(t===e.CPAREN_CODE)this.throwError("Unexpected token ,");else if(t===e.CBRACK_CODE)for(let e=r.length;e<n;e++)r.push(null)}else if(r.length!==n&&0!==n)this.throwError("Expected comma");else{const t=this.gobbleExpression();t&&t.type!==e.COMPOUND||this.throwError("Expected comma"),r.push(t)}}return s||this.throwError("Expected "+String.fromCharCode(t)),r}gobbleGroup(){this.index++;let t=this.gobbleExpressions(e.CPAREN_CODE);if(this.code===e.CPAREN_CODE)return this.index++,1===t.length?t[0]:!!t.length&&{type:e.SEQUENCE_EXP,expressions:t};this.throwError("Unclosed (")}gobbleArray(){return this.index++,{type:e.ARRAY_EXP,elements:this.gobbleArguments(e.CBRACK_CODE)}}}const t=new class{add(e,t,r){if("string"!=typeof arguments[0])for(let e in arguments[0])this.add(e,arguments[0][e],arguments[1]);else(Array.isArray(e)?e:[e]).forEach((function(e){this[e]=this[e]||[],t&&this[e][r?"unshift":"push"](t)}),this)}run(e,t){this[e]=this[e]||[],this[e].forEach((function(e){e.call(t&&t.context?t.context:t,t)}))}};Object.assign(e,{hooks:t,plugins:new class{constructor(e){this.jsep=e,this.registered={}}register(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];t.forEach((e=>{if("object"!=typeof e||!e.name||!e.init)throw new Error("Invalid JSEP plugin format");this.registered[e.name]||(e.init(this.jsep),this.registered[e.name]=e)}))}}(e),COMPOUND:"Compound",SEQUENCE_EXP:"SequenceExpression",IDENTIFIER:"Identifier",MEMBER_EXP:"MemberExpression",LITERAL:"Literal",THIS_EXP:"ThisExpression",CALL_EXP:"CallExpression",UNARY_EXP:"UnaryExpression",BINARY_EXP:"BinaryExpression",ARRAY_EXP:"ArrayExpression",TAB_CODE:9,LF_CODE:10,CR_CODE:13,SPACE_CODE:32,PERIOD_CODE:46,COMMA_CODE:44,SQUOTE_CODE:39,DQUOTE_CODE:34,OPAREN_CODE:40,CPAREN_CODE:41,OBRACK_CODE:91,CBRACK_CODE:93,QUMARK_CODE:63,SEMCOL_CODE:59,COLON_CODE:58,unary_ops:{"-":1,"!":1,"~":1,"+":1},binary_ops:{"||":1,"&&":2,"|":3,"^":4,"&":5,"==":6,"!=":6,"===":6,"!==":6,"<":7,">":7,"<=":7,">=":7,"<<":8,">>":8,">>>":8,"+":9,"-":9,"*":10,"/":10,"%":10},right_associative:new Set,additional_identifier_chars:new Set(["$","_"]),literals:{true:!0,false:!1,null:null},this_str:"this"}),e.max_unop_len=e.getMaxKeyLen(e.unary_ops),e.max_binop_len=e.getMaxKeyLen(e.binary_ops);const r=t=>new e(t).parse(),s=Object.getOwnPropertyNames(class{});Object.getOwnPropertyNames(e).filter((e=>!s.includes(e)&&void 0===r[e])).forEach((t=>{r[t]=e[t]})),r.Jsep=e;var n={name:"ternary",init(e){e.hooks.add("after-expression",(function(t){if(t.node&&this.code===e.QUMARK_CODE){this.index++;const r=t.node,s=this.gobbleExpression();if(s||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===e.COLON_CODE){this.index++;const n=this.gobbleExpression();if(n||this.throwError("Expected expression"),t.node={type:"ConditionalExpression",test:r,consequent:s,alternate:n},r.operator&&e.binary_ops[r.operator]<=.9){let s=r;for(;s.right.operator&&e.binary_ops[s.right.operator]<=.9;)s=s.right;t.node.test=s.right,s.right=t.node,t.node=r}}else this.throwError("Expected :")}}))}};r.plugins.register(n);var i={name:"regex",init(e){e.hooks.add("gobble-token",(function(t){if(47===this.code){const r=++this.index;let s=!1;for(;this.index<this.expr.length;){if(47===this.code&&!s){const s=this.expr.slice(r,this.index);let n,i="";for(;++this.index<this.expr.length;){const e=this.code;if(!(e>=97&&e<=122||e>=65&&e<=90||e>=48&&e<=57))break;i+=this.char}try{n=new RegExp(s,i)}catch(e){this.throwError(e.message)}return t.node={type:e.LITERAL,value:n,raw:this.expr.slice(r-1,this.index)},t.node=this.gobbleTokenProperty(t.node),t.node}this.code===e.OBRACK_CODE?s=!0:s&&this.code===e.CBRACK_CODE&&(s=!1),this.index+=92===this.code?2:1}this.throwError("Unclosed Regex")}}))}};const a={name:"assignment",assignmentOperators:new Set(["=","*=","**=","/=","%=","+=","-=","<<=",">>=",">>>=","&=","^=","|="]),updateOperators:[43,45],assignmentPrecedence:.9,init(e){const t=[e.IDENTIFIER,e.MEMBER_EXP];function r(e){a.assignmentOperators.has(e.operator)?(e.type="AssignmentExpression",r(e.left),r(e.right)):e.operator||Object.values(e).forEach((e=>{e&&"object"==typeof e&&r(e)}))}a.assignmentOperators.forEach((t=>e.addBinaryOp(t,a.assignmentPrecedence,!0))),e.hooks.add("gobble-token",(function(e){const r=this.code;a.updateOperators.some((e=>e===r&&e===this.expr.charCodeAt(this.index+1)))&&(this.index+=2,e.node={type:"UpdateExpression",operator:43===r?"++":"--",argument:this.gobbleTokenProperty(this.gobbleIdentifier()),prefix:!0},e.node.argument&&t.includes(e.node.argument.type)||this.throwError(`Unexpected ${e.node.operator}`))})),e.hooks.add("after-token",(function(e){if(e.node){const r=this.code;a.updateOperators.some((e=>e===r&&e===this.expr.charCodeAt(this.index+1)))&&(t.includes(e.node.type)||this.throwError(`Unexpected ${e.node.operator}`),this.index+=2,e.node={type:"UpdateExpression",operator:43===r?"++":"--",argument:e.node,prefix:!1})}})),e.hooks.add("after-expression",(function(e){e.node&&r(e.node)}))}};r.plugins.register(i,a),r.addUnaryOp("typeof"),r.addLiteral("null",null),r.addLiteral("undefined",void 0);const o=new Set(["constructor","__proto__","__defineGetter__","__defineSetter__"]),h={evalAst(e,t){switch(e.type){case"BinaryExpression":case"LogicalExpression":return h.evalBinaryExpression(e,t);case"Compound":return h.evalCompound(e,t);case"ConditionalExpression":return h.evalConditionalExpression(e,t);case"Identifier":return h.evalIdentifier(e,t);case"Literal":return h.evalLiteral(e,t);case"MemberExpression":return h.evalMemberExpression(e,t);case"UnaryExpression":return h.evalUnaryExpression(e,t);case"ArrayExpression":return h.evalArrayExpression(e,t);case"CallExpression":return h.evalCallExpression(e,t);case"AssignmentExpression":return h.evalAssignmentExpression(e,t);default:throw SyntaxError("Unexpected expression",e)}},evalBinaryExpression:(e,t)=>({"||":(e,t)=>e||t(),"&&":(e,t)=>e&&t(),"|":(e,t)=>e|t(),"^":(e,t)=>e^t(),"&":(e,t)=>e&t(),"==":(e,t)=>e==t(),"!=":(e,t)=>e!=t(),"===":(e,t)=>e===t(),"!==":(e,t)=>e!==t(),"<":(e,t)=>e<t(),">":(e,t)=>e>t(),"<=":(e,t)=>e<=t(),">=":(e,t)=>e>=t(),"<<":(e,t)=>e<<t(),">>":(e,t)=>e>>t(),">>>":(e,t)=>e>>>t(),"+":(e,t)=>e+t(),"-":(e,t)=>e-t(),"*":(e,t)=>e*t(),"/":(e,t)=>e/t(),"%":(e,t)=>e%t()}[e.operator](h.evalAst(e.left,t),(()=>h.evalAst(e.right,t)))),evalCompound(e,t){let r;for(let s=0;s<e.body.length;s++){"Identifier"===e.body[s].type&&["var","let","const"].includes(e.body[s].name)&&e.body[s+1]&&"AssignmentExpression"===e.body[s+1].type&&(s+=1);const n=e.body[s];r=h.evalAst(n,t)}return r},evalConditionalExpression:(e,t)=>h.evalAst(e.test,t)?h.evalAst(e.consequent,t):h.evalAst(e.alternate,t),evalIdentifier(e,t){if(Object.hasOwn(t,e.name))return t[e.name];throw ReferenceError(`${e.name} is not defined`)},evalLiteral:e=>e.value,evalMemberExpression(e,t){const r=e.computed?h.evalAst(e.property):e.property.name,s=h.evalAst(e.object,t);if(null==s)throw TypeError(`Cannot read properties of ${s} (reading '${r}')`);if(!Object.hasOwn(s,r)&&o.has(r))throw TypeError(`Cannot read properties of ${s} (reading '${r}')`);const n=s[r];return"function"==typeof n?n.bind(s):n},evalUnaryExpression:(e,t)=>({"-":e=>-h.evalAst(e,t),"!":e=>!h.evalAst(e,t),"~":e=>~h.evalAst(e,t),"+":e=>+h.evalAst(e,t),typeof:e=>typeof h.evalAst(e,t)}[e.operator](e.argument)),evalArrayExpression:(e,t)=>e.elements.map((e=>h.evalAst(e,t))),evalCallExpression(e,t){const r=e.arguments.map((e=>h.evalAst(e,t)));return h.evalAst(e.callee,t)(...r)},evalAssignmentExpression(e,t){if("Identifier"!==e.left.type)throw SyntaxError("Invalid left-hand side in assignment");const r=e.left.name,s=h.evalAst(e.right,t);return t[r]=s,t[r]}};function l(e,t){return(e=e.slice()).push(t),e}function c(e,t){return(t=t.slice()).unshift(e),t}class p extends Error{constructor(e){super('JSONPath should not be called with "new" (it prevents return of (unwrapped) scalar values)'),this.avoidNew=!0,this.value=e,this.name="NewError"}}function u(e,t,r,s,n){if(!(this instanceof u))try{return new u(e,t,r,s,n)}catch(e){if(!e.avoidNew)throw e;return e.value}"string"==typeof e&&(n=s,s=r,r=t,t=e,e=null);const i=e&&"object"==typeof e;if(e=e||{},this.json=e.json||r,this.path=e.path||t,this.resultType=e.resultType||"value",this.flatten=e.flatten||!1,this.wrap=!Object.hasOwn(e,"wrap")||e.wrap,this.sandbox=e.sandbox||{},this.eval=void 0===e.eval?"safe":e.eval,this.ignoreEvalErrors=void 0!==e.ignoreEvalErrors&&e.ignoreEvalErrors,this.parent=e.parent||null,this.parentProperty=e.parentProperty||null,this.callback=e.callback||s||null,this.otherTypeCallback=e.otherTypeCallback||n||function(){throw new TypeError("You must supply an otherTypeCallback callback option with the @other() operator.")},!1!==e.autostart){const s={path:i?e.path:t};i?"json"in e&&(s.json=e.json):s.json=r;const n=this.evaluate(s);if(!n||"object"!=typeof n)throw new p(n);return n}}u.prototype.evaluate=function(e,t,r,s){let n=this.parent,i=this.parentProperty,{flatten:a,wrap:o}=this;if(this.currResultType=this.resultType,this.currEval=this.eval,this.currSandbox=this.sandbox,r=r||this.callback,this.currOtherTypeCallback=s||this.otherTypeCallback,t=t||this.json,(e=e||this.path)&&"object"==typeof e&&!Array.isArray(e)){if(!e.path&&""!==e.path)throw new TypeError('You must supply a "path" property when providing an object argument to JSONPath.evaluate().');if(!Object.hasOwn(e,"json"))throw new TypeError('You must supply a "json" property when providing an object argument to JSONPath.evaluate().');({json:t}=e),a=Object.hasOwn(e,"flatten")?e.flatten:a,this.currResultType=Object.hasOwn(e,"resultType")?e.resultType:this.currResultType,this.currSandbox=Object.hasOwn(e,"sandbox")?e.sandbox:this.currSandbox,o=Object.hasOwn(e,"wrap")?e.wrap:o,this.currEval=Object.hasOwn(e,"eval")?e.eval:this.currEval,r=Object.hasOwn(e,"callback")?e.callback:r,this.currOtherTypeCallback=Object.hasOwn(e,"otherTypeCallback")?e.otherTypeCallback:this.currOtherTypeCallback,n=Object.hasOwn(e,"parent")?e.parent:n,i=Object.hasOwn(e,"parentProperty")?e.parentProperty:i,e=e.path}if(n=n||null,i=i||null,Array.isArray(e)&&(e=u.toPathString(e)),!e&&""!==e||!t)return;const h=u.toPathArray(e);"$"===h[0]&&h.length>1&&h.shift(),this._hasParentSelector=null;const l=this._trace(h,t,["$"],n,i,r).filter((function(e){return e&&!e.isParentSelector}));return l.length?o||1!==l.length||l[0].hasArrExpr?l.reduce(((e,t)=>{const r=this._getPreferredOutput(t);return a&&Array.isArray(r)?e=e.concat(r):e.push(r),e}),[]):this._getPreferredOutput(l[0]):o?[]:void 0},u.prototype._getPreferredOutput=function(e){const t=this.currResultType;switch(t){case"all":{const t=Array.isArray(e.path)?e.path:u.toPathArray(e.path);return e.pointer=u.toPointer(t),e.path="string"==typeof e.path?e.path:u.toPathString(e.path),e}case"value":case"parent":case"parentProperty":return e[t];case"path":return u.toPathString(e[t]);case"pointer":return u.toPointer(e.path);default:throw new TypeError("Unknown result type")}},u.prototype._handleCallback=function(e,t,r){if(t){const s=this._getPreferredOutput(e);e.path="string"==typeof e.path?e.path:u.toPathString(e.path),t(s,r,e)}},u.prototype._trace=function(e,t,r,s,n,i,a,o){let h;if(!e.length)return h={path:r,value:t,parent:s,parentProperty:n,hasArrExpr:a},this._handleCallback(h,i,"value"),h;const p=e[0],u=e.slice(1),d=[];function f(e){Array.isArray(e)?e.forEach((e=>{d.push(e)})):d.push(e)}if(("string"!=typeof p||o)&&t&&Object.hasOwn(t,p))f(this._trace(u,t[p],l(r,p),t,p,i,a));else if("*"===p)this._walk(t,(e=>{f(this._trace(u,t[e],l(r,e),t,e,i,!0,!0))}));else if(".."===p)f(this._trace(u,t,r,s,n,i,a)),this._walk(t,(s=>{"object"==typeof t[s]&&f(this._trace(e.slice(),t[s],l(r,s),t,s,i,!0))}));else{if("^"===p)return this._hasParentSelector=!0,{path:r.slice(0,-1),expr:u,isParentSelector:!0};if("~"===p)return h={path:l(r,p),value:n,parent:s,parentProperty:null},this._handleCallback(h,i,"property"),h;if("$"===p)f(this._trace(u,t,r,null,null,i,a));else if(/^(-?\d*):(-?\d*):?(\d*)$/u.test(p))f(this._slice(p,u,t,r,s,n,i));else if(0===p.indexOf("?(")){if(!1===this.currEval)throw new Error("Eval [?(expr)] prevented in JSONPath expression.");const e=p.replace(/^\?\((.*?)\)$/u,"$1"),a=/@.?([^?]*)[['](\??\(.*?\))(?!.\)\])[\]']/gu.exec(e);a?this._walk(t,(e=>{const o=[a[2]],h=a[1]?t[e][a[1]]:t[e];this._trace(o,h,r,s,n,i,!0).length>0&&f(this._trace(u,t[e],l(r,e),t,e,i,!0))})):this._walk(t,(a=>{this._eval(e,t[a],a,r,s,n)&&f(this._trace(u,t[a],l(r,a),t,a,i,!0))}))}else if("("===p[0]){if(!1===this.currEval)throw new Error("Eval [(expr)] prevented in JSONPath expression.");f(this._trace(c(this._eval(p,t,r.at(-1),r.slice(0,-1),s,n),u),t,r,s,n,i,a))}else if("@"===p[0]){let e=!1;const a=p.slice(1,-2);switch(a){case"scalar":t&&["object","function"].includes(typeof t)||(e=!0);break;case"boolean":case"string":case"undefined":case"function":typeof t===a&&(e=!0);break;case"integer":!Number.isFinite(t)||t%1||(e=!0);break;case"number":Number.isFinite(t)&&(e=!0);break;case"nonFinite":"number"!=typeof t||Number.isFinite(t)||(e=!0);break;case"object":t&&typeof t===a&&(e=!0);break;case"array":Array.isArray(t)&&(e=!0);break;case"other":e=this.currOtherTypeCallback(t,r,s,n);break;case"null":null===t&&(e=!0);break;default:throw new TypeError("Unknown value type "+a)}if(e)return h={path:r,value:t,parent:s,parentProperty:n},this._handleCallback(h,i,"value"),h}else if("`"===p[0]&&t&&Object.hasOwn(t,p.slice(1))){const e=p.slice(1);f(this._trace(u,t[e],l(r,e),t,e,i,a,!0))}else if(p.includes(",")){const e=p.split(",");for(const a of e)f(this._trace(c(a,u),t,r,s,n,i,!0))}else!o&&t&&Object.hasOwn(t,p)&&f(this._trace(u,t[p],l(r,p),t,p,i,a,!0))}if(this._hasParentSelector)for(let e=0;e<d.length;e++){const r=d[e];if(r&&r.isParentSelector){const o=this._trace(r.expr,t,r.path,s,n,i,a);if(Array.isArray(o)){d[e]=o[0];const t=o.length;for(let r=1;r<t;r++)e++,d.splice(e,0,o[r])}else d[e]=o}}return d},u.prototype._walk=function(e,t){if(Array.isArray(e)){const r=e.length;for(let e=0;e<r;e++)t(e)}else e&&"object"==typeof e&&Object.keys(e).forEach((e=>{t(e)}))},u.prototype._slice=function(e,t,r,s,n,i,a){if(!Array.isArray(r))return;const o=r.length,h=e.split(":"),l=h[2]&&Number.parseInt(h[2])||1;let p=h[0]&&Number.parseInt(h[0])||0,u=h[1]&&Number.parseInt(h[1])||o;p=p<0?Math.max(0,p+o):Math.min(o,p),u=u<0?Math.max(0,u+o):Math.min(o,u);const d=[];for(let e=p;e<u;e+=l){this._trace(c(e,t),r,s,n,i,a,!0).forEach((e=>{d.push(e)}))}return d},u.prototype._eval=function(e,t,r,s,n,i){this.currSandbox._$_parentProperty=i,this.currSandbox._$_parent=n,this.currSandbox._$_property=r,this.currSandbox._$_root=this.json,this.currSandbox._$_v=t;const a=e.includes("@path");a&&(this.currSandbox._$_path=u.toPathString(s.concat([r])));const o=this.currEval+"Script:"+e;if(!u.cache[o]){let t=e.replaceAll("@parentProperty","_$_parentProperty").replaceAll("@parent","_$_parent").replaceAll("@property","_$_property").replaceAll("@root","_$_root").replaceAll(/@([.\s)[])/gu,"_$_v$1");if(a&&(t=t.replaceAll("@path","_$_path")),"safe"===this.currEval||!0===this.currEval||void 0===this.currEval)u.cache[o]=new this.safeVm.Script(t);else if("native"===this.currEval)u.cache[o]=new this.vm.Script(t);else if("function"==typeof this.currEval&&this.currEval.prototype&&Object.hasOwn(this.currEval.prototype,"runInNewContext")){const e=this.currEval;u.cache[o]=new e(t)}else{if("function"!=typeof this.currEval)throw new TypeError(`Unknown "eval" property "${this.currEval}"`);u.cache[o]={runInNewContext:e=>this.currEval(t,e)}}}try{return u.cache[o].runInNewContext(this.currSandbox)}catch(t){if(this.ignoreEvalErrors)return!1;throw new Error("jsonPath: "+t.message+": "+e)}},u.cache={},u.toPathString=function(e){const t=e,r=t.length;let s="$";for(let e=1;e<r;e++)/^(~|\^|@.*?\(\))$/u.test(t[e])||(s+=/^[0-9*]+$/u.test(t[e])?"["+t[e]+"]":"['"+t[e]+"']");return s},u.toPointer=function(e){const t=e,r=t.length;let s="";for(let e=1;e<r;e++)/^(~|\^|@.*?\(\))$/u.test(t[e])||(s+="/"+t[e].toString().replaceAll("~","~0").replaceAll("/","~1"));return s},u.toPathArray=function(e){const{cache:t}=u;if(t[e])return t[e].concat();const r=[],s=e.replaceAll(/@(?:null|boolean|number|string|integer|undefined|nonFinite|scalar|array|object|function|other)\(\)/gu,";$&;").replaceAll(/[['](\??\(.*?\))[\]'](?!.\])/gu,(function(e,t){return"[#"+(r.push(t)-1)+"]"})).replaceAll(/\[['"]([^'\]]*)['"]\]/gu,(function(e,t){return"['"+t.replaceAll(".","%@%").replaceAll("~","%%@@%%")+"']"})).replaceAll("~",";~;").replaceAll(/['"]?\.['"]?(?![^[]*\])|\[['"]?/gu,";").replaceAll("%@%",".").replaceAll("%%@@%%","~").replaceAll(/(?:;)?(\^+)(?:;)?/gu,(function(e,t){return";"+t.split("").join(";")+";"})).replaceAll(/;;;|;;/gu,";..;").replaceAll(/;$|'?\]|'$/gu,"").split(";").map((function(e){const t=e.match(/#(\d+)/u);return t&&t[1]?r[t[1]]:e}));return t[e]=s,t[e].concat()},u.prototype.safeVm={Script:class{constructor(e){this.code=e,this.ast=r(this.code)}runInNewContext(e){const t=Object.assign(Object.create(null),e);return h.evalAst(this.ast,t)}}};u.prototype.vm={Script:class{constructor(e){this.code=e}runInNewContext(e){let t=this.code;const r=Object.keys(e),s=[];!function(e,t,r){const s=e.length;for(let n=0;n<s;n++)r(e[n])&&t.push(e.splice(n--,1)[0])}(r,s,(t=>"function"==typeof e[t]));const n=r.map((t=>e[t]));t=s.reduce(((t,r)=>{let s=e[r].toString();return/function/u.test(s)||(s="function "+s),"var "+r+"="+s+";"+t}),"")+t,/(['"])use strict\1/u.test(t)||r.includes("arguments")||(t="var arguments = undefined;"+t),t=t.replace(/;\s*$/u,"");const i=t.lastIndexOf(";"),a=i>-1?t.slice(0,i+1)+" return "+t.slice(i+1):" return "+t;return new Function(...r,a)(...n)}}};export{u as JSONPath}; //# sourceMappingURL=index-browser-esm.min.js.map
dist/index-browser-esm.min.js.map+1 −1 modifieddist/index-browser-umd.cjs+13 −22 modified@@ -1209,6 +1209,7 @@ jsep.addUnaryOp('typeof'); jsep.addLiteral('null', null); jsep.addLiteral('undefined', undefined); + const BLOCKED_PROTO_PROPERTIES = new Set(['constructor', '__proto__', '__defineGetter__', '__defineSetter__']); const SafeEval = { /** * @param {jsep.Expression} ast @@ -1291,7 +1292,7 @@ return SafeEval.evalAst(ast.alternate, subs); }, evalIdentifier(ast, subs) { - if (ast.name in subs) { + if (Object.hasOwn(subs, ast.name)) { return subs[ast.name]; } throw ReferenceError(`${ast.name} is not defined`); @@ -1300,23 +1301,17 @@ return ast.value; }, evalMemberExpression(ast, subs) { - if (ast.property.type === 'Identifier' && ast.property.name === 'constructor' || ast.object.type === 'Identifier' && ast.object.name === 'constructor') { - throw new Error("'constructor' property is disabled"); - } const prop = ast.computed ? SafeEval.evalAst(ast.property) // `object[property]` : ast.property.name; // `object.property` property is Identifier const obj = SafeEval.evalAst(ast.object, subs); + if (obj === undefined || obj === null) { + throw TypeError(`Cannot read properties of ${obj} (reading '${prop}')`); + } + if (!Object.hasOwn(obj, prop) && BLOCKED_PROTO_PROPERTIES.has(prop)) { + throw TypeError(`Cannot read properties of ${obj} (reading '${prop}')`); + } const result = obj[prop]; if (typeof result === 'function') { - if (obj === Function && prop === 'bind') { - throw new Error('Function.prototype.bind is disabled'); - } - if (obj === Function && (prop === 'call' || prop === 'apply')) { - throw new Error('Function.prototype.call and ' + 'Function.prototype.apply are disabled'); - } - if (result === Function) { - return result; // Don't bind so can identify and throw later - } return result.bind(obj); // arrow functions aren't affected by bind. } return result; @@ -1338,19 +1333,16 @@ evalCallExpression(ast, subs) { const args = ast.arguments.map(arg => SafeEval.evalAst(arg, subs)); const func = SafeEval.evalAst(ast.callee, subs); - if (func === Function) { - throw new Error('Function constructor is disabled'); - } + // if (func === Function) { + // throw new Error('Function constructor is disabled'); + // } return func(...args); }, evalAssignmentExpression(ast, subs) { if (ast.left.type !== 'Identifier') { throw SyntaxError('Invalid left-hand side in assignment'); } const id = ast.left.name; - if (id === '__proto__') { - throw new Error('Assignment to __proto__ is disabled'); - } const value = SafeEval.evalAst(ast.right, subs); subs[id] = value; return subs[id]; @@ -1375,9 +1367,8 @@ * @returns {EvaluatedResult} Result of evaluated code */ runInNewContext(context) { - const keyMap = { - ...context - }; + // `Object.create(null)` creates a prototypeless object + const keyMap = Object.assign(Object.create(null), context); return SafeEval.evalAst(this.ast, keyMap); } }
dist/index-browser-umd.min.cjs+1 −1 modified@@ -1,2 +1,2 @@ -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).JSONPath={})}(this,(function(e){"use strict";class t{static get version(){return"1.3.9"}static toString(){return"JavaScript Expression Parser (JSEP) v"+t.version}static addUnaryOp(e){return t.max_unop_len=Math.max(e.length,t.max_unop_len),t.unary_ops[e]=1,t}static addBinaryOp(e,r,n){return t.max_binop_len=Math.max(e.length,t.max_binop_len),t.binary_ops[e]=r,n?t.right_associative.add(e):t.right_associative.delete(e),t}static addIdentifierChar(e){return t.additional_identifier_chars.add(e),t}static addLiteral(e,r){return t.literals[e]=r,t}static removeUnaryOp(e){return delete t.unary_ops[e],e.length===t.max_unop_len&&(t.max_unop_len=t.getMaxKeyLen(t.unary_ops)),t}static removeAllUnaryOps(){return t.unary_ops={},t.max_unop_len=0,t}static removeIdentifierChar(e){return t.additional_identifier_chars.delete(e),t}static removeBinaryOp(e){return delete t.binary_ops[e],e.length===t.max_binop_len&&(t.max_binop_len=t.getMaxKeyLen(t.binary_ops)),t.right_associative.delete(e),t}static removeAllBinaryOps(){return t.binary_ops={},t.max_binop_len=0,t}static removeLiteral(e){return delete t.literals[e],t}static removeAllLiterals(){return t.literals={},t}get char(){return this.expr.charAt(this.index)}get code(){return this.expr.charCodeAt(this.index)}constructor(e){this.expr=e,this.index=0}static parse(e){return new t(e).parse()}static getMaxKeyLen(e){return Math.max(0,...Object.keys(e).map((e=>e.length)))}static isDecimalDigit(e){return e>=48&&e<=57}static binaryPrecedence(e){return t.binary_ops[e]||0}static isIdentifierStart(e){return e>=65&&e<=90||e>=97&&e<=122||e>=128&&!t.binary_ops[String.fromCharCode(e)]||t.additional_identifier_chars.has(String.fromCharCode(e))}static isIdentifierPart(e){return t.isIdentifierStart(e)||t.isDecimalDigit(e)}throwError(e){const t=new Error(e+" at character "+this.index);throw t.index=this.index,t.description=e,t}runHook(e,r){if(t.hooks[e]){const n={context:this,node:r};return t.hooks.run(e,n),n.node}return r}searchHook(e){if(t.hooks[e]){const r={context:this};return t.hooks[e].find((function(e){return e.call(r.context,r),r.node})),r.node}}gobbleSpaces(){let e=this.code;for(;e===t.SPACE_CODE||e===t.TAB_CODE||e===t.LF_CODE||e===t.CR_CODE;)e=this.expr.charCodeAt(++this.index);this.runHook("gobble-spaces")}parse(){this.runHook("before-all");const e=this.gobbleExpressions(),r=1===e.length?e[0]:{type:t.COMPOUND,body:e};return this.runHook("after-all",r)}gobbleExpressions(e){let r,n,i=[];for(;this.index<this.expr.length;)if(r=this.code,r===t.SEMCOL_CODE||r===t.COMMA_CODE)this.index++;else if(n=this.gobbleExpression())i.push(n);else if(this.index<this.expr.length){if(r===e)break;this.throwError('Unexpected "'+this.char+'"')}return i}gobbleExpression(){const e=this.searchHook("gobble-expression")||this.gobbleBinaryExpression();return this.gobbleSpaces(),this.runHook("after-expression",e)}gobbleBinaryOp(){this.gobbleSpaces();let e=this.expr.substr(this.index,t.max_binop_len),r=e.length;for(;r>0;){if(t.binary_ops.hasOwnProperty(e)&&(!t.isIdentifierStart(this.code)||this.index+e.length<this.expr.length&&!t.isIdentifierPart(this.expr.charCodeAt(this.index+e.length))))return this.index+=r,e;e=e.substr(0,--r)}return!1}gobbleBinaryExpression(){let e,r,n,i,s,o,a,h,l;if(o=this.gobbleToken(),!o)return o;if(r=this.gobbleBinaryOp(),!r)return o;for(s={value:r,prec:t.binaryPrecedence(r),right_a:t.right_associative.has(r)},a=this.gobbleToken(),a||this.throwError("Expected expression after "+r),i=[o,s,a];r=this.gobbleBinaryOp();){if(n=t.binaryPrecedence(r),0===n){this.index-=r.length;break}s={value:r,prec:n,right_a:t.right_associative.has(r)},l=r;const h=e=>s.right_a&&e.right_a?n>e.prec:n<=e.prec;for(;i.length>2&&h(i[i.length-2]);)a=i.pop(),r=i.pop().value,o=i.pop(),e={type:t.BINARY_EXP,operator:r,left:o,right:a},i.push(e);e=this.gobbleToken(),e||this.throwError("Expected expression after "+l),i.push(s,e)}for(h=i.length-1,e=i[h];h>1;)e={type:t.BINARY_EXP,operator:i[h-1].value,left:i[h-2],right:e},h-=2;return e}gobbleToken(){let e,r,n,i;if(this.gobbleSpaces(),i=this.searchHook("gobble-token"),i)return this.runHook("after-token",i);if(e=this.code,t.isDecimalDigit(e)||e===t.PERIOD_CODE)return this.gobbleNumericLiteral();if(e===t.SQUOTE_CODE||e===t.DQUOTE_CODE)i=this.gobbleStringLiteral();else if(e===t.OBRACK_CODE)i=this.gobbleArray();else{for(r=this.expr.substr(this.index,t.max_unop_len),n=r.length;n>0;){if(t.unary_ops.hasOwnProperty(r)&&(!t.isIdentifierStart(this.code)||this.index+r.length<this.expr.length&&!t.isIdentifierPart(this.expr.charCodeAt(this.index+r.length)))){this.index+=n;const e=this.gobbleToken();return e||this.throwError("missing unaryOp argument"),this.runHook("after-token",{type:t.UNARY_EXP,operator:r,argument:e,prefix:!0})}r=r.substr(0,--n)}t.isIdentifierStart(e)?(i=this.gobbleIdentifier(),t.literals.hasOwnProperty(i.name)?i={type:t.LITERAL,value:t.literals[i.name],raw:i.name}:i.name===t.this_str&&(i={type:t.THIS_EXP})):e===t.OPAREN_CODE&&(i=this.gobbleGroup())}return i?(i=this.gobbleTokenProperty(i),this.runHook("after-token",i)):this.runHook("after-token",!1)}gobbleTokenProperty(e){this.gobbleSpaces();let r=this.code;for(;r===t.PERIOD_CODE||r===t.OBRACK_CODE||r===t.OPAREN_CODE||r===t.QUMARK_CODE;){let n;if(r===t.QUMARK_CODE){if(this.expr.charCodeAt(this.index+1)!==t.PERIOD_CODE)break;n=!0,this.index+=2,this.gobbleSpaces(),r=this.code}this.index++,r===t.OBRACK_CODE?((e={type:t.MEMBER_EXP,computed:!0,object:e,property:this.gobbleExpression()}).property||this.throwError('Unexpected "'+this.char+'"'),this.gobbleSpaces(),r=this.code,r!==t.CBRACK_CODE&&this.throwError("Unclosed ["),this.index++):r===t.OPAREN_CODE?e={type:t.CALL_EXP,arguments:this.gobbleArguments(t.CPAREN_CODE),callee:e}:(r===t.PERIOD_CODE||n)&&(n&&this.index--,this.gobbleSpaces(),e={type:t.MEMBER_EXP,computed:!1,object:e,property:this.gobbleIdentifier()}),n&&(e.optional=!0),this.gobbleSpaces(),r=this.code}return e}gobbleNumericLiteral(){let e,r,n="";for(;t.isDecimalDigit(this.code);)n+=this.expr.charAt(this.index++);if(this.code===t.PERIOD_CODE)for(n+=this.expr.charAt(this.index++);t.isDecimalDigit(this.code);)n+=this.expr.charAt(this.index++);if(e=this.char,"e"===e||"E"===e){for(n+=this.expr.charAt(this.index++),e=this.char,"+"!==e&&"-"!==e||(n+=this.expr.charAt(this.index++));t.isDecimalDigit(this.code);)n+=this.expr.charAt(this.index++);t.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+n+this.char+")")}return r=this.code,t.isIdentifierStart(r)?this.throwError("Variable names cannot start with a number ("+n+this.char+")"):(r===t.PERIOD_CODE||1===n.length&&n.charCodeAt(0)===t.PERIOD_CODE)&&this.throwError("Unexpected period"),{type:t.LITERAL,value:parseFloat(n),raw:n}}gobbleStringLiteral(){let e="";const r=this.index,n=this.expr.charAt(this.index++);let i=!1;for(;this.index<this.expr.length;){let t=this.expr.charAt(this.index++);if(t===n){i=!0;break}if("\\"===t)switch(t=this.expr.charAt(this.index++),t){case"n":e+="\n";break;case"r":e+="\r";break;case"t":e+="\t";break;case"b":e+="\b";break;case"f":e+="\f";break;case"v":e+="\v";break;default:e+=t}else e+=t}return i||this.throwError('Unclosed quote after "'+e+'"'),{type:t.LITERAL,value:e,raw:this.expr.substring(r,this.index)}}gobbleIdentifier(){let e=this.code,r=this.index;for(t.isIdentifierStart(e)?this.index++:this.throwError("Unexpected "+this.char);this.index<this.expr.length&&(e=this.code,t.isIdentifierPart(e));)this.index++;return{type:t.IDENTIFIER,name:this.expr.slice(r,this.index)}}gobbleArguments(e){const r=[];let n=!1,i=0;for(;this.index<this.expr.length;){this.gobbleSpaces();let s=this.code;if(s===e){n=!0,this.index++,e===t.CPAREN_CODE&&i&&i>=r.length&&this.throwError("Unexpected token "+String.fromCharCode(e));break}if(s===t.COMMA_CODE){if(this.index++,i++,i!==r.length)if(e===t.CPAREN_CODE)this.throwError("Unexpected token ,");else if(e===t.CBRACK_CODE)for(let e=r.length;e<i;e++)r.push(null)}else if(r.length!==i&&0!==i)this.throwError("Expected comma");else{const e=this.gobbleExpression();e&&e.type!==t.COMPOUND||this.throwError("Expected comma"),r.push(e)}}return n||this.throwError("Expected "+String.fromCharCode(e)),r}gobbleGroup(){this.index++;let e=this.gobbleExpressions(t.CPAREN_CODE);if(this.code===t.CPAREN_CODE)return this.index++,1===e.length?e[0]:!!e.length&&{type:t.SEQUENCE_EXP,expressions:e};this.throwError("Unclosed (")}gobbleArray(){return this.index++,{type:t.ARRAY_EXP,elements:this.gobbleArguments(t.CBRACK_CODE)}}}const r=new class{add(e,t,r){if("string"!=typeof arguments[0])for(let e in arguments[0])this.add(e,arguments[0][e],arguments[1]);else(Array.isArray(e)?e:[e]).forEach((function(e){this[e]=this[e]||[],t&&this[e][r?"unshift":"push"](t)}),this)}run(e,t){this[e]=this[e]||[],this[e].forEach((function(e){e.call(t&&t.context?t.context:t,t)}))}};Object.assign(t,{hooks:r,plugins:new class{constructor(e){this.jsep=e,this.registered={}}register(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];t.forEach((e=>{if("object"!=typeof e||!e.name||!e.init)throw new Error("Invalid JSEP plugin format");this.registered[e.name]||(e.init(this.jsep),this.registered[e.name]=e)}))}}(t),COMPOUND:"Compound",SEQUENCE_EXP:"SequenceExpression",IDENTIFIER:"Identifier",MEMBER_EXP:"MemberExpression",LITERAL:"Literal",THIS_EXP:"ThisExpression",CALL_EXP:"CallExpression",UNARY_EXP:"UnaryExpression",BINARY_EXP:"BinaryExpression",ARRAY_EXP:"ArrayExpression",TAB_CODE:9,LF_CODE:10,CR_CODE:13,SPACE_CODE:32,PERIOD_CODE:46,COMMA_CODE:44,SQUOTE_CODE:39,DQUOTE_CODE:34,OPAREN_CODE:40,CPAREN_CODE:41,OBRACK_CODE:91,CBRACK_CODE:93,QUMARK_CODE:63,SEMCOL_CODE:59,COLON_CODE:58,unary_ops:{"-":1,"!":1,"~":1,"+":1},binary_ops:{"||":1,"&&":2,"|":3,"^":4,"&":5,"==":6,"!=":6,"===":6,"!==":6,"<":7,">":7,"<=":7,">=":7,"<<":8,">>":8,">>>":8,"+":9,"-":9,"*":10,"/":10,"%":10},right_associative:new Set,additional_identifier_chars:new Set(["$","_"]),literals:{true:!0,false:!1,null:null},this_str:"this"}),t.max_unop_len=t.getMaxKeyLen(t.unary_ops),t.max_binop_len=t.getMaxKeyLen(t.binary_ops);const n=e=>new t(e).parse(),i=Object.getOwnPropertyNames(class{});Object.getOwnPropertyNames(t).filter((e=>!i.includes(e)&&void 0===n[e])).forEach((e=>{n[e]=t[e]})),n.Jsep=t;var s={name:"ternary",init(e){e.hooks.add("after-expression",(function(t){if(t.node&&this.code===e.QUMARK_CODE){this.index++;const r=t.node,n=this.gobbleExpression();if(n||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===e.COLON_CODE){this.index++;const i=this.gobbleExpression();if(i||this.throwError("Expected expression"),t.node={type:"ConditionalExpression",test:r,consequent:n,alternate:i},r.operator&&e.binary_ops[r.operator]<=.9){let n=r;for(;n.right.operator&&e.binary_ops[n.right.operator]<=.9;)n=n.right;t.node.test=n.right,n.right=t.node,t.node=r}}else this.throwError("Expected :")}}))}};n.plugins.register(s);var o={name:"regex",init(e){e.hooks.add("gobble-token",(function(t){if(47===this.code){const r=++this.index;let n=!1;for(;this.index<this.expr.length;){if(47===this.code&&!n){const n=this.expr.slice(r,this.index);let i,s="";for(;++this.index<this.expr.length;){const e=this.code;if(!(e>=97&&e<=122||e>=65&&e<=90||e>=48&&e<=57))break;s+=this.char}try{i=new RegExp(n,s)}catch(e){this.throwError(e.message)}return t.node={type:e.LITERAL,value:i,raw:this.expr.slice(r-1,this.index)},t.node=this.gobbleTokenProperty(t.node),t.node}this.code===e.OBRACK_CODE?n=!0:n&&this.code===e.CBRACK_CODE&&(n=!1),this.index+=92===this.code?2:1}this.throwError("Unclosed Regex")}}))}};const a={name:"assignment",assignmentOperators:new Set(["=","*=","**=","/=","%=","+=","-=","<<=",">>=",">>>=","&=","^=","|="]),updateOperators:[43,45],assignmentPrecedence:.9,init(e){const t=[e.IDENTIFIER,e.MEMBER_EXP];function r(e){a.assignmentOperators.has(e.operator)?(e.type="AssignmentExpression",r(e.left),r(e.right)):e.operator||Object.values(e).forEach((e=>{e&&"object"==typeof e&&r(e)}))}a.assignmentOperators.forEach((t=>e.addBinaryOp(t,a.assignmentPrecedence,!0))),e.hooks.add("gobble-token",(function(e){const r=this.code;a.updateOperators.some((e=>e===r&&e===this.expr.charCodeAt(this.index+1)))&&(this.index+=2,e.node={type:"UpdateExpression",operator:43===r?"++":"--",argument:this.gobbleTokenProperty(this.gobbleIdentifier()),prefix:!0},e.node.argument&&t.includes(e.node.argument.type)||this.throwError(`Unexpected ${e.node.operator}`))})),e.hooks.add("after-token",(function(e){if(e.node){const r=this.code;a.updateOperators.some((e=>e===r&&e===this.expr.charCodeAt(this.index+1)))&&(t.includes(e.node.type)||this.throwError(`Unexpected ${e.node.operator}`),this.index+=2,e.node={type:"UpdateExpression",operator:43===r?"++":"--",argument:e.node,prefix:!1})}})),e.hooks.add("after-expression",(function(e){e.node&&r(e.node)}))}};n.plugins.register(o,a),n.addUnaryOp("typeof"),n.addLiteral("null",null),n.addLiteral("undefined",void 0);const h={evalAst(e,t){switch(e.type){case"BinaryExpression":case"LogicalExpression":return h.evalBinaryExpression(e,t);case"Compound":return h.evalCompound(e,t);case"ConditionalExpression":return h.evalConditionalExpression(e,t);case"Identifier":return h.evalIdentifier(e,t);case"Literal":return h.evalLiteral(e,t);case"MemberExpression":return h.evalMemberExpression(e,t);case"UnaryExpression":return h.evalUnaryExpression(e,t);case"ArrayExpression":return h.evalArrayExpression(e,t);case"CallExpression":return h.evalCallExpression(e,t);case"AssignmentExpression":return h.evalAssignmentExpression(e,t);default:throw SyntaxError("Unexpected expression",e)}},evalBinaryExpression:(e,t)=>({"||":(e,t)=>e||t(),"&&":(e,t)=>e&&t(),"|":(e,t)=>e|t(),"^":(e,t)=>e^t(),"&":(e,t)=>e&t(),"==":(e,t)=>e==t(),"!=":(e,t)=>e!=t(),"===":(e,t)=>e===t(),"!==":(e,t)=>e!==t(),"<":(e,t)=>e<t(),">":(e,t)=>e>t(),"<=":(e,t)=>e<=t(),">=":(e,t)=>e>=t(),"<<":(e,t)=>e<<t(),">>":(e,t)=>e>>t(),">>>":(e,t)=>e>>>t(),"+":(e,t)=>e+t(),"-":(e,t)=>e-t(),"*":(e,t)=>e*t(),"/":(e,t)=>e/t(),"%":(e,t)=>e%t()}[e.operator](h.evalAst(e.left,t),(()=>h.evalAst(e.right,t)))),evalCompound(e,t){let r;for(let n=0;n<e.body.length;n++){"Identifier"===e.body[n].type&&["var","let","const"].includes(e.body[n].name)&&e.body[n+1]&&"AssignmentExpression"===e.body[n+1].type&&(n+=1);const i=e.body[n];r=h.evalAst(i,t)}return r},evalConditionalExpression:(e,t)=>h.evalAst(e.test,t)?h.evalAst(e.consequent,t):h.evalAst(e.alternate,t),evalIdentifier(e,t){if(e.name in t)return t[e.name];throw ReferenceError(`${e.name} is not defined`)},evalLiteral:e=>e.value,evalMemberExpression(e,t){if("Identifier"===e.property.type&&"constructor"===e.property.name||"Identifier"===e.object.type&&"constructor"===e.object.name)throw new Error("'constructor' property is disabled");const r=e.computed?h.evalAst(e.property):e.property.name,n=h.evalAst(e.object,t),i=n[r];if("function"==typeof i){if(n===Function&&"bind"===r)throw new Error("Function.prototype.bind is disabled");if(n===Function&&("call"===r||"apply"===r))throw new Error("Function.prototype.call and Function.prototype.apply are disabled");return i===Function?i:i.bind(n)}return i},evalUnaryExpression:(e,t)=>({"-":e=>-h.evalAst(e,t),"!":e=>!h.evalAst(e,t),"~":e=>~h.evalAst(e,t),"+":e=>+h.evalAst(e,t),typeof:e=>typeof h.evalAst(e,t)}[e.operator](e.argument)),evalArrayExpression:(e,t)=>e.elements.map((e=>h.evalAst(e,t))),evalCallExpression(e,t){const r=e.arguments.map((e=>h.evalAst(e,t))),n=h.evalAst(e.callee,t);if(n===Function)throw new Error("Function constructor is disabled");return n(...r)},evalAssignmentExpression(e,t){if("Identifier"!==e.left.type)throw SyntaxError("Invalid left-hand side in assignment");const r=e.left.name;if("__proto__"===r)throw new Error("Assignment to __proto__ is disabled");const n=h.evalAst(e.right,t);return t[r]=n,t[r]}};function l(e,t){return(e=e.slice()).push(t),e}function c(e,t){return(t=t.slice()).unshift(e),t}class p extends Error{constructor(e){super('JSONPath should not be called with "new" (it prevents return of (unwrapped) scalar values)'),this.avoidNew=!0,this.value=e,this.name="NewError"}}function u(e,t,r,n,i){if(!(this instanceof u))try{return new u(e,t,r,n,i)}catch(e){if(!e.avoidNew)throw e;return e.value}"string"==typeof e&&(i=n,n=r,r=t,t=e,e=null);const s=e&&"object"==typeof e;if(e=e||{},this.json=e.json||r,this.path=e.path||t,this.resultType=e.resultType||"value",this.flatten=e.flatten||!1,this.wrap=!Object.hasOwn(e,"wrap")||e.wrap,this.sandbox=e.sandbox||{},this.eval=void 0===e.eval?"safe":e.eval,this.ignoreEvalErrors=void 0!==e.ignoreEvalErrors&&e.ignoreEvalErrors,this.parent=e.parent||null,this.parentProperty=e.parentProperty||null,this.callback=e.callback||n||null,this.otherTypeCallback=e.otherTypeCallback||i||function(){throw new TypeError("You must supply an otherTypeCallback callback option with the @other() operator.")},!1!==e.autostart){const n={path:s?e.path:t};s?"json"in e&&(n.json=e.json):n.json=r;const i=this.evaluate(n);if(!i||"object"!=typeof i)throw new p(i);return i}}u.prototype.evaluate=function(e,t,r,n){let i=this.parent,s=this.parentProperty,{flatten:o,wrap:a}=this;if(this.currResultType=this.resultType,this.currEval=this.eval,this.currSandbox=this.sandbox,r=r||this.callback,this.currOtherTypeCallback=n||this.otherTypeCallback,t=t||this.json,(e=e||this.path)&&"object"==typeof e&&!Array.isArray(e)){if(!e.path&&""!==e.path)throw new TypeError('You must supply a "path" property when providing an object argument to JSONPath.evaluate().');if(!Object.hasOwn(e,"json"))throw new TypeError('You must supply a "json" property when providing an object argument to JSONPath.evaluate().');({json:t}=e),o=Object.hasOwn(e,"flatten")?e.flatten:o,this.currResultType=Object.hasOwn(e,"resultType")?e.resultType:this.currResultType,this.currSandbox=Object.hasOwn(e,"sandbox")?e.sandbox:this.currSandbox,a=Object.hasOwn(e,"wrap")?e.wrap:a,this.currEval=Object.hasOwn(e,"eval")?e.eval:this.currEval,r=Object.hasOwn(e,"callback")?e.callback:r,this.currOtherTypeCallback=Object.hasOwn(e,"otherTypeCallback")?e.otherTypeCallback:this.currOtherTypeCallback,i=Object.hasOwn(e,"parent")?e.parent:i,s=Object.hasOwn(e,"parentProperty")?e.parentProperty:s,e=e.path}if(i=i||null,s=s||null,Array.isArray(e)&&(e=u.toPathString(e)),!e&&""!==e||!t)return;const h=u.toPathArray(e);"$"===h[0]&&h.length>1&&h.shift(),this._hasParentSelector=null;const l=this._trace(h,t,["$"],i,s,r).filter((function(e){return e&&!e.isParentSelector}));return l.length?a||1!==l.length||l[0].hasArrExpr?l.reduce(((e,t)=>{const r=this._getPreferredOutput(t);return o&&Array.isArray(r)?e=e.concat(r):e.push(r),e}),[]):this._getPreferredOutput(l[0]):a?[]:void 0},u.prototype._getPreferredOutput=function(e){const t=this.currResultType;switch(t){case"all":{const t=Array.isArray(e.path)?e.path:u.toPathArray(e.path);return e.pointer=u.toPointer(t),e.path="string"==typeof e.path?e.path:u.toPathString(e.path),e}case"value":case"parent":case"parentProperty":return e[t];case"path":return u.toPathString(e[t]);case"pointer":return u.toPointer(e.path);default:throw new TypeError("Unknown result type")}},u.prototype._handleCallback=function(e,t,r){if(t){const n=this._getPreferredOutput(e);e.path="string"==typeof e.path?e.path:u.toPathString(e.path),t(n,r,e)}},u.prototype._trace=function(e,t,r,n,i,s,o,a){let h;if(!e.length)return h={path:r,value:t,parent:n,parentProperty:i,hasArrExpr:o},this._handleCallback(h,s,"value"),h;const p=e[0],u=e.slice(1),d=[];function f(e){Array.isArray(e)?e.forEach((e=>{d.push(e)})):d.push(e)}if(("string"!=typeof p||a)&&t&&Object.hasOwn(t,p))f(this._trace(u,t[p],l(r,p),t,p,s,o));else if("*"===p)this._walk(t,(e=>{f(this._trace(u,t[e],l(r,e),t,e,s,!0,!0))}));else if(".."===p)f(this._trace(u,t,r,n,i,s,o)),this._walk(t,(n=>{"object"==typeof t[n]&&f(this._trace(e.slice(),t[n],l(r,n),t,n,s,!0))}));else{if("^"===p)return this._hasParentSelector=!0,{path:r.slice(0,-1),expr:u,isParentSelector:!0};if("~"===p)return h={path:l(r,p),value:i,parent:n,parentProperty:null},this._handleCallback(h,s,"property"),h;if("$"===p)f(this._trace(u,t,r,null,null,s,o));else if(/^(-?\d*):(-?\d*):?(\d*)$/u.test(p))f(this._slice(p,u,t,r,n,i,s));else if(0===p.indexOf("?(")){if(!1===this.currEval)throw new Error("Eval [?(expr)] prevented in JSONPath expression.");const e=p.replace(/^\?\((.*?)\)$/u,"$1"),o=/@.?([^?]*)[['](\??\(.*?\))(?!.\)\])[\]']/gu.exec(e);o?this._walk(t,(e=>{const a=[o[2]],h=o[1]?t[e][o[1]]:t[e];this._trace(a,h,r,n,i,s,!0).length>0&&f(this._trace(u,t[e],l(r,e),t,e,s,!0))})):this._walk(t,(o=>{this._eval(e,t[o],o,r,n,i)&&f(this._trace(u,t[o],l(r,o),t,o,s,!0))}))}else if("("===p[0]){if(!1===this.currEval)throw new Error("Eval [(expr)] prevented in JSONPath expression.");f(this._trace(c(this._eval(p,t,r.at(-1),r.slice(0,-1),n,i),u),t,r,n,i,s,o))}else if("@"===p[0]){let e=!1;const o=p.slice(1,-2);switch(o){case"scalar":t&&["object","function"].includes(typeof t)||(e=!0);break;case"boolean":case"string":case"undefined":case"function":typeof t===o&&(e=!0);break;case"integer":!Number.isFinite(t)||t%1||(e=!0);break;case"number":Number.isFinite(t)&&(e=!0);break;case"nonFinite":"number"!=typeof t||Number.isFinite(t)||(e=!0);break;case"object":t&&typeof t===o&&(e=!0);break;case"array":Array.isArray(t)&&(e=!0);break;case"other":e=this.currOtherTypeCallback(t,r,n,i);break;case"null":null===t&&(e=!0);break;default:throw new TypeError("Unknown value type "+o)}if(e)return h={path:r,value:t,parent:n,parentProperty:i},this._handleCallback(h,s,"value"),h}else if("`"===p[0]&&t&&Object.hasOwn(t,p.slice(1))){const e=p.slice(1);f(this._trace(u,t[e],l(r,e),t,e,s,o,!0))}else if(p.includes(",")){const e=p.split(",");for(const o of e)f(this._trace(c(o,u),t,r,n,i,s,!0))}else!a&&t&&Object.hasOwn(t,p)&&f(this._trace(u,t[p],l(r,p),t,p,s,o,!0))}if(this._hasParentSelector)for(let e=0;e<d.length;e++){const r=d[e];if(r&&r.isParentSelector){const a=this._trace(r.expr,t,r.path,n,i,s,o);if(Array.isArray(a)){d[e]=a[0];const t=a.length;for(let r=1;r<t;r++)e++,d.splice(e,0,a[r])}else d[e]=a}}return d},u.prototype._walk=function(e,t){if(Array.isArray(e)){const r=e.length;for(let e=0;e<r;e++)t(e)}else e&&"object"==typeof e&&Object.keys(e).forEach((e=>{t(e)}))},u.prototype._slice=function(e,t,r,n,i,s,o){if(!Array.isArray(r))return;const a=r.length,h=e.split(":"),l=h[2]&&Number.parseInt(h[2])||1;let p=h[0]&&Number.parseInt(h[0])||0,u=h[1]&&Number.parseInt(h[1])||a;p=p<0?Math.max(0,p+a):Math.min(a,p),u=u<0?Math.max(0,u+a):Math.min(a,u);const d=[];for(let e=p;e<u;e+=l){this._trace(c(e,t),r,n,i,s,o,!0).forEach((e=>{d.push(e)}))}return d},u.prototype._eval=function(e,t,r,n,i,s){this.currSandbox._$_parentProperty=s,this.currSandbox._$_parent=i,this.currSandbox._$_property=r,this.currSandbox._$_root=this.json,this.currSandbox._$_v=t;const o=e.includes("@path");o&&(this.currSandbox._$_path=u.toPathString(n.concat([r])));const a=this.currEval+"Script:"+e;if(!u.cache[a]){let t=e.replaceAll("@parentProperty","_$_parentProperty").replaceAll("@parent","_$_parent").replaceAll("@property","_$_property").replaceAll("@root","_$_root").replaceAll(/@([.\s)[])/gu,"_$_v$1");if(o&&(t=t.replaceAll("@path","_$_path")),"safe"===this.currEval||!0===this.currEval||void 0===this.currEval)u.cache[a]=new this.safeVm.Script(t);else if("native"===this.currEval)u.cache[a]=new this.vm.Script(t);else if("function"==typeof this.currEval&&this.currEval.prototype&&Object.hasOwn(this.currEval.prototype,"runInNewContext")){const e=this.currEval;u.cache[a]=new e(t)}else{if("function"!=typeof this.currEval)throw new TypeError(`Unknown "eval" property "${this.currEval}"`);u.cache[a]={runInNewContext:e=>this.currEval(t,e)}}}try{return u.cache[a].runInNewContext(this.currSandbox)}catch(t){if(this.ignoreEvalErrors)return!1;throw new Error("jsonPath: "+t.message+": "+e)}},u.cache={},u.toPathString=function(e){const t=e,r=t.length;let n="$";for(let e=1;e<r;e++)/^(~|\^|@.*?\(\))$/u.test(t[e])||(n+=/^[0-9*]+$/u.test(t[e])?"["+t[e]+"]":"['"+t[e]+"']");return n},u.toPointer=function(e){const t=e,r=t.length;let n="";for(let e=1;e<r;e++)/^(~|\^|@.*?\(\))$/u.test(t[e])||(n+="/"+t[e].toString().replaceAll("~","~0").replaceAll("/","~1"));return n},u.toPathArray=function(e){const{cache:t}=u;if(t[e])return t[e].concat();const r=[],n=e.replaceAll(/@(?:null|boolean|number|string|integer|undefined|nonFinite|scalar|array|object|function|other)\(\)/gu,";$&;").replaceAll(/[['](\??\(.*?\))[\]'](?!.\])/gu,(function(e,t){return"[#"+(r.push(t)-1)+"]"})).replaceAll(/\[['"]([^'\]]*)['"]\]/gu,(function(e,t){return"['"+t.replaceAll(".","%@%").replaceAll("~","%%@@%%")+"']"})).replaceAll("~",";~;").replaceAll(/['"]?\.['"]?(?![^[]*\])|\[['"]?/gu,";").replaceAll("%@%",".").replaceAll("%%@@%%","~").replaceAll(/(?:;)?(\^+)(?:;)?/gu,(function(e,t){return";"+t.split("").join(";")+";"})).replaceAll(/;;;|;;/gu,";..;").replaceAll(/;$|'?\]|'$/gu,"").split(";").map((function(e){const t=e.match(/#(\d+)/u);return t&&t[1]?r[t[1]]:e}));return t[e]=n,t[e].concat()},u.prototype.safeVm={Script:class{constructor(e){this.code=e,this.ast=n(this.code)}runInNewContext(e){const t={...e};return h.evalAst(this.ast,t)}}};u.prototype.vm={Script:class{constructor(e){this.code=e}runInNewContext(e){let t=this.code;const r=Object.keys(e),n=[];!function(e,t,r){const n=e.length;for(let i=0;i<n;i++)r(e[i])&&t.push(e.splice(i--,1)[0])}(r,n,(t=>"function"==typeof e[t]));const i=r.map((t=>e[t]));t=n.reduce(((t,r)=>{let n=e[r].toString();return/function/u.test(n)||(n="function "+n),"var "+r+"="+n+";"+t}),"")+t,/(['"])use strict\1/u.test(t)||r.includes("arguments")||(t="var arguments = undefined;"+t),t=t.replace(/;\s*$/u,"");const s=t.lastIndexOf(";"),o=s>-1?t.slice(0,s+1)+" return "+t.slice(s+1):" return "+t;return new Function(...r,o)(...i)}}},e.JSONPath=u})); +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).JSONPath={})}(this,(function(e){"use strict";class t{static get version(){return"1.3.9"}static toString(){return"JavaScript Expression Parser (JSEP) v"+t.version}static addUnaryOp(e){return t.max_unop_len=Math.max(e.length,t.max_unop_len),t.unary_ops[e]=1,t}static addBinaryOp(e,r,s){return t.max_binop_len=Math.max(e.length,t.max_binop_len),t.binary_ops[e]=r,s?t.right_associative.add(e):t.right_associative.delete(e),t}static addIdentifierChar(e){return t.additional_identifier_chars.add(e),t}static addLiteral(e,r){return t.literals[e]=r,t}static removeUnaryOp(e){return delete t.unary_ops[e],e.length===t.max_unop_len&&(t.max_unop_len=t.getMaxKeyLen(t.unary_ops)),t}static removeAllUnaryOps(){return t.unary_ops={},t.max_unop_len=0,t}static removeIdentifierChar(e){return t.additional_identifier_chars.delete(e),t}static removeBinaryOp(e){return delete t.binary_ops[e],e.length===t.max_binop_len&&(t.max_binop_len=t.getMaxKeyLen(t.binary_ops)),t.right_associative.delete(e),t}static removeAllBinaryOps(){return t.binary_ops={},t.max_binop_len=0,t}static removeLiteral(e){return delete t.literals[e],t}static removeAllLiterals(){return t.literals={},t}get char(){return this.expr.charAt(this.index)}get code(){return this.expr.charCodeAt(this.index)}constructor(e){this.expr=e,this.index=0}static parse(e){return new t(e).parse()}static getMaxKeyLen(e){return Math.max(0,...Object.keys(e).map((e=>e.length)))}static isDecimalDigit(e){return e>=48&&e<=57}static binaryPrecedence(e){return t.binary_ops[e]||0}static isIdentifierStart(e){return e>=65&&e<=90||e>=97&&e<=122||e>=128&&!t.binary_ops[String.fromCharCode(e)]||t.additional_identifier_chars.has(String.fromCharCode(e))}static isIdentifierPart(e){return t.isIdentifierStart(e)||t.isDecimalDigit(e)}throwError(e){const t=new Error(e+" at character "+this.index);throw t.index=this.index,t.description=e,t}runHook(e,r){if(t.hooks[e]){const s={context:this,node:r};return t.hooks.run(e,s),s.node}return r}searchHook(e){if(t.hooks[e]){const r={context:this};return t.hooks[e].find((function(e){return e.call(r.context,r),r.node})),r.node}}gobbleSpaces(){let e=this.code;for(;e===t.SPACE_CODE||e===t.TAB_CODE||e===t.LF_CODE||e===t.CR_CODE;)e=this.expr.charCodeAt(++this.index);this.runHook("gobble-spaces")}parse(){this.runHook("before-all");const e=this.gobbleExpressions(),r=1===e.length?e[0]:{type:t.COMPOUND,body:e};return this.runHook("after-all",r)}gobbleExpressions(e){let r,s,n=[];for(;this.index<this.expr.length;)if(r=this.code,r===t.SEMCOL_CODE||r===t.COMMA_CODE)this.index++;else if(s=this.gobbleExpression())n.push(s);else if(this.index<this.expr.length){if(r===e)break;this.throwError('Unexpected "'+this.char+'"')}return n}gobbleExpression(){const e=this.searchHook("gobble-expression")||this.gobbleBinaryExpression();return this.gobbleSpaces(),this.runHook("after-expression",e)}gobbleBinaryOp(){this.gobbleSpaces();let e=this.expr.substr(this.index,t.max_binop_len),r=e.length;for(;r>0;){if(t.binary_ops.hasOwnProperty(e)&&(!t.isIdentifierStart(this.code)||this.index+e.length<this.expr.length&&!t.isIdentifierPart(this.expr.charCodeAt(this.index+e.length))))return this.index+=r,e;e=e.substr(0,--r)}return!1}gobbleBinaryExpression(){let e,r,s,n,i,o,a,h,l;if(o=this.gobbleToken(),!o)return o;if(r=this.gobbleBinaryOp(),!r)return o;for(i={value:r,prec:t.binaryPrecedence(r),right_a:t.right_associative.has(r)},a=this.gobbleToken(),a||this.throwError("Expected expression after "+r),n=[o,i,a];r=this.gobbleBinaryOp();){if(s=t.binaryPrecedence(r),0===s){this.index-=r.length;break}i={value:r,prec:s,right_a:t.right_associative.has(r)},l=r;const h=e=>i.right_a&&e.right_a?s>e.prec:s<=e.prec;for(;n.length>2&&h(n[n.length-2]);)a=n.pop(),r=n.pop().value,o=n.pop(),e={type:t.BINARY_EXP,operator:r,left:o,right:a},n.push(e);e=this.gobbleToken(),e||this.throwError("Expected expression after "+l),n.push(i,e)}for(h=n.length-1,e=n[h];h>1;)e={type:t.BINARY_EXP,operator:n[h-1].value,left:n[h-2],right:e},h-=2;return e}gobbleToken(){let e,r,s,n;if(this.gobbleSpaces(),n=this.searchHook("gobble-token"),n)return this.runHook("after-token",n);if(e=this.code,t.isDecimalDigit(e)||e===t.PERIOD_CODE)return this.gobbleNumericLiteral();if(e===t.SQUOTE_CODE||e===t.DQUOTE_CODE)n=this.gobbleStringLiteral();else if(e===t.OBRACK_CODE)n=this.gobbleArray();else{for(r=this.expr.substr(this.index,t.max_unop_len),s=r.length;s>0;){if(t.unary_ops.hasOwnProperty(r)&&(!t.isIdentifierStart(this.code)||this.index+r.length<this.expr.length&&!t.isIdentifierPart(this.expr.charCodeAt(this.index+r.length)))){this.index+=s;const e=this.gobbleToken();return e||this.throwError("missing unaryOp argument"),this.runHook("after-token",{type:t.UNARY_EXP,operator:r,argument:e,prefix:!0})}r=r.substr(0,--s)}t.isIdentifierStart(e)?(n=this.gobbleIdentifier(),t.literals.hasOwnProperty(n.name)?n={type:t.LITERAL,value:t.literals[n.name],raw:n.name}:n.name===t.this_str&&(n={type:t.THIS_EXP})):e===t.OPAREN_CODE&&(n=this.gobbleGroup())}return n?(n=this.gobbleTokenProperty(n),this.runHook("after-token",n)):this.runHook("after-token",!1)}gobbleTokenProperty(e){this.gobbleSpaces();let r=this.code;for(;r===t.PERIOD_CODE||r===t.OBRACK_CODE||r===t.OPAREN_CODE||r===t.QUMARK_CODE;){let s;if(r===t.QUMARK_CODE){if(this.expr.charCodeAt(this.index+1)!==t.PERIOD_CODE)break;s=!0,this.index+=2,this.gobbleSpaces(),r=this.code}this.index++,r===t.OBRACK_CODE?((e={type:t.MEMBER_EXP,computed:!0,object:e,property:this.gobbleExpression()}).property||this.throwError('Unexpected "'+this.char+'"'),this.gobbleSpaces(),r=this.code,r!==t.CBRACK_CODE&&this.throwError("Unclosed ["),this.index++):r===t.OPAREN_CODE?e={type:t.CALL_EXP,arguments:this.gobbleArguments(t.CPAREN_CODE),callee:e}:(r===t.PERIOD_CODE||s)&&(s&&this.index--,this.gobbleSpaces(),e={type:t.MEMBER_EXP,computed:!1,object:e,property:this.gobbleIdentifier()}),s&&(e.optional=!0),this.gobbleSpaces(),r=this.code}return e}gobbleNumericLiteral(){let e,r,s="";for(;t.isDecimalDigit(this.code);)s+=this.expr.charAt(this.index++);if(this.code===t.PERIOD_CODE)for(s+=this.expr.charAt(this.index++);t.isDecimalDigit(this.code);)s+=this.expr.charAt(this.index++);if(e=this.char,"e"===e||"E"===e){for(s+=this.expr.charAt(this.index++),e=this.char,"+"!==e&&"-"!==e||(s+=this.expr.charAt(this.index++));t.isDecimalDigit(this.code);)s+=this.expr.charAt(this.index++);t.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+s+this.char+")")}return r=this.code,t.isIdentifierStart(r)?this.throwError("Variable names cannot start with a number ("+s+this.char+")"):(r===t.PERIOD_CODE||1===s.length&&s.charCodeAt(0)===t.PERIOD_CODE)&&this.throwError("Unexpected period"),{type:t.LITERAL,value:parseFloat(s),raw:s}}gobbleStringLiteral(){let e="";const r=this.index,s=this.expr.charAt(this.index++);let n=!1;for(;this.index<this.expr.length;){let t=this.expr.charAt(this.index++);if(t===s){n=!0;break}if("\\"===t)switch(t=this.expr.charAt(this.index++),t){case"n":e+="\n";break;case"r":e+="\r";break;case"t":e+="\t";break;case"b":e+="\b";break;case"f":e+="\f";break;case"v":e+="\v";break;default:e+=t}else e+=t}return n||this.throwError('Unclosed quote after "'+e+'"'),{type:t.LITERAL,value:e,raw:this.expr.substring(r,this.index)}}gobbleIdentifier(){let e=this.code,r=this.index;for(t.isIdentifierStart(e)?this.index++:this.throwError("Unexpected "+this.char);this.index<this.expr.length&&(e=this.code,t.isIdentifierPart(e));)this.index++;return{type:t.IDENTIFIER,name:this.expr.slice(r,this.index)}}gobbleArguments(e){const r=[];let s=!1,n=0;for(;this.index<this.expr.length;){this.gobbleSpaces();let i=this.code;if(i===e){s=!0,this.index++,e===t.CPAREN_CODE&&n&&n>=r.length&&this.throwError("Unexpected token "+String.fromCharCode(e));break}if(i===t.COMMA_CODE){if(this.index++,n++,n!==r.length)if(e===t.CPAREN_CODE)this.throwError("Unexpected token ,");else if(e===t.CBRACK_CODE)for(let e=r.length;e<n;e++)r.push(null)}else if(r.length!==n&&0!==n)this.throwError("Expected comma");else{const e=this.gobbleExpression();e&&e.type!==t.COMPOUND||this.throwError("Expected comma"),r.push(e)}}return s||this.throwError("Expected "+String.fromCharCode(e)),r}gobbleGroup(){this.index++;let e=this.gobbleExpressions(t.CPAREN_CODE);if(this.code===t.CPAREN_CODE)return this.index++,1===e.length?e[0]:!!e.length&&{type:t.SEQUENCE_EXP,expressions:e};this.throwError("Unclosed (")}gobbleArray(){return this.index++,{type:t.ARRAY_EXP,elements:this.gobbleArguments(t.CBRACK_CODE)}}}const r=new class{add(e,t,r){if("string"!=typeof arguments[0])for(let e in arguments[0])this.add(e,arguments[0][e],arguments[1]);else(Array.isArray(e)?e:[e]).forEach((function(e){this[e]=this[e]||[],t&&this[e][r?"unshift":"push"](t)}),this)}run(e,t){this[e]=this[e]||[],this[e].forEach((function(e){e.call(t&&t.context?t.context:t,t)}))}};Object.assign(t,{hooks:r,plugins:new class{constructor(e){this.jsep=e,this.registered={}}register(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];t.forEach((e=>{if("object"!=typeof e||!e.name||!e.init)throw new Error("Invalid JSEP plugin format");this.registered[e.name]||(e.init(this.jsep),this.registered[e.name]=e)}))}}(t),COMPOUND:"Compound",SEQUENCE_EXP:"SequenceExpression",IDENTIFIER:"Identifier",MEMBER_EXP:"MemberExpression",LITERAL:"Literal",THIS_EXP:"ThisExpression",CALL_EXP:"CallExpression",UNARY_EXP:"UnaryExpression",BINARY_EXP:"BinaryExpression",ARRAY_EXP:"ArrayExpression",TAB_CODE:9,LF_CODE:10,CR_CODE:13,SPACE_CODE:32,PERIOD_CODE:46,COMMA_CODE:44,SQUOTE_CODE:39,DQUOTE_CODE:34,OPAREN_CODE:40,CPAREN_CODE:41,OBRACK_CODE:91,CBRACK_CODE:93,QUMARK_CODE:63,SEMCOL_CODE:59,COLON_CODE:58,unary_ops:{"-":1,"!":1,"~":1,"+":1},binary_ops:{"||":1,"&&":2,"|":3,"^":4,"&":5,"==":6,"!=":6,"===":6,"!==":6,"<":7,">":7,"<=":7,">=":7,"<<":8,">>":8,">>>":8,"+":9,"-":9,"*":10,"/":10,"%":10},right_associative:new Set,additional_identifier_chars:new Set(["$","_"]),literals:{true:!0,false:!1,null:null},this_str:"this"}),t.max_unop_len=t.getMaxKeyLen(t.unary_ops),t.max_binop_len=t.getMaxKeyLen(t.binary_ops);const s=e=>new t(e).parse(),n=Object.getOwnPropertyNames(class{});Object.getOwnPropertyNames(t).filter((e=>!n.includes(e)&&void 0===s[e])).forEach((e=>{s[e]=t[e]})),s.Jsep=t;var i={name:"ternary",init(e){e.hooks.add("after-expression",(function(t){if(t.node&&this.code===e.QUMARK_CODE){this.index++;const r=t.node,s=this.gobbleExpression();if(s||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===e.COLON_CODE){this.index++;const n=this.gobbleExpression();if(n||this.throwError("Expected expression"),t.node={type:"ConditionalExpression",test:r,consequent:s,alternate:n},r.operator&&e.binary_ops[r.operator]<=.9){let s=r;for(;s.right.operator&&e.binary_ops[s.right.operator]<=.9;)s=s.right;t.node.test=s.right,s.right=t.node,t.node=r}}else this.throwError("Expected :")}}))}};s.plugins.register(i);var o={name:"regex",init(e){e.hooks.add("gobble-token",(function(t){if(47===this.code){const r=++this.index;let s=!1;for(;this.index<this.expr.length;){if(47===this.code&&!s){const s=this.expr.slice(r,this.index);let n,i="";for(;++this.index<this.expr.length;){const e=this.code;if(!(e>=97&&e<=122||e>=65&&e<=90||e>=48&&e<=57))break;i+=this.char}try{n=new RegExp(s,i)}catch(e){this.throwError(e.message)}return t.node={type:e.LITERAL,value:n,raw:this.expr.slice(r-1,this.index)},t.node=this.gobbleTokenProperty(t.node),t.node}this.code===e.OBRACK_CODE?s=!0:s&&this.code===e.CBRACK_CODE&&(s=!1),this.index+=92===this.code?2:1}this.throwError("Unclosed Regex")}}))}};const a={name:"assignment",assignmentOperators:new Set(["=","*=","**=","/=","%=","+=","-=","<<=",">>=",">>>=","&=","^=","|="]),updateOperators:[43,45],assignmentPrecedence:.9,init(e){const t=[e.IDENTIFIER,e.MEMBER_EXP];function r(e){a.assignmentOperators.has(e.operator)?(e.type="AssignmentExpression",r(e.left),r(e.right)):e.operator||Object.values(e).forEach((e=>{e&&"object"==typeof e&&r(e)}))}a.assignmentOperators.forEach((t=>e.addBinaryOp(t,a.assignmentPrecedence,!0))),e.hooks.add("gobble-token",(function(e){const r=this.code;a.updateOperators.some((e=>e===r&&e===this.expr.charCodeAt(this.index+1)))&&(this.index+=2,e.node={type:"UpdateExpression",operator:43===r?"++":"--",argument:this.gobbleTokenProperty(this.gobbleIdentifier()),prefix:!0},e.node.argument&&t.includes(e.node.argument.type)||this.throwError(`Unexpected ${e.node.operator}`))})),e.hooks.add("after-token",(function(e){if(e.node){const r=this.code;a.updateOperators.some((e=>e===r&&e===this.expr.charCodeAt(this.index+1)))&&(t.includes(e.node.type)||this.throwError(`Unexpected ${e.node.operator}`),this.index+=2,e.node={type:"UpdateExpression",operator:43===r?"++":"--",argument:e.node,prefix:!1})}})),e.hooks.add("after-expression",(function(e){e.node&&r(e.node)}))}};s.plugins.register(o,a),s.addUnaryOp("typeof"),s.addLiteral("null",null),s.addLiteral("undefined",void 0);const h=new Set(["constructor","__proto__","__defineGetter__","__defineSetter__"]),l={evalAst(e,t){switch(e.type){case"BinaryExpression":case"LogicalExpression":return l.evalBinaryExpression(e,t);case"Compound":return l.evalCompound(e,t);case"ConditionalExpression":return l.evalConditionalExpression(e,t);case"Identifier":return l.evalIdentifier(e,t);case"Literal":return l.evalLiteral(e,t);case"MemberExpression":return l.evalMemberExpression(e,t);case"UnaryExpression":return l.evalUnaryExpression(e,t);case"ArrayExpression":return l.evalArrayExpression(e,t);case"CallExpression":return l.evalCallExpression(e,t);case"AssignmentExpression":return l.evalAssignmentExpression(e,t);default:throw SyntaxError("Unexpected expression",e)}},evalBinaryExpression:(e,t)=>({"||":(e,t)=>e||t(),"&&":(e,t)=>e&&t(),"|":(e,t)=>e|t(),"^":(e,t)=>e^t(),"&":(e,t)=>e&t(),"==":(e,t)=>e==t(),"!=":(e,t)=>e!=t(),"===":(e,t)=>e===t(),"!==":(e,t)=>e!==t(),"<":(e,t)=>e<t(),">":(e,t)=>e>t(),"<=":(e,t)=>e<=t(),">=":(e,t)=>e>=t(),"<<":(e,t)=>e<<t(),">>":(e,t)=>e>>t(),">>>":(e,t)=>e>>>t(),"+":(e,t)=>e+t(),"-":(e,t)=>e-t(),"*":(e,t)=>e*t(),"/":(e,t)=>e/t(),"%":(e,t)=>e%t()}[e.operator](l.evalAst(e.left,t),(()=>l.evalAst(e.right,t)))),evalCompound(e,t){let r;for(let s=0;s<e.body.length;s++){"Identifier"===e.body[s].type&&["var","let","const"].includes(e.body[s].name)&&e.body[s+1]&&"AssignmentExpression"===e.body[s+1].type&&(s+=1);const n=e.body[s];r=l.evalAst(n,t)}return r},evalConditionalExpression:(e,t)=>l.evalAst(e.test,t)?l.evalAst(e.consequent,t):l.evalAst(e.alternate,t),evalIdentifier(e,t){if(Object.hasOwn(t,e.name))return t[e.name];throw ReferenceError(`${e.name} is not defined`)},evalLiteral:e=>e.value,evalMemberExpression(e,t){const r=e.computed?l.evalAst(e.property):e.property.name,s=l.evalAst(e.object,t);if(null==s)throw TypeError(`Cannot read properties of ${s} (reading '${r}')`);if(!Object.hasOwn(s,r)&&h.has(r))throw TypeError(`Cannot read properties of ${s} (reading '${r}')`);const n=s[r];return"function"==typeof n?n.bind(s):n},evalUnaryExpression:(e,t)=>({"-":e=>-l.evalAst(e,t),"!":e=>!l.evalAst(e,t),"~":e=>~l.evalAst(e,t),"+":e=>+l.evalAst(e,t),typeof:e=>typeof l.evalAst(e,t)}[e.operator](e.argument)),evalArrayExpression:(e,t)=>e.elements.map((e=>l.evalAst(e,t))),evalCallExpression(e,t){const r=e.arguments.map((e=>l.evalAst(e,t)));return l.evalAst(e.callee,t)(...r)},evalAssignmentExpression(e,t){if("Identifier"!==e.left.type)throw SyntaxError("Invalid left-hand side in assignment");const r=e.left.name,s=l.evalAst(e.right,t);return t[r]=s,t[r]}};function c(e,t){return(e=e.slice()).push(t),e}function p(e,t){return(t=t.slice()).unshift(e),t}class u extends Error{constructor(e){super('JSONPath should not be called with "new" (it prevents return of (unwrapped) scalar values)'),this.avoidNew=!0,this.value=e,this.name="NewError"}}function d(e,t,r,s,n){if(!(this instanceof d))try{return new d(e,t,r,s,n)}catch(e){if(!e.avoidNew)throw e;return e.value}"string"==typeof e&&(n=s,s=r,r=t,t=e,e=null);const i=e&&"object"==typeof e;if(e=e||{},this.json=e.json||r,this.path=e.path||t,this.resultType=e.resultType||"value",this.flatten=e.flatten||!1,this.wrap=!Object.hasOwn(e,"wrap")||e.wrap,this.sandbox=e.sandbox||{},this.eval=void 0===e.eval?"safe":e.eval,this.ignoreEvalErrors=void 0!==e.ignoreEvalErrors&&e.ignoreEvalErrors,this.parent=e.parent||null,this.parentProperty=e.parentProperty||null,this.callback=e.callback||s||null,this.otherTypeCallback=e.otherTypeCallback||n||function(){throw new TypeError("You must supply an otherTypeCallback callback option with the @other() operator.")},!1!==e.autostart){const s={path:i?e.path:t};i?"json"in e&&(s.json=e.json):s.json=r;const n=this.evaluate(s);if(!n||"object"!=typeof n)throw new u(n);return n}}d.prototype.evaluate=function(e,t,r,s){let n=this.parent,i=this.parentProperty,{flatten:o,wrap:a}=this;if(this.currResultType=this.resultType,this.currEval=this.eval,this.currSandbox=this.sandbox,r=r||this.callback,this.currOtherTypeCallback=s||this.otherTypeCallback,t=t||this.json,(e=e||this.path)&&"object"==typeof e&&!Array.isArray(e)){if(!e.path&&""!==e.path)throw new TypeError('You must supply a "path" property when providing an object argument to JSONPath.evaluate().');if(!Object.hasOwn(e,"json"))throw new TypeError('You must supply a "json" property when providing an object argument to JSONPath.evaluate().');({json:t}=e),o=Object.hasOwn(e,"flatten")?e.flatten:o,this.currResultType=Object.hasOwn(e,"resultType")?e.resultType:this.currResultType,this.currSandbox=Object.hasOwn(e,"sandbox")?e.sandbox:this.currSandbox,a=Object.hasOwn(e,"wrap")?e.wrap:a,this.currEval=Object.hasOwn(e,"eval")?e.eval:this.currEval,r=Object.hasOwn(e,"callback")?e.callback:r,this.currOtherTypeCallback=Object.hasOwn(e,"otherTypeCallback")?e.otherTypeCallback:this.currOtherTypeCallback,n=Object.hasOwn(e,"parent")?e.parent:n,i=Object.hasOwn(e,"parentProperty")?e.parentProperty:i,e=e.path}if(n=n||null,i=i||null,Array.isArray(e)&&(e=d.toPathString(e)),!e&&""!==e||!t)return;const h=d.toPathArray(e);"$"===h[0]&&h.length>1&&h.shift(),this._hasParentSelector=null;const l=this._trace(h,t,["$"],n,i,r).filter((function(e){return e&&!e.isParentSelector}));return l.length?a||1!==l.length||l[0].hasArrExpr?l.reduce(((e,t)=>{const r=this._getPreferredOutput(t);return o&&Array.isArray(r)?e=e.concat(r):e.push(r),e}),[]):this._getPreferredOutput(l[0]):a?[]:void 0},d.prototype._getPreferredOutput=function(e){const t=this.currResultType;switch(t){case"all":{const t=Array.isArray(e.path)?e.path:d.toPathArray(e.path);return e.pointer=d.toPointer(t),e.path="string"==typeof e.path?e.path:d.toPathString(e.path),e}case"value":case"parent":case"parentProperty":return e[t];case"path":return d.toPathString(e[t]);case"pointer":return d.toPointer(e.path);default:throw new TypeError("Unknown result type")}},d.prototype._handleCallback=function(e,t,r){if(t){const s=this._getPreferredOutput(e);e.path="string"==typeof e.path?e.path:d.toPathString(e.path),t(s,r,e)}},d.prototype._trace=function(e,t,r,s,n,i,o,a){let h;if(!e.length)return h={path:r,value:t,parent:s,parentProperty:n,hasArrExpr:o},this._handleCallback(h,i,"value"),h;const l=e[0],u=e.slice(1),d=[];function f(e){Array.isArray(e)?e.forEach((e=>{d.push(e)})):d.push(e)}if(("string"!=typeof l||a)&&t&&Object.hasOwn(t,l))f(this._trace(u,t[l],c(r,l),t,l,i,o));else if("*"===l)this._walk(t,(e=>{f(this._trace(u,t[e],c(r,e),t,e,i,!0,!0))}));else if(".."===l)f(this._trace(u,t,r,s,n,i,o)),this._walk(t,(s=>{"object"==typeof t[s]&&f(this._trace(e.slice(),t[s],c(r,s),t,s,i,!0))}));else{if("^"===l)return this._hasParentSelector=!0,{path:r.slice(0,-1),expr:u,isParentSelector:!0};if("~"===l)return h={path:c(r,l),value:n,parent:s,parentProperty:null},this._handleCallback(h,i,"property"),h;if("$"===l)f(this._trace(u,t,r,null,null,i,o));else if(/^(-?\d*):(-?\d*):?(\d*)$/u.test(l))f(this._slice(l,u,t,r,s,n,i));else if(0===l.indexOf("?(")){if(!1===this.currEval)throw new Error("Eval [?(expr)] prevented in JSONPath expression.");const e=l.replace(/^\?\((.*?)\)$/u,"$1"),o=/@.?([^?]*)[['](\??\(.*?\))(?!.\)\])[\]']/gu.exec(e);o?this._walk(t,(e=>{const a=[o[2]],h=o[1]?t[e][o[1]]:t[e];this._trace(a,h,r,s,n,i,!0).length>0&&f(this._trace(u,t[e],c(r,e),t,e,i,!0))})):this._walk(t,(o=>{this._eval(e,t[o],o,r,s,n)&&f(this._trace(u,t[o],c(r,o),t,o,i,!0))}))}else if("("===l[0]){if(!1===this.currEval)throw new Error("Eval [(expr)] prevented in JSONPath expression.");f(this._trace(p(this._eval(l,t,r.at(-1),r.slice(0,-1),s,n),u),t,r,s,n,i,o))}else if("@"===l[0]){let e=!1;const o=l.slice(1,-2);switch(o){case"scalar":t&&["object","function"].includes(typeof t)||(e=!0);break;case"boolean":case"string":case"undefined":case"function":typeof t===o&&(e=!0);break;case"integer":!Number.isFinite(t)||t%1||(e=!0);break;case"number":Number.isFinite(t)&&(e=!0);break;case"nonFinite":"number"!=typeof t||Number.isFinite(t)||(e=!0);break;case"object":t&&typeof t===o&&(e=!0);break;case"array":Array.isArray(t)&&(e=!0);break;case"other":e=this.currOtherTypeCallback(t,r,s,n);break;case"null":null===t&&(e=!0);break;default:throw new TypeError("Unknown value type "+o)}if(e)return h={path:r,value:t,parent:s,parentProperty:n},this._handleCallback(h,i,"value"),h}else if("`"===l[0]&&t&&Object.hasOwn(t,l.slice(1))){const e=l.slice(1);f(this._trace(u,t[e],c(r,e),t,e,i,o,!0))}else if(l.includes(",")){const e=l.split(",");for(const o of e)f(this._trace(p(o,u),t,r,s,n,i,!0))}else!a&&t&&Object.hasOwn(t,l)&&f(this._trace(u,t[l],c(r,l),t,l,i,o,!0))}if(this._hasParentSelector)for(let e=0;e<d.length;e++){const r=d[e];if(r&&r.isParentSelector){const a=this._trace(r.expr,t,r.path,s,n,i,o);if(Array.isArray(a)){d[e]=a[0];const t=a.length;for(let r=1;r<t;r++)e++,d.splice(e,0,a[r])}else d[e]=a}}return d},d.prototype._walk=function(e,t){if(Array.isArray(e)){const r=e.length;for(let e=0;e<r;e++)t(e)}else e&&"object"==typeof e&&Object.keys(e).forEach((e=>{t(e)}))},d.prototype._slice=function(e,t,r,s,n,i,o){if(!Array.isArray(r))return;const a=r.length,h=e.split(":"),l=h[2]&&Number.parseInt(h[2])||1;let c=h[0]&&Number.parseInt(h[0])||0,u=h[1]&&Number.parseInt(h[1])||a;c=c<0?Math.max(0,c+a):Math.min(a,c),u=u<0?Math.max(0,u+a):Math.min(a,u);const d=[];for(let e=c;e<u;e+=l){this._trace(p(e,t),r,s,n,i,o,!0).forEach((e=>{d.push(e)}))}return d},d.prototype._eval=function(e,t,r,s,n,i){this.currSandbox._$_parentProperty=i,this.currSandbox._$_parent=n,this.currSandbox._$_property=r,this.currSandbox._$_root=this.json,this.currSandbox._$_v=t;const o=e.includes("@path");o&&(this.currSandbox._$_path=d.toPathString(s.concat([r])));const a=this.currEval+"Script:"+e;if(!d.cache[a]){let t=e.replaceAll("@parentProperty","_$_parentProperty").replaceAll("@parent","_$_parent").replaceAll("@property","_$_property").replaceAll("@root","_$_root").replaceAll(/@([.\s)[])/gu,"_$_v$1");if(o&&(t=t.replaceAll("@path","_$_path")),"safe"===this.currEval||!0===this.currEval||void 0===this.currEval)d.cache[a]=new this.safeVm.Script(t);else if("native"===this.currEval)d.cache[a]=new this.vm.Script(t);else if("function"==typeof this.currEval&&this.currEval.prototype&&Object.hasOwn(this.currEval.prototype,"runInNewContext")){const e=this.currEval;d.cache[a]=new e(t)}else{if("function"!=typeof this.currEval)throw new TypeError(`Unknown "eval" property "${this.currEval}"`);d.cache[a]={runInNewContext:e=>this.currEval(t,e)}}}try{return d.cache[a].runInNewContext(this.currSandbox)}catch(t){if(this.ignoreEvalErrors)return!1;throw new Error("jsonPath: "+t.message+": "+e)}},d.cache={},d.toPathString=function(e){const t=e,r=t.length;let s="$";for(let e=1;e<r;e++)/^(~|\^|@.*?\(\))$/u.test(t[e])||(s+=/^[0-9*]+$/u.test(t[e])?"["+t[e]+"]":"['"+t[e]+"']");return s},d.toPointer=function(e){const t=e,r=t.length;let s="";for(let e=1;e<r;e++)/^(~|\^|@.*?\(\))$/u.test(t[e])||(s+="/"+t[e].toString().replaceAll("~","~0").replaceAll("/","~1"));return s},d.toPathArray=function(e){const{cache:t}=d;if(t[e])return t[e].concat();const r=[],s=e.replaceAll(/@(?:null|boolean|number|string|integer|undefined|nonFinite|scalar|array|object|function|other)\(\)/gu,";$&;").replaceAll(/[['](\??\(.*?\))[\]'](?!.\])/gu,(function(e,t){return"[#"+(r.push(t)-1)+"]"})).replaceAll(/\[['"]([^'\]]*)['"]\]/gu,(function(e,t){return"['"+t.replaceAll(".","%@%").replaceAll("~","%%@@%%")+"']"})).replaceAll("~",";~;").replaceAll(/['"]?\.['"]?(?![^[]*\])|\[['"]?/gu,";").replaceAll("%@%",".").replaceAll("%%@@%%","~").replaceAll(/(?:;)?(\^+)(?:;)?/gu,(function(e,t){return";"+t.split("").join(";")+";"})).replaceAll(/;;;|;;/gu,";..;").replaceAll(/;$|'?\]|'$/gu,"").split(";").map((function(e){const t=e.match(/#(\d+)/u);return t&&t[1]?r[t[1]]:e}));return t[e]=s,t[e].concat()},d.prototype.safeVm={Script:class{constructor(e){this.code=e,this.ast=s(this.code)}runInNewContext(e){const t=Object.assign(Object.create(null),e);return l.evalAst(this.ast,t)}}};d.prototype.vm={Script:class{constructor(e){this.code=e}runInNewContext(e){let t=this.code;const r=Object.keys(e),s=[];!function(e,t,r){const s=e.length;for(let n=0;n<s;n++)r(e[n])&&t.push(e.splice(n--,1)[0])}(r,s,(t=>"function"==typeof e[t]));const n=r.map((t=>e[t]));t=s.reduce(((t,r)=>{let s=e[r].toString();return/function/u.test(s)||(s="function "+s),"var "+r+"="+s+";"+t}),"")+t,/(['"])use strict\1/u.test(t)||r.includes("arguments")||(t="var arguments = undefined;"+t),t=t.replace(/;\s*$/u,"");const i=t.lastIndexOf(";"),o=i>-1?t.slice(0,i+1)+" return "+t.slice(i+1):" return "+t;return new Function(...r,o)(...n)}}},e.JSONPath=d})); //# sourceMappingURL=index-browser-umd.min.cjs.map
dist/index-browser-umd.min.cjs.map+1 −1 modifieddist/index-node-cjs.cjs+13 −22 modified@@ -1204,6 +1204,7 @@ jsep.plugins.register(index, plugin); jsep.addUnaryOp('typeof'); jsep.addLiteral('null', null); jsep.addLiteral('undefined', undefined); +const BLOCKED_PROTO_PROPERTIES = new Set(['constructor', '__proto__', '__defineGetter__', '__defineSetter__']); const SafeEval = { /** * @param {jsep.Expression} ast @@ -1286,7 +1287,7 @@ const SafeEval = { return SafeEval.evalAst(ast.alternate, subs); }, evalIdentifier(ast, subs) { - if (ast.name in subs) { + if (Object.hasOwn(subs, ast.name)) { return subs[ast.name]; } throw ReferenceError(`${ast.name} is not defined`); @@ -1295,23 +1296,17 @@ const SafeEval = { return ast.value; }, evalMemberExpression(ast, subs) { - if (ast.property.type === 'Identifier' && ast.property.name === 'constructor' || ast.object.type === 'Identifier' && ast.object.name === 'constructor') { - throw new Error("'constructor' property is disabled"); - } const prop = ast.computed ? SafeEval.evalAst(ast.property) // `object[property]` : ast.property.name; // `object.property` property is Identifier const obj = SafeEval.evalAst(ast.object, subs); + if (obj === undefined || obj === null) { + throw TypeError(`Cannot read properties of ${obj} (reading '${prop}')`); + } + if (!Object.hasOwn(obj, prop) && BLOCKED_PROTO_PROPERTIES.has(prop)) { + throw TypeError(`Cannot read properties of ${obj} (reading '${prop}')`); + } const result = obj[prop]; if (typeof result === 'function') { - if (obj === Function && prop === 'bind') { - throw new Error('Function.prototype.bind is disabled'); - } - if (obj === Function && (prop === 'call' || prop === 'apply')) { - throw new Error('Function.prototype.call and ' + 'Function.prototype.apply are disabled'); - } - if (result === Function) { - return result; // Don't bind so can identify and throw later - } return result.bind(obj); // arrow functions aren't affected by bind. } return result; @@ -1333,19 +1328,16 @@ const SafeEval = { evalCallExpression(ast, subs) { const args = ast.arguments.map(arg => SafeEval.evalAst(arg, subs)); const func = SafeEval.evalAst(ast.callee, subs); - if (func === Function) { - throw new Error('Function constructor is disabled'); - } + // if (func === Function) { + // throw new Error('Function constructor is disabled'); + // } return func(...args); }, evalAssignmentExpression(ast, subs) { if (ast.left.type !== 'Identifier') { throw SyntaxError('Invalid left-hand side in assignment'); } const id = ast.left.name; - if (id === '__proto__') { - throw new Error('Assignment to __proto__ is disabled'); - } const value = SafeEval.evalAst(ast.right, subs); subs[id] = value; return subs[id]; @@ -1370,9 +1362,8 @@ class SafeScript { * @returns {EvaluatedResult} Result of evaluated code */ runInNewContext(context) { - const keyMap = { - ...context - }; + // `Object.create(null)` creates a prototypeless object + const keyMap = Object.assign(Object.create(null), context); return SafeEval.evalAst(this.ast, keyMap); } }
dist/index-node-esm.js+13 −22 modified@@ -1202,6 +1202,7 @@ jsep.plugins.register(index, plugin); jsep.addUnaryOp('typeof'); jsep.addLiteral('null', null); jsep.addLiteral('undefined', undefined); +const BLOCKED_PROTO_PROPERTIES = new Set(['constructor', '__proto__', '__defineGetter__', '__defineSetter__']); const SafeEval = { /** * @param {jsep.Expression} ast @@ -1284,7 +1285,7 @@ const SafeEval = { return SafeEval.evalAst(ast.alternate, subs); }, evalIdentifier(ast, subs) { - if (ast.name in subs) { + if (Object.hasOwn(subs, ast.name)) { return subs[ast.name]; } throw ReferenceError(`${ast.name} is not defined`); @@ -1293,23 +1294,17 @@ const SafeEval = { return ast.value; }, evalMemberExpression(ast, subs) { - if (ast.property.type === 'Identifier' && ast.property.name === 'constructor' || ast.object.type === 'Identifier' && ast.object.name === 'constructor') { - throw new Error("'constructor' property is disabled"); - } const prop = ast.computed ? SafeEval.evalAst(ast.property) // `object[property]` : ast.property.name; // `object.property` property is Identifier const obj = SafeEval.evalAst(ast.object, subs); + if (obj === undefined || obj === null) { + throw TypeError(`Cannot read properties of ${obj} (reading '${prop}')`); + } + if (!Object.hasOwn(obj, prop) && BLOCKED_PROTO_PROPERTIES.has(prop)) { + throw TypeError(`Cannot read properties of ${obj} (reading '${prop}')`); + } const result = obj[prop]; if (typeof result === 'function') { - if (obj === Function && prop === 'bind') { - throw new Error('Function.prototype.bind is disabled'); - } - if (obj === Function && (prop === 'call' || prop === 'apply')) { - throw new Error('Function.prototype.call and ' + 'Function.prototype.apply are disabled'); - } - if (result === Function) { - return result; // Don't bind so can identify and throw later - } return result.bind(obj); // arrow functions aren't affected by bind. } return result; @@ -1331,19 +1326,16 @@ const SafeEval = { evalCallExpression(ast, subs) { const args = ast.arguments.map(arg => SafeEval.evalAst(arg, subs)); const func = SafeEval.evalAst(ast.callee, subs); - if (func === Function) { - throw new Error('Function constructor is disabled'); - } + // if (func === Function) { + // throw new Error('Function constructor is disabled'); + // } return func(...args); }, evalAssignmentExpression(ast, subs) { if (ast.left.type !== 'Identifier') { throw SyntaxError('Invalid left-hand side in assignment'); } const id = ast.left.name; - if (id === '__proto__') { - throw new Error('Assignment to __proto__ is disabled'); - } const value = SafeEval.evalAst(ast.right, subs); subs[id] = value; return subs[id]; @@ -1368,9 +1360,8 @@ class SafeScript { * @returns {EvaluatedResult} Result of evaluated code */ runInNewContext(context) { - const keyMap = { - ...context - }; + // `Object.create(null)` creates a prototypeless object + const keyMap = Object.assign(Object.create(null), context); return SafeEval.evalAst(this.ast, keyMap); } }
docs/ts/classes/EvalClass.html+2 −2 modified@@ -1,3 +1,3 @@ -<!DOCTYPE html><html class="default" lang="en"><head><meta charset="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>EvalClass | jsonpath-plus</title><meta name="description" content="Documentation for jsonpath-plus"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script defer src="../assets/main.js"></script><script async src="../assets/icons.js" id="tsd-icons-script"></script><script async src="../assets/search.js" id="tsd-search-script"></script><script async src="../assets/navigation.js" id="tsd-nav-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><div class="table-cell" id="tsd-search" data-base=".."><div class="field"><label for="tsd-search-field" class="tsd-widget tsd-toolbar-icon search no-caption"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-search"></use></svg></label><input type="text" id="tsd-search-field" aria-label="Search"/></div><div class="field"><div id="tsd-toolbar-links"></div></div><ul class="results"><li class="state loading">Preparing search index...</li><li class="state failure">The search index is not available</li></ul><a href="../index.html" class="title">jsonpath-plus</a></div><div class="table-cell" id="tsd-widgets"><a href="#" class="tsd-widget tsd-toolbar-icon menu no-caption" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-menu"></use></svg></a></div></div></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><ul class="tsd-breadcrumb"><li><a href="../modules.html">jsonpath-plus</a></li><li><a href="EvalClass.html">EvalClass</a></li></ul><h1>Class EvalClass</h1></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/a119240a17591a50176ef162e77d4305ebda73bd/src/jsonpath.d.ts#L11">jsonpath.d.ts:11</a></li></ul></aside><section class="tsd-panel-group tsd-index-group"><section class="tsd-panel tsd-index-panel"><details class="tsd-index-content tsd-accordion" open><summary class="tsd-accordion-summary tsd-index-summary"><h5 class="tsd-index-heading uppercase" role="button" aria-expanded="false" tabIndex="0"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-chevronSmall"></use></svg> Index</h5></summary><div class="tsd-accordion-details"><section class="tsd-index-section"><h3 class="tsd-index-heading">Constructors</h3><div class="tsd-index-list"><a href="EvalClass.html#constructor" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-512"></use></svg><span>constructor</span></a> +<!DOCTYPE html><html class="default" lang="en"><head><meta charset="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>EvalClass | jsonpath-plus</title><meta name="description" content="Documentation for jsonpath-plus"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script defer src="../assets/main.js"></script><script async src="../assets/icons.js" id="tsd-icons-script"></script><script async src="../assets/search.js" id="tsd-search-script"></script><script async src="../assets/navigation.js" id="tsd-nav-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><div class="table-cell" id="tsd-search" data-base=".."><div class="field"><label for="tsd-search-field" class="tsd-widget tsd-toolbar-icon search no-caption"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-search"></use></svg></label><input type="text" id="tsd-search-field" aria-label="Search"/></div><div class="field"><div id="tsd-toolbar-links"></div></div><ul class="results"><li class="state loading">Preparing search index...</li><li class="state failure">The search index is not available</li></ul><a href="../index.html" class="title">jsonpath-plus</a></div><div class="table-cell" id="tsd-widgets"><a href="#" class="tsd-widget tsd-toolbar-icon menu no-caption" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-menu"></use></svg></a></div></div></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><ul class="tsd-breadcrumb"><li><a href="../modules.html">jsonpath-plus</a></li><li><a href="EvalClass.html">EvalClass</a></li></ul><h1>Class EvalClass</h1></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/39ee1844c610f9fd8925d3095ed3971e3d48025e/src/jsonpath.d.ts#L11">jsonpath.d.ts:11</a></li></ul></aside><section class="tsd-panel-group tsd-index-group"><section class="tsd-panel tsd-index-panel"><details class="tsd-index-content tsd-accordion" open><summary class="tsd-accordion-summary tsd-index-summary"><h5 class="tsd-index-heading uppercase" role="button" aria-expanded="false" tabIndex="0"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-chevronSmall"></use></svg> Index</h5></summary><div class="tsd-accordion-details"><section class="tsd-index-section"><h3 class="tsd-index-heading">Constructors</h3><div class="tsd-index-list"><a href="EvalClass.html#constructor" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-512"></use></svg><span>constructor</span></a> </div></section><section class="tsd-index-section"><h3 class="tsd-index-heading">Methods</h3><div class="tsd-index-list"><a href="EvalClass.html#runInNewContext" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-2048"></use></svg><span>run<wbr/>In<wbr/>New<wbr/>Context</span></a> -</div></section></div></details></section></section><details class="tsd-panel-group tsd-member-group tsd-accordion" open><summary class="tsd-accordion-summary" data-key="section-Constructors"><h2><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg> Constructors</h2></summary><section><section class="tsd-panel tsd-member"><a id="constructor" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span>constructor</span><a href="#constructor" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class="tsd-signature tsd-anchor-link"><a id="constructor.new_EvalClass" class="tsd-anchor"></a><span class="tsd-kind-constructor-signature">new <wbr/>Eval<wbr/>Class</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">code</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="EvalClass.html" class="tsd-signature-type tsd-kind-class">EvalClass</a><a href="#constructor.new_EvalClass" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">code</span>: <span class="tsd-signature-type">string</span></span></li></ul></div><h4 class="tsd-returns-title">Returns <a href="EvalClass.html" class="tsd-signature-type tsd-kind-class">EvalClass</a></h4><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/a119240a17591a50176ef162e77d4305ebda73bd/src/jsonpath.d.ts#L12">jsonpath.d.ts:12</a></li></ul></aside></li></ul></section></section></details><details class="tsd-panel-group tsd-member-group tsd-accordion" open><summary class="tsd-accordion-summary" data-key="section-Methods"><h2><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg> Methods</h2></summary><section><section class="tsd-panel tsd-member"><a id="runInNewContext" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span>run<wbr/>In<wbr/>New<wbr/>Context</span><a href="#runInNewContext" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class="tsd-signature tsd-anchor-link"><a id="runInNewContext.runInNewContext-1" class="tsd-anchor"></a><span class="tsd-kind-call-signature">run<wbr/>In<wbr/>New<wbr/>Context</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">context</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">any</span><a href="#runInNewContext.runInNewContext-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">context</span>: <span class="tsd-signature-type">object</span></span></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">any</span></h4><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/a119240a17591a50176ef162e77d4305ebda73bd/src/jsonpath.d.ts#L13">jsonpath.d.ts:13</a></li></ul></aside></li></ul></section></section></details></div><div class="col-sidebar"><div class="page-menu"><div class="tsd-navigation settings"><details class="tsd-accordion"><summary class="tsd-accordion-summary"><h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Settings</h3></summary><div class="tsd-accordion-details"><div class="tsd-filter-visibility"><span class="settings-label">Member Visibility</span><ul id="tsd-filter-options"><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-protected" name="protected"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Protected</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-inherited" name="inherited" checked/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Inherited</span></label></li></ul></div><div class="tsd-theme-toggle"><label class="settings-label" for="tsd-theme">Theme</label><select id="tsd-theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div><details open class="tsd-accordion tsd-page-navigation"><summary class="tsd-accordion-summary"><h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>On This Page</h3></summary><div class="tsd-accordion-details"><details open class="tsd-accordion tsd-page-navigation-section"><summary class="tsd-accordion-summary" data-key="tsd-otp-Constructors"><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Constructors</summary><div><a href="#constructor" class=""><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-512"></use></svg><span>constructor</span></a></div></details><details open class="tsd-accordion tsd-page-navigation-section"><summary class="tsd-accordion-summary" data-key="tsd-otp-Methods"><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Methods</summary><div><a href="#runInNewContext" class=""><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-2048"></use></svg><span>run<wbr/>In<wbr/>New<wbr/>Context</span></a></div></details></div></details></div><div class="site-menu"><nav class="tsd-navigation"><a href="../modules.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1"></use></svg><span>jsonpath-plus</span></a><ul class="tsd-small-nested-navigation" id="tsd-nav-container" data-base=".."><li>Loading...</li></ul></nav></div></div></div><footer><p class="tsd-generator">Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></footer><div class="overlay"></div></body></html> +</div></section></div></details></section></section><details class="tsd-panel-group tsd-member-group tsd-accordion" open><summary class="tsd-accordion-summary" data-key="section-Constructors"><h2><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg> Constructors</h2></summary><section><section class="tsd-panel tsd-member"><a id="constructor" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span>constructor</span><a href="#constructor" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class="tsd-signature tsd-anchor-link"><a id="constructor.new_EvalClass" class="tsd-anchor"></a><span class="tsd-kind-constructor-signature">new <wbr/>Eval<wbr/>Class</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">code</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="EvalClass.html" class="tsd-signature-type tsd-kind-class">EvalClass</a><a href="#constructor.new_EvalClass" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">code</span>: <span class="tsd-signature-type">string</span></span></li></ul></div><h4 class="tsd-returns-title">Returns <a href="EvalClass.html" class="tsd-signature-type tsd-kind-class">EvalClass</a></h4><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/39ee1844c610f9fd8925d3095ed3971e3d48025e/src/jsonpath.d.ts#L12">jsonpath.d.ts:12</a></li></ul></aside></li></ul></section></section></details><details class="tsd-panel-group tsd-member-group tsd-accordion" open><summary class="tsd-accordion-summary" data-key="section-Methods"><h2><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg> Methods</h2></summary><section><section class="tsd-panel tsd-member"><a id="runInNewContext" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span>run<wbr/>In<wbr/>New<wbr/>Context</span><a href="#runInNewContext" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class="tsd-signature tsd-anchor-link"><a id="runInNewContext.runInNewContext-1" class="tsd-anchor"></a><span class="tsd-kind-call-signature">run<wbr/>In<wbr/>New<wbr/>Context</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">context</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">any</span><a href="#runInNewContext.runInNewContext-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">context</span>: <span class="tsd-signature-type">object</span></span></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">any</span></h4><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/39ee1844c610f9fd8925d3095ed3971e3d48025e/src/jsonpath.d.ts#L13">jsonpath.d.ts:13</a></li></ul></aside></li></ul></section></section></details></div><div class="col-sidebar"><div class="page-menu"><div class="tsd-navigation settings"><details class="tsd-accordion"><summary class="tsd-accordion-summary"><h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Settings</h3></summary><div class="tsd-accordion-details"><div class="tsd-filter-visibility"><span class="settings-label">Member Visibility</span><ul id="tsd-filter-options"><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-protected" name="protected"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Protected</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-inherited" name="inherited" checked/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Inherited</span></label></li></ul></div><div class="tsd-theme-toggle"><label class="settings-label" for="tsd-theme">Theme</label><select id="tsd-theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div><details open class="tsd-accordion tsd-page-navigation"><summary class="tsd-accordion-summary"><h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>On This Page</h3></summary><div class="tsd-accordion-details"><details open class="tsd-accordion tsd-page-navigation-section"><summary class="tsd-accordion-summary" data-key="tsd-otp-Constructors"><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Constructors</summary><div><a href="#constructor" class=""><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-512"></use></svg><span>constructor</span></a></div></details><details open class="tsd-accordion tsd-page-navigation-section"><summary class="tsd-accordion-summary" data-key="tsd-otp-Methods"><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Methods</summary><div><a href="#runInNewContext" class=""><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-2048"></use></svg><span>run<wbr/>In<wbr/>New<wbr/>Context</span></a></div></details></div></details></div><div class="site-menu"><nav class="tsd-navigation"><a href="../modules.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1"></use></svg><span>jsonpath-plus</span></a><ul class="tsd-small-nested-navigation" id="tsd-nav-container" data-base=".."><li>Loading...</li></ul></nav></div></div></div><footer><p class="tsd-generator">Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></footer><div class="overlay"></div></body></html>
docs/ts/classes/JSONPathClass.html+5 −5 modified@@ -1,23 +1,23 @@ -<!DOCTYPE html><html class="default" lang="en"><head><meta charset="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>JSONPathClass | jsonpath-plus</title><meta name="description" content="Documentation for jsonpath-plus"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script defer src="../assets/main.js"></script><script async src="../assets/icons.js" id="tsd-icons-script"></script><script async src="../assets/search.js" id="tsd-search-script"></script><script async src="../assets/navigation.js" id="tsd-nav-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><div class="table-cell" id="tsd-search" data-base=".."><div class="field"><label for="tsd-search-field" class="tsd-widget tsd-toolbar-icon search no-caption"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-search"></use></svg></label><input type="text" id="tsd-search-field" aria-label="Search"/></div><div class="field"><div id="tsd-toolbar-links"></div></div><ul class="results"><li class="state loading">Preparing search index...</li><li class="state failure">The search index is not available</li></ul><a href="../index.html" class="title">jsonpath-plus</a></div><div class="table-cell" id="tsd-widgets"><a href="#" class="tsd-widget tsd-toolbar-icon menu no-caption" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-menu"></use></svg></a></div></div></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><ul class="tsd-breadcrumb"><li><a href="../modules.html">jsonpath-plus</a></li><li><a href="JSONPathClass.html">JSONPathClass</a></li></ul><h1>Class JSONPathClass</h1></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/a119240a17591a50176ef162e77d4305ebda73bd/src/jsonpath.d.ts#L174">jsonpath.d.ts:174</a></li></ul></aside><section class="tsd-panel-group tsd-index-group"><section class="tsd-panel tsd-index-panel"><details class="tsd-index-content tsd-accordion" open><summary class="tsd-accordion-summary tsd-index-summary"><h5 class="tsd-index-heading uppercase" role="button" aria-expanded="false" tabIndex="0"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-chevronSmall"></use></svg> Index</h5></summary><div class="tsd-accordion-details"><section class="tsd-index-section"><h3 class="tsd-index-heading">Constructors</h3><div class="tsd-index-list"><a href="JSONPathClass.html#constructor" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-512"></use></svg><span>constructor</span></a> +<!DOCTYPE html><html class="default" lang="en"><head><meta charset="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>JSONPathClass | jsonpath-plus</title><meta name="description" content="Documentation for jsonpath-plus"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script defer src="../assets/main.js"></script><script async src="../assets/icons.js" id="tsd-icons-script"></script><script async src="../assets/search.js" id="tsd-search-script"></script><script async src="../assets/navigation.js" id="tsd-nav-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><div class="table-cell" id="tsd-search" data-base=".."><div class="field"><label for="tsd-search-field" class="tsd-widget tsd-toolbar-icon search no-caption"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-search"></use></svg></label><input type="text" id="tsd-search-field" aria-label="Search"/></div><div class="field"><div id="tsd-toolbar-links"></div></div><ul class="results"><li class="state loading">Preparing search index...</li><li class="state failure">The search index is not available</li></ul><a href="../index.html" class="title">jsonpath-plus</a></div><div class="table-cell" id="tsd-widgets"><a href="#" class="tsd-widget tsd-toolbar-icon menu no-caption" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-menu"></use></svg></a></div></div></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><ul class="tsd-breadcrumb"><li><a href="../modules.html">jsonpath-plus</a></li><li><a href="JSONPathClass.html">JSONPathClass</a></li></ul><h1>Class JSONPathClass</h1></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/39ee1844c610f9fd8925d3095ed3971e3d48025e/src/jsonpath.d.ts#L174">jsonpath.d.ts:174</a></li></ul></aside><section class="tsd-panel-group tsd-index-group"><section class="tsd-panel tsd-index-panel"><details class="tsd-index-content tsd-accordion" open><summary class="tsd-accordion-summary tsd-index-summary"><h5 class="tsd-index-heading uppercase" role="button" aria-expanded="false" tabIndex="0"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-chevronSmall"></use></svg> Index</h5></summary><div class="tsd-accordion-details"><section class="tsd-index-section"><h3 class="tsd-index-heading">Constructors</h3><div class="tsd-index-list"><a href="JSONPathClass.html#constructor" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-512"></use></svg><span>constructor</span></a> </div></section><section class="tsd-index-section"><h3 class="tsd-index-heading">Properties</h3><div class="tsd-index-list"><a href="JSONPathClass.html#cache" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1024"></use></svg><span>cache</span></a> </div></section><section class="tsd-index-section"><h3 class="tsd-index-heading">Methods</h3><div class="tsd-index-list"><a href="JSONPathClass.html#evaluate" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-2048"></use></svg><span>evaluate</span></a> <a href="JSONPathClass.html#toPathArray" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-2048"></use></svg><span>to<wbr/>Path<wbr/>Array</span></a> <a href="JSONPathClass.html#toPathString" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-2048"></use></svg><span>to<wbr/>Path<wbr/>String</span></a> <a href="JSONPathClass.html#toPointer" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-2048"></use></svg><span>to<wbr/>Pointer</span></a> </div></section></div></details></section></section><details class="tsd-panel-group tsd-member-group tsd-accordion" open><summary class="tsd-accordion-summary" data-key="section-Constructors"><h2><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg> Constructors</h2></summary><section><section class="tsd-panel tsd-member"><a id="constructor" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span>constructor</span><a href="#constructor" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class="tsd-signature tsd-anchor-link"><a id="constructor.new_JSONPathClass" class="tsd-anchor"></a><span class="tsd-kind-constructor-signature">new JSONPath<wbr/>Class</span><span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="JSONPathClass.html" class="tsd-signature-type tsd-kind-class">JSONPathClass</a><a href="#constructor.new_JSONPathClass" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><h4 class="tsd-returns-title">Returns <a href="JSONPathClass.html" class="tsd-signature-type tsd-kind-class">JSONPathClass</a></h4></li></ul></section></section></details><details class="tsd-panel-group tsd-member-group tsd-accordion" open><summary class="tsd-accordion-summary" data-key="section-Properties"><h2><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg> Properties</h2></summary><section><section class="tsd-panel tsd-member"><a id="cache" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span>cache</span><a href="#cache" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><div class="tsd-signature"><span class="tsd-kind-property">cache</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">any</span></div><div class="tsd-comment tsd-typography"><p>Exposes the cache object for those who wish to preserve and reuse it for optimization purposes.</p> -</div><div class="tsd-comment tsd-typography"></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/a119240a17591a50176ef162e77d4305ebda73bd/src/jsonpath.d.ts#L179">jsonpath.d.ts:179</a></li></ul></aside></section></section></details><details class="tsd-panel-group tsd-member-group tsd-accordion" open><summary class="tsd-accordion-summary" data-key="section-Methods"><h2><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg> Methods</h2></summary><section><section class="tsd-panel tsd-member"><a id="evaluate" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span>evaluate</span><a href="#evaluate" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class="tsd-signature tsd-anchor-link"><a id="evaluate.evaluate-1" class="tsd-anchor"></a><span class="tsd-kind-call-signature">evaluate</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">path</span>, <span class="tsd-kind-parameter">json</span>, <span class="tsd-kind-parameter">callback</span>, <span class="tsd-kind-parameter">otherTypeCallback</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">any</span><a href="#evaluate.evaluate-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">path</span>: <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">[]</span></span></li><li><span><span class="tsd-kind-parameter">json</span>: <br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">string</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">number</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">boolean</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">object</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">[]</span></span></li><li><span><span class="tsd-kind-parameter">callback</span>: <a href="../types/JSONPathCallback.html" class="tsd-signature-type tsd-kind-type-alias">JSONPathCallback</a></span></li><li><span><span class="tsd-kind-parameter">otherTypeCallback</span>: <a href="../types/JSONPathOtherTypeCallback.html" class="tsd-signature-type tsd-kind-type-alias">JSONPathOtherTypeCallback</a></span></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">any</span></h4><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/a119240a17591a50176ef162e77d4305ebda73bd/src/jsonpath.d.ts#L209">jsonpath.d.ts:209</a></li></ul></aside></li><li class="tsd-signature tsd-anchor-link"><a id="evaluate.evaluate-2" class="tsd-anchor"></a><span class="tsd-kind-call-signature">evaluate</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">options</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">any</span><a href="#evaluate.evaluate-2" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">options</span>: <span class="tsd-signature-symbol">{ </span><br/><span> </span><span class="tsd-kind-property">callback</span><span class="tsd-signature-symbol">: </span><a href="../types/JSONPathCallback.html" class="tsd-signature-type tsd-kind-type-alias">JSONPathCallback</a><span class="tsd-signature-symbol">; </span><br/><span> </span><span class="tsd-kind-property">json</span><span class="tsd-signature-symbol">: </span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">string</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">number</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">boolean</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">object</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">; </span><br/><span> </span><span class="tsd-kind-property">otherTypeCallback</span><span class="tsd-signature-symbol">: </span><a href="../types/JSONPathOtherTypeCallback.html" class="tsd-signature-type tsd-kind-type-alias">JSONPathOtherTypeCallback</a><span class="tsd-signature-symbol">; </span><br/><span> </span><span class="tsd-kind-property">path</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">; </span><br/><span class="tsd-signature-symbol">}</span></span><ul class="tsd-parameters"><li class="tsd-parameter"><h5><span class="tsd-kind-property">callback</span><span class="tsd-signature-symbol">: </span><a href="../types/JSONPathCallback.html" class="tsd-signature-type tsd-kind-type-alias">JSONPathCallback</a></h5></li><li class="tsd-parameter"><h5><span class="tsd-kind-property">json</span><span class="tsd-signature-symbol">: </span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">string</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">number</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">boolean</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">object</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">[]</span></h5></li><li class="tsd-parameter"><h5><span class="tsd-kind-property">other<wbr/>Type<wbr/>Callback</span><span class="tsd-signature-symbol">: </span><a href="../types/JSONPathOtherTypeCallback.html" class="tsd-signature-type tsd-kind-type-alias">JSONPathOtherTypeCallback</a></h5></li><li class="tsd-parameter"><h5><span class="tsd-kind-property">path</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">[]</span></h5></li></ul></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">any</span></h4><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/a119240a17591a50176ef162e77d4305ebda73bd/src/jsonpath.d.ts#L215">jsonpath.d.ts:215</a></li></ul></aside></li></ul></section><section class="tsd-panel tsd-member"><a id="toPathArray" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span>to<wbr/>Path<wbr/>Array</span><a href="#toPathArray" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class="tsd-signature tsd-anchor-link"><a id="toPathArray.toPathArray-1" class="tsd-anchor"></a><span class="tsd-kind-call-signature">to<wbr/>Path<wbr/>Array</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">path</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">[]</span><a href="#toPathArray.toPathArray-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><div class="tsd-comment tsd-typography"><p>Accepts a normalized or unnormalized path as string and +</div><div class="tsd-comment tsd-typography"></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/39ee1844c610f9fd8925d3095ed3971e3d48025e/src/jsonpath.d.ts#L179">jsonpath.d.ts:179</a></li></ul></aside></section></section></details><details class="tsd-panel-group tsd-member-group tsd-accordion" open><summary class="tsd-accordion-summary" data-key="section-Methods"><h2><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg> Methods</h2></summary><section><section class="tsd-panel tsd-member"><a id="evaluate" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span>evaluate</span><a href="#evaluate" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class="tsd-signature tsd-anchor-link"><a id="evaluate.evaluate-1" class="tsd-anchor"></a><span class="tsd-kind-call-signature">evaluate</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">path</span>, <span class="tsd-kind-parameter">json</span>, <span class="tsd-kind-parameter">callback</span>, <span class="tsd-kind-parameter">otherTypeCallback</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">any</span><a href="#evaluate.evaluate-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">path</span>: <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">[]</span></span></li><li><span><span class="tsd-kind-parameter">json</span>: <br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">string</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">number</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">boolean</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">object</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">[]</span></span></li><li><span><span class="tsd-kind-parameter">callback</span>: <a href="../types/JSONPathCallback.html" class="tsd-signature-type tsd-kind-type-alias">JSONPathCallback</a></span></li><li><span><span class="tsd-kind-parameter">otherTypeCallback</span>: <a href="../types/JSONPathOtherTypeCallback.html" class="tsd-signature-type tsd-kind-type-alias">JSONPathOtherTypeCallback</a></span></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">any</span></h4><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/39ee1844c610f9fd8925d3095ed3971e3d48025e/src/jsonpath.d.ts#L209">jsonpath.d.ts:209</a></li></ul></aside></li><li class="tsd-signature tsd-anchor-link"><a id="evaluate.evaluate-2" class="tsd-anchor"></a><span class="tsd-kind-call-signature">evaluate</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">options</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">any</span><a href="#evaluate.evaluate-2" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">options</span>: <span class="tsd-signature-symbol">{ </span><br/><span> </span><span class="tsd-kind-property">callback</span><span class="tsd-signature-symbol">: </span><a href="../types/JSONPathCallback.html" class="tsd-signature-type tsd-kind-type-alias">JSONPathCallback</a><span class="tsd-signature-symbol">; </span><br/><span> </span><span class="tsd-kind-property">json</span><span class="tsd-signature-symbol">: </span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">string</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">number</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">boolean</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">object</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">; </span><br/><span> </span><span class="tsd-kind-property">otherTypeCallback</span><span class="tsd-signature-symbol">: </span><a href="../types/JSONPathOtherTypeCallback.html" class="tsd-signature-type tsd-kind-type-alias">JSONPathOtherTypeCallback</a><span class="tsd-signature-symbol">; </span><br/><span> </span><span class="tsd-kind-property">path</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">; </span><br/><span class="tsd-signature-symbol">}</span></span><ul class="tsd-parameters"><li class="tsd-parameter"><h5><span class="tsd-kind-property">callback</span><span class="tsd-signature-symbol">: </span><a href="../types/JSONPathCallback.html" class="tsd-signature-type tsd-kind-type-alias">JSONPathCallback</a></h5></li><li class="tsd-parameter"><h5><span class="tsd-kind-property">json</span><span class="tsd-signature-symbol">: </span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">string</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">number</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">boolean</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">object</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">[]</span></h5></li><li class="tsd-parameter"><h5><span class="tsd-kind-property">other<wbr/>Type<wbr/>Callback</span><span class="tsd-signature-symbol">: </span><a href="../types/JSONPathOtherTypeCallback.html" class="tsd-signature-type tsd-kind-type-alias">JSONPathOtherTypeCallback</a></h5></li><li class="tsd-parameter"><h5><span class="tsd-kind-property">path</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">[]</span></h5></li></ul></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">any</span></h4><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/39ee1844c610f9fd8925d3095ed3971e3d48025e/src/jsonpath.d.ts#L215">jsonpath.d.ts:215</a></li></ul></aside></li></ul></section><section class="tsd-panel tsd-member"><a id="toPathArray" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span>to<wbr/>Path<wbr/>Array</span><a href="#toPathArray" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class="tsd-signature tsd-anchor-link"><a id="toPathArray.toPathArray-1" class="tsd-anchor"></a><span class="tsd-kind-call-signature">to<wbr/>Path<wbr/>Array</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">path</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">[]</span><a href="#toPathArray.toPathArray-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><div class="tsd-comment tsd-typography"><p>Accepts a normalized or unnormalized path as string and converts to an array: for example, <code>['$', 'aProperty', 'anotherProperty']</code>.</p> -</div><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">path</span>: <span class="tsd-signature-type">string</span></span></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">[]</span></h4><div class="tsd-comment tsd-typography"></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/a119240a17591a50176ef162e77d4305ebda73bd/src/jsonpath.d.ts#L186">jsonpath.d.ts:186</a></li></ul></aside></li></ul></section><section class="tsd-panel tsd-member"><a id="toPathString" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span>to<wbr/>Path<wbr/>String</span><a href="#toPathString" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class="tsd-signature tsd-anchor-link"><a id="toPathString.toPathString-1" class="tsd-anchor"></a><span class="tsd-kind-call-signature">to<wbr/>Path<wbr/>String</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">path</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><a href="#toPathString.toPathString-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><div class="tsd-comment tsd-typography"><p>Accepts a path array and converts to a normalized path string. +</div><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">path</span>: <span class="tsd-signature-type">string</span></span></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">[]</span></h4><div class="tsd-comment tsd-typography"></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/39ee1844c610f9fd8925d3095ed3971e3d48025e/src/jsonpath.d.ts#L186">jsonpath.d.ts:186</a></li></ul></aside></li></ul></section><section class="tsd-panel tsd-member"><a id="toPathString" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span>to<wbr/>Path<wbr/>String</span><a href="#toPathString" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class="tsd-signature tsd-anchor-link"><a id="toPathString.toPathString-1" class="tsd-anchor"></a><span class="tsd-kind-call-signature">to<wbr/>Path<wbr/>String</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">path</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><a href="#toPathString.toPathString-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><div class="tsd-comment tsd-typography"><p>Accepts a path array and converts to a normalized path string. The string will be in a form like: <code>$['aProperty']['anotherProperty][0]</code>. The JSONPath terminal constructions <code>~</code> and <code>^</code> and type operators like <code>@string()</code> are silently stripped.</p> -</div><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">path</span>: <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">[]</span></span></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">string</span></h4><div class="tsd-comment tsd-typography"></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/a119240a17591a50176ef162e77d4305ebda73bd/src/jsonpath.d.ts#L195">jsonpath.d.ts:195</a></li></ul></aside></li></ul></section><section class="tsd-panel tsd-member"><a id="toPointer" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span>to<wbr/>Pointer</span><a href="#toPointer" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class="tsd-signature tsd-anchor-link"><a id="toPointer.toPointer-1" class="tsd-anchor"></a><span class="tsd-kind-call-signature">to<wbr/>Pointer</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">path</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">any</span><a href="#toPointer.toPointer-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><div class="tsd-comment tsd-typography"><p>Accepts a path array and converts to a JSON Pointer.</p> +</div><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">path</span>: <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">[]</span></span></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">string</span></h4><div class="tsd-comment tsd-typography"></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/39ee1844c610f9fd8925d3095ed3971e3d48025e/src/jsonpath.d.ts#L195">jsonpath.d.ts:195</a></li></ul></aside></li></ul></section><section class="tsd-panel tsd-member"><a id="toPointer" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span>to<wbr/>Pointer</span><a href="#toPointer" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class="tsd-signature tsd-anchor-link"><a id="toPointer.toPointer-1" class="tsd-anchor"></a><span class="tsd-kind-call-signature">to<wbr/>Pointer</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">path</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">any</span><a href="#toPointer.toPointer-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><div class="tsd-comment tsd-typography"><p>Accepts a path array and converts to a JSON Pointer.</p> <p>The string will be in a form like: <code>/aProperty/anotherProperty/0</code> (with any <code>~</code> and <code>/</code> internal characters escaped as per the JSON Pointer spec).</p> <p>The JSONPath terminal constructions <code>~</code> and <code>^</code> and type operators like <code>@string()</code> are silently stripped.</p> -</div><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">path</span>: <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">[]</span></span></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">any</span></h4><div class="tsd-comment tsd-typography"></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/a119240a17591a50176ef162e77d4305ebda73bd/src/jsonpath.d.ts#L207">jsonpath.d.ts:207</a></li></ul></aside></li></ul></section></section></details></div><div class="col-sidebar"><div class="page-menu"><div class="tsd-navigation settings"><details class="tsd-accordion"><summary class="tsd-accordion-summary"><h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Settings</h3></summary><div class="tsd-accordion-details"><div class="tsd-filter-visibility"><span class="settings-label">Member Visibility</span><ul id="tsd-filter-options"><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-protected" name="protected"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Protected</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-inherited" name="inherited" checked/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Inherited</span></label></li></ul></div><div class="tsd-theme-toggle"><label class="settings-label" for="tsd-theme">Theme</label><select id="tsd-theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div><details open class="tsd-accordion tsd-page-navigation"><summary class="tsd-accordion-summary"><h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>On This Page</h3></summary><div class="tsd-accordion-details"><details open class="tsd-accordion tsd-page-navigation-section"><summary class="tsd-accordion-summary" data-key="tsd-otp-Constructors"><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Constructors</summary><div><a href="#constructor" class=""><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-512"></use></svg><span>constructor</span></a></div></details><details open class="tsd-accordion tsd-page-navigation-section"><summary class="tsd-accordion-summary" data-key="tsd-otp-Properties"><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Properties</summary><div><a href="#cache" class=""><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1024"></use></svg><span>cache</span></a></div></details><details open class="tsd-accordion tsd-page-navigation-section"><summary class="tsd-accordion-summary" data-key="tsd-otp-Methods"><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Methods</summary><div><a href="#evaluate" class=""><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-2048"></use></svg><span>evaluate</span></a><a href="#toPathArray" class=""><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-2048"></use></svg><span>to<wbr/>Path<wbr/>Array</span></a><a href="#toPathString" class=""><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-2048"></use></svg><span>to<wbr/>Path<wbr/>String</span></a><a href="#toPointer" class=""><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-2048"></use></svg><span>to<wbr/>Pointer</span></a></div></details></div></details></div><div class="site-menu"><nav class="tsd-navigation"><a href="../modules.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1"></use></svg><span>jsonpath-plus</span></a><ul class="tsd-small-nested-navigation" id="tsd-nav-container" data-base=".."><li>Loading...</li></ul></nav></div></div></div><footer><p class="tsd-generator">Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></footer><div class="overlay"></div></body></html> +</div><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">path</span>: <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">[]</span></span></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">any</span></h4><div class="tsd-comment tsd-typography"></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/39ee1844c610f9fd8925d3095ed3971e3d48025e/src/jsonpath.d.ts#L207">jsonpath.d.ts:207</a></li></ul></aside></li></ul></section></section></details></div><div class="col-sidebar"><div class="page-menu"><div class="tsd-navigation settings"><details class="tsd-accordion"><summary class="tsd-accordion-summary"><h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Settings</h3></summary><div class="tsd-accordion-details"><div class="tsd-filter-visibility"><span class="settings-label">Member Visibility</span><ul id="tsd-filter-options"><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-protected" name="protected"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Protected</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-inherited" name="inherited" checked/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Inherited</span></label></li></ul></div><div class="tsd-theme-toggle"><label class="settings-label" for="tsd-theme">Theme</label><select id="tsd-theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div><details open class="tsd-accordion tsd-page-navigation"><summary class="tsd-accordion-summary"><h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>On This Page</h3></summary><div class="tsd-accordion-details"><details open class="tsd-accordion tsd-page-navigation-section"><summary class="tsd-accordion-summary" data-key="tsd-otp-Constructors"><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Constructors</summary><div><a href="#constructor" class=""><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-512"></use></svg><span>constructor</span></a></div></details><details open class="tsd-accordion tsd-page-navigation-section"><summary class="tsd-accordion-summary" data-key="tsd-otp-Properties"><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Properties</summary><div><a href="#cache" class=""><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1024"></use></svg><span>cache</span></a></div></details><details open class="tsd-accordion tsd-page-navigation-section"><summary class="tsd-accordion-summary" data-key="tsd-otp-Methods"><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Methods</summary><div><a href="#evaluate" class=""><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-2048"></use></svg><span>evaluate</span></a><a href="#toPathArray" class=""><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-2048"></use></svg><span>to<wbr/>Path<wbr/>Array</span></a><a href="#toPathString" class=""><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-2048"></use></svg><span>to<wbr/>Path<wbr/>String</span></a><a href="#toPointer" class=""><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-2048"></use></svg><span>to<wbr/>Pointer</span></a></div></details></div></details></div><div class="site-menu"><nav class="tsd-navigation"><a href="../modules.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1"></use></svg><span>jsonpath-plus</span></a><ul class="tsd-small-nested-navigation" id="tsd-nav-container" data-base=".."><li>Loading...</li></ul></nav></div></div></div><footer><p class="tsd-generator">Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></footer><div class="overlay"></div></body></html>
docs/ts/functions/JSONPath.html+5 −5 modified@@ -1,22 +1,22 @@ -<!DOCTYPE html><html class="default" lang="en"><head><meta charset="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>JSONPath | jsonpath-plus</title><meta name="description" content="Documentation for jsonpath-plus"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script defer src="../assets/main.js"></script><script async src="../assets/icons.js" id="tsd-icons-script"></script><script async src="../assets/search.js" id="tsd-search-script"></script><script async src="../assets/navigation.js" id="tsd-nav-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><div class="table-cell" id="tsd-search" data-base=".."><div class="field"><label for="tsd-search-field" class="tsd-widget tsd-toolbar-icon search no-caption"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-search"></use></svg></label><input type="text" id="tsd-search-field" aria-label="Search"/></div><div class="field"><div id="tsd-toolbar-links"></div></div><ul class="results"><li class="state loading">Preparing search index...</li><li class="state failure">The search index is not available</li></ul><a href="../index.html" class="title">jsonpath-plus</a></div><div class="table-cell" id="tsd-widgets"><a href="#" class="tsd-widget tsd-toolbar-icon menu no-caption" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-menu"></use></svg></a></div></div></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><ul class="tsd-breadcrumb"><li><a href="../modules.html">jsonpath-plus</a></li><li><a href="JSONPath.html">JSONPath</a></li></ul><h1>Function JSONPath</h1></div><section class="tsd-panel"><ul class="tsd-signatures"><li class="tsd-signature tsd-anchor-link"><a id="JSONPath" class="tsd-anchor"></a><span class="tsd-kind-call-signature">JSONPath</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="JSONPath.html#JSONPath.T">T</a><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">options</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="../classes/JSONPathClass.html" class="tsd-signature-type tsd-kind-class">JSONPathClass</a><a href="#JSONPath" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><section class="tsd-panel"><h4>Type Parameters</h4><ul class="tsd-type-parameter-list"><li><span><a id="JSONPath.T" class="tsd-anchor"></a><span class="tsd-kind-type-parameter">T</span> = <span class="tsd-signature-type">any</span></span></li></ul></section><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">options</span>: <a href="../interfaces/JSONPathOptionsAutoStart.html" class="tsd-signature-type tsd-kind-interface">JSONPathOptionsAutoStart</a></span></li></ul></div><h4 class="tsd-returns-title">Returns <a href="../classes/JSONPathClass.html" class="tsd-signature-type tsd-kind-class">JSONPathClass</a></h4><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/a119240a17591a50176ef162e77d4305ebda73bd/src/jsonpath.d.ts#L225">jsonpath.d.ts:225</a></li></ul></aside></li><li class="tsd-signature tsd-anchor-link"><a id="JSONPath-1" class="tsd-anchor"></a><span class="tsd-kind-call-signature">JSONPath</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="JSONPath.html#JSONPath-1.T-1">T</a><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">options</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a class="tsd-signature-type tsd-kind-type-parameter" href="../interfaces/JSONPathCallable.html#JSONPathCallable-1.T-1">T</a><a href="#JSONPath-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><section class="tsd-panel"><h4>Type Parameters</h4><ul class="tsd-type-parameter-list"><li><span><a id="JSONPath-1.T-1" class="tsd-anchor"></a><span class="tsd-kind-type-parameter">T</span> = <span class="tsd-signature-type">any</span></span></li></ul></section><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">options</span>: <a href="../interfaces/JSONPathOptions.html" class="tsd-signature-type tsd-kind-interface">JSONPathOptions</a></span></li></ul></div><h4 class="tsd-returns-title">Returns <a class="tsd-signature-type tsd-kind-type-parameter" href="../interfaces/JSONPathCallable.html#JSONPathCallable-1.T-1">T</a></h4><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/a119240a17591a50176ef162e77d4305ebda73bd/src/jsonpath.d.ts#L225">jsonpath.d.ts:225</a></li></ul></aside></li><li class="tsd-signature tsd-anchor-link"><a id="JSONPath-2" class="tsd-anchor"></a><span class="tsd-kind-call-signature">JSONPath</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="JSONPath.html#JSONPath-2.T-2">T</a><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">path</span>, <span class="tsd-kind-parameter">json</span>, <span class="tsd-kind-parameter">callback</span>, <span class="tsd-kind-parameter">otherTypeCallback</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a class="tsd-signature-type tsd-kind-type-parameter" href="../interfaces/JSONPathCallable.html#JSONPathCallable-2.T-2">T</a><a href="#JSONPath-2" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><section class="tsd-panel"><h4>Type Parameters</h4><ul class="tsd-type-parameter-list"><li><span><a id="JSONPath-2.T-2" class="tsd-anchor"></a><span class="tsd-kind-type-parameter">T</span> = <span class="tsd-signature-type">any</span></span></li></ul></section><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">path</span>: <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">[]</span></span></li><li><span><span class="tsd-kind-parameter">json</span>: <br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">string</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">number</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">boolean</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">object</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">[]</span></span></li><li><span><span class="tsd-kind-parameter">callback</span>: <a href="../types/JSONPathCallback.html" class="tsd-signature-type tsd-kind-type-alias">JSONPathCallback</a></span></li><li><span><span class="tsd-kind-parameter">otherTypeCallback</span>: <a href="../types/JSONPathOtherTypeCallback.html" class="tsd-signature-type tsd-kind-type-alias">JSONPathOtherTypeCallback</a></span></li></ul></div><h4 class="tsd-returns-title">Returns <a class="tsd-signature-type tsd-kind-type-parameter" href="../interfaces/JSONPathCallable.html#JSONPathCallable-2.T-2">T</a></h4><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/a119240a17591a50176ef162e77d4305ebda73bd/src/jsonpath.d.ts#L225">jsonpath.d.ts:225</a></li></ul></aside></li></ul></section><section class="tsd-panel-group tsd-index-group"><section class="tsd-panel tsd-index-panel"><details class="tsd-index-content tsd-accordion" open><summary class="tsd-accordion-summary tsd-index-summary"><h5 class="tsd-index-heading uppercase" role="button" aria-expanded="false" tabIndex="0"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-chevronSmall"></use></svg> Index</h5></summary><div class="tsd-accordion-details"><section class="tsd-index-section"><h3 class="tsd-index-heading">Properties</h3><div class="tsd-index-list"><a href="JSONPath.html#cache" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1024"></use></svg><span>cache</span></a> +<!DOCTYPE html><html class="default" lang="en"><head><meta charset="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>JSONPath | jsonpath-plus</title><meta name="description" content="Documentation for jsonpath-plus"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script defer src="../assets/main.js"></script><script async src="../assets/icons.js" id="tsd-icons-script"></script><script async src="../assets/search.js" id="tsd-search-script"></script><script async src="../assets/navigation.js" id="tsd-nav-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><div class="table-cell" id="tsd-search" data-base=".."><div class="field"><label for="tsd-search-field" class="tsd-widget tsd-toolbar-icon search no-caption"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-search"></use></svg></label><input type="text" id="tsd-search-field" aria-label="Search"/></div><div class="field"><div id="tsd-toolbar-links"></div></div><ul class="results"><li class="state loading">Preparing search index...</li><li class="state failure">The search index is not available</li></ul><a href="../index.html" class="title">jsonpath-plus</a></div><div class="table-cell" id="tsd-widgets"><a href="#" class="tsd-widget tsd-toolbar-icon menu no-caption" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-menu"></use></svg></a></div></div></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><ul class="tsd-breadcrumb"><li><a href="../modules.html">jsonpath-plus</a></li><li><a href="JSONPath.html">JSONPath</a></li></ul><h1>Function JSONPath</h1></div><section class="tsd-panel"><ul class="tsd-signatures"><li class="tsd-signature tsd-anchor-link"><a id="JSONPath" class="tsd-anchor"></a><span class="tsd-kind-call-signature">JSONPath</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="JSONPath.html#JSONPath.T">T</a><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">options</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="../classes/JSONPathClass.html" class="tsd-signature-type tsd-kind-class">JSONPathClass</a><a href="#JSONPath" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><section class="tsd-panel"><h4>Type Parameters</h4><ul class="tsd-type-parameter-list"><li><span><a id="JSONPath.T" class="tsd-anchor"></a><span class="tsd-kind-type-parameter">T</span> = <span class="tsd-signature-type">any</span></span></li></ul></section><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">options</span>: <a href="../interfaces/JSONPathOptionsAutoStart.html" class="tsd-signature-type tsd-kind-interface">JSONPathOptionsAutoStart</a></span></li></ul></div><h4 class="tsd-returns-title">Returns <a href="../classes/JSONPathClass.html" class="tsd-signature-type tsd-kind-class">JSONPathClass</a></h4><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/39ee1844c610f9fd8925d3095ed3971e3d48025e/src/jsonpath.d.ts#L225">jsonpath.d.ts:225</a></li></ul></aside></li><li class="tsd-signature tsd-anchor-link"><a id="JSONPath-1" class="tsd-anchor"></a><span class="tsd-kind-call-signature">JSONPath</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="JSONPath.html#JSONPath-1.T-1">T</a><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">options</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a class="tsd-signature-type tsd-kind-type-parameter" href="../interfaces/JSONPathCallable.html#JSONPathCallable-1.T-1">T</a><a href="#JSONPath-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><section class="tsd-panel"><h4>Type Parameters</h4><ul class="tsd-type-parameter-list"><li><span><a id="JSONPath-1.T-1" class="tsd-anchor"></a><span class="tsd-kind-type-parameter">T</span> = <span class="tsd-signature-type">any</span></span></li></ul></section><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">options</span>: <a href="../interfaces/JSONPathOptions.html" class="tsd-signature-type tsd-kind-interface">JSONPathOptions</a></span></li></ul></div><h4 class="tsd-returns-title">Returns <a class="tsd-signature-type tsd-kind-type-parameter" href="../interfaces/JSONPathCallable.html#JSONPathCallable-1.T-1">T</a></h4><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/39ee1844c610f9fd8925d3095ed3971e3d48025e/src/jsonpath.d.ts#L225">jsonpath.d.ts:225</a></li></ul></aside></li><li class="tsd-signature tsd-anchor-link"><a id="JSONPath-2" class="tsd-anchor"></a><span class="tsd-kind-call-signature">JSONPath</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="JSONPath.html#JSONPath-2.T-2">T</a><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">path</span>, <span class="tsd-kind-parameter">json</span>, <span class="tsd-kind-parameter">callback</span>, <span class="tsd-kind-parameter">otherTypeCallback</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a class="tsd-signature-type tsd-kind-type-parameter" href="../interfaces/JSONPathCallable.html#JSONPathCallable-2.T-2">T</a><a href="#JSONPath-2" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><section class="tsd-panel"><h4>Type Parameters</h4><ul class="tsd-type-parameter-list"><li><span><a id="JSONPath-2.T-2" class="tsd-anchor"></a><span class="tsd-kind-type-parameter">T</span> = <span class="tsd-signature-type">any</span></span></li></ul></section><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">path</span>: <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">[]</span></span></li><li><span><span class="tsd-kind-parameter">json</span>: <br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">string</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">number</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">boolean</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">object</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">[]</span></span></li><li><span><span class="tsd-kind-parameter">callback</span>: <a href="../types/JSONPathCallback.html" class="tsd-signature-type tsd-kind-type-alias">JSONPathCallback</a></span></li><li><span><span class="tsd-kind-parameter">otherTypeCallback</span>: <a href="../types/JSONPathOtherTypeCallback.html" class="tsd-signature-type tsd-kind-type-alias">JSONPathOtherTypeCallback</a></span></li></ul></div><h4 class="tsd-returns-title">Returns <a class="tsd-signature-type tsd-kind-type-parameter" href="../interfaces/JSONPathCallable.html#JSONPathCallable-2.T-2">T</a></h4><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/39ee1844c610f9fd8925d3095ed3971e3d48025e/src/jsonpath.d.ts#L225">jsonpath.d.ts:225</a></li></ul></aside></li></ul></section><section class="tsd-panel-group tsd-index-group"><section class="tsd-panel tsd-index-panel"><details class="tsd-index-content tsd-accordion" open><summary class="tsd-accordion-summary tsd-index-summary"><h5 class="tsd-index-heading uppercase" role="button" aria-expanded="false" tabIndex="0"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-chevronSmall"></use></svg> Index</h5></summary><div class="tsd-accordion-details"><section class="tsd-index-section"><h3 class="tsd-index-heading">Properties</h3><div class="tsd-index-list"><a href="JSONPath.html#cache" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1024"></use></svg><span>cache</span></a> </div></section><section class="tsd-index-section"><h3 class="tsd-index-heading">Methods</h3><div class="tsd-index-list"><a href="JSONPath.html#evaluate" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-2048"></use></svg><span>evaluate</span></a> <a href="JSONPath.html#toPathArray" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-2048"></use></svg><span>to<wbr/>Path<wbr/>Array</span></a> <a href="JSONPath.html#toPathString" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-2048"></use></svg><span>to<wbr/>Path<wbr/>String</span></a> <a href="JSONPath.html#toPointer" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-2048"></use></svg><span>to<wbr/>Pointer</span></a> </div></section></div></details></section></section><details class="tsd-panel-group tsd-member-group tsd-accordion" open><summary class="tsd-accordion-summary" data-key="section-Properties"><h2><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg> Properties</h2></summary><section><section class="tsd-panel tsd-member"><a id="cache" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span>cache</span><a href="#cache" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><div class="tsd-signature"><span class="tsd-kind-property">cache</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">any</span></div><div class="tsd-comment tsd-typography"><p>Exposes the cache object for those who wish to preserve and reuse it for optimization purposes.</p> -</div><div class="tsd-comment tsd-typography"></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/a119240a17591a50176ef162e77d4305ebda73bd/src/jsonpath.d.ts#L179">jsonpath.d.ts:179</a></li></ul></aside></section></section></details><details class="tsd-panel-group tsd-member-group tsd-accordion" open><summary class="tsd-accordion-summary" data-key="section-Methods"><h2><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg> Methods</h2></summary><section><section class="tsd-panel tsd-member"><a id="evaluate" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span>evaluate</span><a href="#evaluate" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class="tsd-signature tsd-anchor-link"><a id="evaluate.evaluate-1" class="tsd-anchor"></a><span class="tsd-kind-call-signature">evaluate</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">path</span>, <span class="tsd-kind-parameter">json</span>, <span class="tsd-kind-parameter">callback</span>, <span class="tsd-kind-parameter">otherTypeCallback</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">any</span><a href="#evaluate.evaluate-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">path</span>: <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">[]</span></span></li><li><span><span class="tsd-kind-parameter">json</span>: <br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">string</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">number</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">boolean</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">object</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">[]</span></span></li><li><span><span class="tsd-kind-parameter">callback</span>: <a href="../types/JSONPathCallback.html" class="tsd-signature-type tsd-kind-type-alias">JSONPathCallback</a></span></li><li><span><span class="tsd-kind-parameter">otherTypeCallback</span>: <a href="../types/JSONPathOtherTypeCallback.html" class="tsd-signature-type tsd-kind-type-alias">JSONPathOtherTypeCallback</a></span></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">any</span></h4><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/a119240a17591a50176ef162e77d4305ebda73bd/src/jsonpath.d.ts#L209">jsonpath.d.ts:209</a></li></ul></aside></li><li class="tsd-signature tsd-anchor-link"><a id="evaluate.evaluate-2" class="tsd-anchor"></a><span class="tsd-kind-call-signature">evaluate</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">options</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">any</span><a href="#evaluate.evaluate-2" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">options</span>: <span class="tsd-signature-symbol">{ </span><br/><span> </span><span class="tsd-kind-property">callback</span><span class="tsd-signature-symbol">: </span><a href="../types/JSONPathCallback.html" class="tsd-signature-type tsd-kind-type-alias">JSONPathCallback</a><span class="tsd-signature-symbol">; </span><br/><span> </span><span class="tsd-kind-property">json</span><span class="tsd-signature-symbol">: </span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">string</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">number</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">boolean</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">object</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">; </span><br/><span> </span><span class="tsd-kind-property">otherTypeCallback</span><span class="tsd-signature-symbol">: </span><a href="../types/JSONPathOtherTypeCallback.html" class="tsd-signature-type tsd-kind-type-alias">JSONPathOtherTypeCallback</a><span class="tsd-signature-symbol">; </span><br/><span> </span><span class="tsd-kind-property">path</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">; </span><br/><span class="tsd-signature-symbol">}</span></span><ul class="tsd-parameters"><li class="tsd-parameter"><h5><span class="tsd-kind-property">callback</span><span class="tsd-signature-symbol">: </span><a href="../types/JSONPathCallback.html" class="tsd-signature-type tsd-kind-type-alias">JSONPathCallback</a></h5></li><li class="tsd-parameter"><h5><span class="tsd-kind-property">json</span><span class="tsd-signature-symbol">: </span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">string</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">number</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">boolean</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">object</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">[]</span></h5></li><li class="tsd-parameter"><h5><span class="tsd-kind-property">other<wbr/>Type<wbr/>Callback</span><span class="tsd-signature-symbol">: </span><a href="../types/JSONPathOtherTypeCallback.html" class="tsd-signature-type tsd-kind-type-alias">JSONPathOtherTypeCallback</a></h5></li><li class="tsd-parameter"><h5><span class="tsd-kind-property">path</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">[]</span></h5></li></ul></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">any</span></h4><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/a119240a17591a50176ef162e77d4305ebda73bd/src/jsonpath.d.ts#L215">jsonpath.d.ts:215</a></li></ul></aside></li></ul></section><section class="tsd-panel tsd-member"><a id="toPathArray" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span>to<wbr/>Path<wbr/>Array</span><a href="#toPathArray" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class="tsd-signature tsd-anchor-link"><a id="toPathArray.toPathArray-1" class="tsd-anchor"></a><span class="tsd-kind-call-signature">to<wbr/>Path<wbr/>Array</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">path</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">[]</span><a href="#toPathArray.toPathArray-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><div class="tsd-comment tsd-typography"><p>Accepts a normalized or unnormalized path as string and +</div><div class="tsd-comment tsd-typography"></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/39ee1844c610f9fd8925d3095ed3971e3d48025e/src/jsonpath.d.ts#L179">jsonpath.d.ts:179</a></li></ul></aside></section></section></details><details class="tsd-panel-group tsd-member-group tsd-accordion" open><summary class="tsd-accordion-summary" data-key="section-Methods"><h2><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg> Methods</h2></summary><section><section class="tsd-panel tsd-member"><a id="evaluate" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span>evaluate</span><a href="#evaluate" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class="tsd-signature tsd-anchor-link"><a id="evaluate.evaluate-1" class="tsd-anchor"></a><span class="tsd-kind-call-signature">evaluate</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">path</span>, <span class="tsd-kind-parameter">json</span>, <span class="tsd-kind-parameter">callback</span>, <span class="tsd-kind-parameter">otherTypeCallback</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">any</span><a href="#evaluate.evaluate-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">path</span>: <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">[]</span></span></li><li><span><span class="tsd-kind-parameter">json</span>: <br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">string</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">number</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">boolean</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">object</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">[]</span></span></li><li><span><span class="tsd-kind-parameter">callback</span>: <a href="../types/JSONPathCallback.html" class="tsd-signature-type tsd-kind-type-alias">JSONPathCallback</a></span></li><li><span><span class="tsd-kind-parameter">otherTypeCallback</span>: <a href="../types/JSONPathOtherTypeCallback.html" class="tsd-signature-type tsd-kind-type-alias">JSONPathOtherTypeCallback</a></span></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">any</span></h4><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/39ee1844c610f9fd8925d3095ed3971e3d48025e/src/jsonpath.d.ts#L209">jsonpath.d.ts:209</a></li></ul></aside></li><li class="tsd-signature tsd-anchor-link"><a id="evaluate.evaluate-2" class="tsd-anchor"></a><span class="tsd-kind-call-signature">evaluate</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">options</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">any</span><a href="#evaluate.evaluate-2" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">options</span>: <span class="tsd-signature-symbol">{ </span><br/><span> </span><span class="tsd-kind-property">callback</span><span class="tsd-signature-symbol">: </span><a href="../types/JSONPathCallback.html" class="tsd-signature-type tsd-kind-type-alias">JSONPathCallback</a><span class="tsd-signature-symbol">; </span><br/><span> </span><span class="tsd-kind-property">json</span><span class="tsd-signature-symbol">: </span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">string</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">number</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">boolean</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">object</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">; </span><br/><span> </span><span class="tsd-kind-property">otherTypeCallback</span><span class="tsd-signature-symbol">: </span><a href="../types/JSONPathOtherTypeCallback.html" class="tsd-signature-type tsd-kind-type-alias">JSONPathOtherTypeCallback</a><span class="tsd-signature-symbol">; </span><br/><span> </span><span class="tsd-kind-property">path</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">; </span><br/><span class="tsd-signature-symbol">}</span></span><ul class="tsd-parameters"><li class="tsd-parameter"><h5><span class="tsd-kind-property">callback</span><span class="tsd-signature-symbol">: </span><a href="../types/JSONPathCallback.html" class="tsd-signature-type tsd-kind-type-alias">JSONPathCallback</a></h5></li><li class="tsd-parameter"><h5><span class="tsd-kind-property">json</span><span class="tsd-signature-symbol">: </span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">string</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">number</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">boolean</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">object</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">[]</span></h5></li><li class="tsd-parameter"><h5><span class="tsd-kind-property">other<wbr/>Type<wbr/>Callback</span><span class="tsd-signature-symbol">: </span><a href="../types/JSONPathOtherTypeCallback.html" class="tsd-signature-type tsd-kind-type-alias">JSONPathOtherTypeCallback</a></h5></li><li class="tsd-parameter"><h5><span class="tsd-kind-property">path</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">[]</span></h5></li></ul></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">any</span></h4><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/39ee1844c610f9fd8925d3095ed3971e3d48025e/src/jsonpath.d.ts#L215">jsonpath.d.ts:215</a></li></ul></aside></li></ul></section><section class="tsd-panel tsd-member"><a id="toPathArray" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span>to<wbr/>Path<wbr/>Array</span><a href="#toPathArray" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class="tsd-signature tsd-anchor-link"><a id="toPathArray.toPathArray-1" class="tsd-anchor"></a><span class="tsd-kind-call-signature">to<wbr/>Path<wbr/>Array</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">path</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">[]</span><a href="#toPathArray.toPathArray-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><div class="tsd-comment tsd-typography"><p>Accepts a normalized or unnormalized path as string and converts to an array: for example, <code>['$', 'aProperty', 'anotherProperty']</code>.</p> -</div><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">path</span>: <span class="tsd-signature-type">string</span></span></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">[]</span></h4><div class="tsd-comment tsd-typography"></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/a119240a17591a50176ef162e77d4305ebda73bd/src/jsonpath.d.ts#L186">jsonpath.d.ts:186</a></li></ul></aside></li></ul></section><section class="tsd-panel tsd-member"><a id="toPathString" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span>to<wbr/>Path<wbr/>String</span><a href="#toPathString" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class="tsd-signature tsd-anchor-link"><a id="toPathString.toPathString-1" class="tsd-anchor"></a><span class="tsd-kind-call-signature">to<wbr/>Path<wbr/>String</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">path</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><a href="#toPathString.toPathString-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><div class="tsd-comment tsd-typography"><p>Accepts a path array and converts to a normalized path string. +</div><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">path</span>: <span class="tsd-signature-type">string</span></span></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">[]</span></h4><div class="tsd-comment tsd-typography"></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/39ee1844c610f9fd8925d3095ed3971e3d48025e/src/jsonpath.d.ts#L186">jsonpath.d.ts:186</a></li></ul></aside></li></ul></section><section class="tsd-panel tsd-member"><a id="toPathString" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span>to<wbr/>Path<wbr/>String</span><a href="#toPathString" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class="tsd-signature tsd-anchor-link"><a id="toPathString.toPathString-1" class="tsd-anchor"></a><span class="tsd-kind-call-signature">to<wbr/>Path<wbr/>String</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">path</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><a href="#toPathString.toPathString-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><div class="tsd-comment tsd-typography"><p>Accepts a path array and converts to a normalized path string. The string will be in a form like: <code>$['aProperty']['anotherProperty][0]</code>. The JSONPath terminal constructions <code>~</code> and <code>^</code> and type operators like <code>@string()</code> are silently stripped.</p> -</div><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">path</span>: <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">[]</span></span></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">string</span></h4><div class="tsd-comment tsd-typography"></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/a119240a17591a50176ef162e77d4305ebda73bd/src/jsonpath.d.ts#L195">jsonpath.d.ts:195</a></li></ul></aside></li></ul></section><section class="tsd-panel tsd-member"><a id="toPointer" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span>to<wbr/>Pointer</span><a href="#toPointer" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class="tsd-signature tsd-anchor-link"><a id="toPointer.toPointer-1" class="tsd-anchor"></a><span class="tsd-kind-call-signature">to<wbr/>Pointer</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">path</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">any</span><a href="#toPointer.toPointer-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><div class="tsd-comment tsd-typography"><p>Accepts a path array and converts to a JSON Pointer.</p> +</div><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">path</span>: <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">[]</span></span></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">string</span></h4><div class="tsd-comment tsd-typography"></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/39ee1844c610f9fd8925d3095ed3971e3d48025e/src/jsonpath.d.ts#L195">jsonpath.d.ts:195</a></li></ul></aside></li></ul></section><section class="tsd-panel tsd-member"><a id="toPointer" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span>to<wbr/>Pointer</span><a href="#toPointer" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class="tsd-signature tsd-anchor-link"><a id="toPointer.toPointer-1" class="tsd-anchor"></a><span class="tsd-kind-call-signature">to<wbr/>Pointer</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">path</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">any</span><a href="#toPointer.toPointer-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><div class="tsd-comment tsd-typography"><p>Accepts a path array and converts to a JSON Pointer.</p> <p>The string will be in a form like: <code>/aProperty/anotherProperty/0</code> (with any <code>~</code> and <code>/</code> internal characters escaped as per the JSON Pointer spec).</p> <p>The JSONPath terminal constructions <code>~</code> and <code>^</code> and type operators like <code>@string()</code> are silently stripped.</p> -</div><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">path</span>: <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">[]</span></span></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">any</span></h4><div class="tsd-comment tsd-typography"></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/a119240a17591a50176ef162e77d4305ebda73bd/src/jsonpath.d.ts#L207">jsonpath.d.ts:207</a></li></ul></aside></li></ul></section></section></details></div><div class="col-sidebar"><div class="page-menu"><div class="tsd-navigation settings"><details class="tsd-accordion"><summary class="tsd-accordion-summary"><h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Settings</h3></summary><div class="tsd-accordion-details"><div class="tsd-filter-visibility"><span class="settings-label">Member Visibility</span><ul id="tsd-filter-options"><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-protected" name="protected"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Protected</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-inherited" name="inherited" checked/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Inherited</span></label></li></ul></div><div class="tsd-theme-toggle"><label class="settings-label" for="tsd-theme">Theme</label><select id="tsd-theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div><details open class="tsd-accordion tsd-page-navigation"><summary class="tsd-accordion-summary"><h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>On This Page</h3></summary><div class="tsd-accordion-details"><details open class="tsd-accordion tsd-page-navigation-section"><summary class="tsd-accordion-summary" data-key="tsd-otp-Properties"><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Properties</summary><div><a href="#cache" class=""><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1024"></use></svg><span>cache</span></a></div></details><details open class="tsd-accordion tsd-page-navigation-section"><summary class="tsd-accordion-summary" data-key="tsd-otp-Methods"><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Methods</summary><div><a href="#evaluate" class=""><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-2048"></use></svg><span>evaluate</span></a><a href="#toPathArray" class=""><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-2048"></use></svg><span>to<wbr/>Path<wbr/>Array</span></a><a href="#toPathString" class=""><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-2048"></use></svg><span>to<wbr/>Path<wbr/>String</span></a><a href="#toPointer" class=""><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-2048"></use></svg><span>to<wbr/>Pointer</span></a></div></details></div></details></div><div class="site-menu"><nav class="tsd-navigation"><a href="../modules.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1"></use></svg><span>jsonpath-plus</span></a><ul class="tsd-small-nested-navigation" id="tsd-nav-container" data-base=".."><li>Loading...</li></ul></nav></div></div></div><footer><p class="tsd-generator">Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></footer><div class="overlay"></div></body></html> +</div><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">path</span>: <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">[]</span></span></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">any</span></h4><div class="tsd-comment tsd-typography"></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/39ee1844c610f9fd8925d3095ed3971e3d48025e/src/jsonpath.d.ts#L207">jsonpath.d.ts:207</a></li></ul></aside></li></ul></section></section></details></div><div class="col-sidebar"><div class="page-menu"><div class="tsd-navigation settings"><details class="tsd-accordion"><summary class="tsd-accordion-summary"><h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Settings</h3></summary><div class="tsd-accordion-details"><div class="tsd-filter-visibility"><span class="settings-label">Member Visibility</span><ul id="tsd-filter-options"><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-protected" name="protected"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Protected</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-inherited" name="inherited" checked/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Inherited</span></label></li></ul></div><div class="tsd-theme-toggle"><label class="settings-label" for="tsd-theme">Theme</label><select id="tsd-theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div><details open class="tsd-accordion tsd-page-navigation"><summary class="tsd-accordion-summary"><h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>On This Page</h3></summary><div class="tsd-accordion-details"><details open class="tsd-accordion tsd-page-navigation-section"><summary class="tsd-accordion-summary" data-key="tsd-otp-Properties"><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Properties</summary><div><a href="#cache" class=""><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1024"></use></svg><span>cache</span></a></div></details><details open class="tsd-accordion tsd-page-navigation-section"><summary class="tsd-accordion-summary" data-key="tsd-otp-Methods"><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Methods</summary><div><a href="#evaluate" class=""><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-2048"></use></svg><span>evaluate</span></a><a href="#toPathArray" class=""><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-2048"></use></svg><span>to<wbr/>Path<wbr/>Array</span></a><a href="#toPathString" class=""><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-2048"></use></svg><span>to<wbr/>Path<wbr/>String</span></a><a href="#toPointer" class=""><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-2048"></use></svg><span>to<wbr/>Pointer</span></a></div></details></div></details></div><div class="site-menu"><nav class="tsd-navigation"><a href="../modules.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1"></use></svg><span>jsonpath-plus</span></a><ul class="tsd-small-nested-navigation" id="tsd-nav-container" data-base=".."><li>Loading...</li></ul></nav></div></div></div><footer><p class="tsd-generator">Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></footer><div class="overlay"></div></body></html>
docs/ts/interfaces/JSONPathCallable.html+1 −1 modified@@ -1 +1 @@ -<!DOCTYPE html><html class="default" lang="en"><head><meta charset="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>JSONPathCallable | jsonpath-plus</title><meta name="description" content="Documentation for jsonpath-plus"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script defer src="../assets/main.js"></script><script async src="../assets/icons.js" id="tsd-icons-script"></script><script async src="../assets/search.js" id="tsd-search-script"></script><script async src="../assets/navigation.js" id="tsd-nav-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><div class="table-cell" id="tsd-search" data-base=".."><div class="field"><label for="tsd-search-field" class="tsd-widget tsd-toolbar-icon search no-caption"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-search"></use></svg></label><input type="text" id="tsd-search-field" aria-label="Search"/></div><div class="field"><div id="tsd-toolbar-links"></div></div><ul class="results"><li class="state loading">Preparing search index...</li><li class="state failure">The search index is not available</li></ul><a href="../index.html" class="title">jsonpath-plus</a></div><div class="table-cell" id="tsd-widgets"><a href="#" class="tsd-widget tsd-toolbar-icon menu no-caption" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-menu"></use></svg></a></div></div></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><ul class="tsd-breadcrumb"><li><a href="../modules.html">jsonpath-plus</a></li><li><a href="JSONPathCallable.html">JSONPathCallable</a></li></ul><h1>Interface JSONPathCallable</h1></div><section class="tsd-panel"><ul class="tsd-signatures"><li class="tsd-signature tsd-anchor-link"><a id="JSONPathCallable" class="tsd-anchor"></a><span class="tsd-kind-call-signature">JSONPath<wbr/>Callable</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="JSONPathCallable.html#JSONPathCallable.T">T</a><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">options</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="../classes/JSONPathClass.html" class="tsd-signature-type tsd-kind-class">JSONPathClass</a><a href="#JSONPathCallable" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><section class="tsd-panel"><h4>Type Parameters</h4><ul class="tsd-type-parameter-list"><li><span><a id="JSONPathCallable.T" class="tsd-anchor"></a><span class="tsd-kind-type-parameter">T</span> = <span class="tsd-signature-type">any</span></span></li></ul></section><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">options</span>: <a href="JSONPathOptionsAutoStart.html" class="tsd-signature-type tsd-kind-interface">JSONPathOptionsAutoStart</a></span></li></ul></div><h4 class="tsd-returns-title">Returns <a href="../classes/JSONPathClass.html" class="tsd-signature-type tsd-kind-class">JSONPathClass</a></h4><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/a119240a17591a50176ef162e77d4305ebda73bd/src/jsonpath.d.ts#L163">jsonpath.d.ts:163</a></li></ul></aside></li><li class="tsd-signature tsd-anchor-link"><a id="JSONPathCallable-1" class="tsd-anchor"></a><span class="tsd-kind-call-signature">JSONPath<wbr/>Callable</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="JSONPathCallable.html#JSONPathCallable-1.T-1">T</a><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">options</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a class="tsd-signature-type tsd-kind-type-parameter" href="JSONPathCallable.html#JSONPathCallable-1.T-1">T</a><a href="#JSONPathCallable-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><section class="tsd-panel"><h4>Type Parameters</h4><ul class="tsd-type-parameter-list"><li><span><a id="JSONPathCallable-1.T-1" class="tsd-anchor"></a><span class="tsd-kind-type-parameter">T</span> = <span class="tsd-signature-type">any</span></span></li></ul></section><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">options</span>: <a href="JSONPathOptions.html" class="tsd-signature-type tsd-kind-interface">JSONPathOptions</a></span></li></ul></div><h4 class="tsd-returns-title">Returns <a class="tsd-signature-type tsd-kind-type-parameter" href="JSONPathCallable.html#JSONPathCallable-1.T-1">T</a></h4><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/a119240a17591a50176ef162e77d4305ebda73bd/src/jsonpath.d.ts#L164">jsonpath.d.ts:164</a></li></ul></aside></li><li class="tsd-signature tsd-anchor-link"><a id="JSONPathCallable-2" class="tsd-anchor"></a><span class="tsd-kind-call-signature">JSONPath<wbr/>Callable</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="JSONPathCallable.html#JSONPathCallable-2.T-2">T</a><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">path</span>, <span class="tsd-kind-parameter">json</span>, <span class="tsd-kind-parameter">callback</span>, <span class="tsd-kind-parameter">otherTypeCallback</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a class="tsd-signature-type tsd-kind-type-parameter" href="JSONPathCallable.html#JSONPathCallable-2.T-2">T</a><a href="#JSONPathCallable-2" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><section class="tsd-panel"><h4>Type Parameters</h4><ul class="tsd-type-parameter-list"><li><span><a id="JSONPathCallable-2.T-2" class="tsd-anchor"></a><span class="tsd-kind-type-parameter">T</span> = <span class="tsd-signature-type">any</span></span></li></ul></section><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">path</span>: <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">[]</span></span></li><li><span><span class="tsd-kind-parameter">json</span>: <br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">string</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">number</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">boolean</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">object</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">[]</span></span></li><li><span><span class="tsd-kind-parameter">callback</span>: <a href="../types/JSONPathCallback.html" class="tsd-signature-type tsd-kind-type-alias">JSONPathCallback</a></span></li><li><span><span class="tsd-kind-parameter">otherTypeCallback</span>: <a href="../types/JSONPathOtherTypeCallback.html" class="tsd-signature-type tsd-kind-type-alias">JSONPathOtherTypeCallback</a></span></li></ul></div><h4 class="tsd-returns-title">Returns <a class="tsd-signature-type tsd-kind-type-parameter" href="JSONPathCallable.html#JSONPathCallable-2.T-2">T</a></h4><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/a119240a17591a50176ef162e77d4305ebda73bd/src/jsonpath.d.ts#L166">jsonpath.d.ts:166</a></li></ul></aside></li></ul></section></div><div class="col-sidebar"><div class="page-menu"><div class="tsd-navigation settings"><details class="tsd-accordion"><summary class="tsd-accordion-summary"><h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Settings</h3></summary><div class="tsd-accordion-details"><div class="tsd-filter-visibility"><span class="settings-label">Member Visibility</span><ul id="tsd-filter-options"><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-protected" name="protected"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Protected</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-inherited" name="inherited" checked/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Inherited</span></label></li></ul></div><div class="tsd-theme-toggle"><label class="settings-label" for="tsd-theme">Theme</label><select id="tsd-theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div></div><div class="site-menu"><nav class="tsd-navigation"><a href="../modules.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1"></use></svg><span>jsonpath-plus</span></a><ul class="tsd-small-nested-navigation" id="tsd-nav-container" data-base=".."><li>Loading...</li></ul></nav></div></div></div><footer><p class="tsd-generator">Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></footer><div class="overlay"></div></body></html> +<!DOCTYPE html><html class="default" lang="en"><head><meta charset="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>JSONPathCallable | jsonpath-plus</title><meta name="description" content="Documentation for jsonpath-plus"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script defer src="../assets/main.js"></script><script async src="../assets/icons.js" id="tsd-icons-script"></script><script async src="../assets/search.js" id="tsd-search-script"></script><script async src="../assets/navigation.js" id="tsd-nav-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><div class="table-cell" id="tsd-search" data-base=".."><div class="field"><label for="tsd-search-field" class="tsd-widget tsd-toolbar-icon search no-caption"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-search"></use></svg></label><input type="text" id="tsd-search-field" aria-label="Search"/></div><div class="field"><div id="tsd-toolbar-links"></div></div><ul class="results"><li class="state loading">Preparing search index...</li><li class="state failure">The search index is not available</li></ul><a href="../index.html" class="title">jsonpath-plus</a></div><div class="table-cell" id="tsd-widgets"><a href="#" class="tsd-widget tsd-toolbar-icon menu no-caption" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-menu"></use></svg></a></div></div></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><ul class="tsd-breadcrumb"><li><a href="../modules.html">jsonpath-plus</a></li><li><a href="JSONPathCallable.html">JSONPathCallable</a></li></ul><h1>Interface JSONPathCallable</h1></div><section class="tsd-panel"><ul class="tsd-signatures"><li class="tsd-signature tsd-anchor-link"><a id="JSONPathCallable" class="tsd-anchor"></a><span class="tsd-kind-call-signature">JSONPath<wbr/>Callable</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="JSONPathCallable.html#JSONPathCallable.T">T</a><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">options</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="../classes/JSONPathClass.html" class="tsd-signature-type tsd-kind-class">JSONPathClass</a><a href="#JSONPathCallable" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><section class="tsd-panel"><h4>Type Parameters</h4><ul class="tsd-type-parameter-list"><li><span><a id="JSONPathCallable.T" class="tsd-anchor"></a><span class="tsd-kind-type-parameter">T</span> = <span class="tsd-signature-type">any</span></span></li></ul></section><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">options</span>: <a href="JSONPathOptionsAutoStart.html" class="tsd-signature-type tsd-kind-interface">JSONPathOptionsAutoStart</a></span></li></ul></div><h4 class="tsd-returns-title">Returns <a href="../classes/JSONPathClass.html" class="tsd-signature-type tsd-kind-class">JSONPathClass</a></h4><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/39ee1844c610f9fd8925d3095ed3971e3d48025e/src/jsonpath.d.ts#L163">jsonpath.d.ts:163</a></li></ul></aside></li><li class="tsd-signature tsd-anchor-link"><a id="JSONPathCallable-1" class="tsd-anchor"></a><span class="tsd-kind-call-signature">JSONPath<wbr/>Callable</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="JSONPathCallable.html#JSONPathCallable-1.T-1">T</a><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">options</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a class="tsd-signature-type tsd-kind-type-parameter" href="JSONPathCallable.html#JSONPathCallable-1.T-1">T</a><a href="#JSONPathCallable-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><section class="tsd-panel"><h4>Type Parameters</h4><ul class="tsd-type-parameter-list"><li><span><a id="JSONPathCallable-1.T-1" class="tsd-anchor"></a><span class="tsd-kind-type-parameter">T</span> = <span class="tsd-signature-type">any</span></span></li></ul></section><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">options</span>: <a href="JSONPathOptions.html" class="tsd-signature-type tsd-kind-interface">JSONPathOptions</a></span></li></ul></div><h4 class="tsd-returns-title">Returns <a class="tsd-signature-type tsd-kind-type-parameter" href="JSONPathCallable.html#JSONPathCallable-1.T-1">T</a></h4><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/39ee1844c610f9fd8925d3095ed3971e3d48025e/src/jsonpath.d.ts#L164">jsonpath.d.ts:164</a></li></ul></aside></li><li class="tsd-signature tsd-anchor-link"><a id="JSONPathCallable-2" class="tsd-anchor"></a><span class="tsd-kind-call-signature">JSONPath<wbr/>Callable</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="JSONPathCallable.html#JSONPathCallable-2.T-2">T</a><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">path</span>, <span class="tsd-kind-parameter">json</span>, <span class="tsd-kind-parameter">callback</span>, <span class="tsd-kind-parameter">otherTypeCallback</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a class="tsd-signature-type tsd-kind-type-parameter" href="JSONPathCallable.html#JSONPathCallable-2.T-2">T</a><a href="#JSONPathCallable-2" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><section class="tsd-panel"><h4>Type Parameters</h4><ul class="tsd-type-parameter-list"><li><span><a id="JSONPathCallable-2.T-2" class="tsd-anchor"></a><span class="tsd-kind-type-parameter">T</span> = <span class="tsd-signature-type">any</span></span></li></ul></section><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">path</span>: <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">[]</span></span></li><li><span><span class="tsd-kind-parameter">json</span>: <br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">string</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">number</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">boolean</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">object</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">[]</span></span></li><li><span><span class="tsd-kind-parameter">callback</span>: <a href="../types/JSONPathCallback.html" class="tsd-signature-type tsd-kind-type-alias">JSONPathCallback</a></span></li><li><span><span class="tsd-kind-parameter">otherTypeCallback</span>: <a href="../types/JSONPathOtherTypeCallback.html" class="tsd-signature-type tsd-kind-type-alias">JSONPathOtherTypeCallback</a></span></li></ul></div><h4 class="tsd-returns-title">Returns <a class="tsd-signature-type tsd-kind-type-parameter" href="JSONPathCallable.html#JSONPathCallable-2.T-2">T</a></h4><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/39ee1844c610f9fd8925d3095ed3971e3d48025e/src/jsonpath.d.ts#L166">jsonpath.d.ts:166</a></li></ul></aside></li></ul></section></div><div class="col-sidebar"><div class="page-menu"><div class="tsd-navigation settings"><details class="tsd-accordion"><summary class="tsd-accordion-summary"><h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Settings</h3></summary><div class="tsd-accordion-details"><div class="tsd-filter-visibility"><span class="settings-label">Member Visibility</span><ul id="tsd-filter-options"><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-protected" name="protected"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Protected</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-inherited" name="inherited" checked/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Inherited</span></label></li></ul></div><div class="tsd-theme-toggle"><label class="settings-label" for="tsd-theme">Theme</label><select id="tsd-theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div></div><div class="site-menu"><nav class="tsd-navigation"><a href="../modules.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1"></use></svg><span>jsonpath-plus</span></a><ul class="tsd-small-nested-navigation" id="tsd-nav-container" data-base=".."><li>Loading...</li></ul></nav></div></div></div><footer><p class="tsd-generator">Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></footer><div class="overlay"></div></body></html>
docs/ts/interfaces/JSONPathOptionsAutoStart.html+14 −14 modified@@ -1,4 +1,4 @@ -<!DOCTYPE html><html class="default" lang="en"><head><meta charset="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>JSONPathOptionsAutoStart | jsonpath-plus</title><meta name="description" content="Documentation for jsonpath-plus"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script defer src="../assets/main.js"></script><script async src="../assets/icons.js" id="tsd-icons-script"></script><script async src="../assets/search.js" id="tsd-search-script"></script><script async src="../assets/navigation.js" id="tsd-nav-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><div class="table-cell" id="tsd-search" data-base=".."><div class="field"><label for="tsd-search-field" class="tsd-widget tsd-toolbar-icon search no-caption"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-search"></use></svg></label><input type="text" id="tsd-search-field" aria-label="Search"/></div><div class="field"><div id="tsd-toolbar-links"></div></div><ul class="results"><li class="state loading">Preparing search index...</li><li class="state failure">The search index is not available</li></ul><a href="../index.html" class="title">jsonpath-plus</a></div><div class="table-cell" id="tsd-widgets"><a href="#" class="tsd-widget tsd-toolbar-icon menu no-caption" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-menu"></use></svg></a></div></div></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><ul class="tsd-breadcrumb"><li><a href="../modules.html">jsonpath-plus</a></li><li><a href="JSONPathOptionsAutoStart.html">JSONPathOptionsAutoStart</a></li></ul><h1>Interface JSONPathOptionsAutoStart</h1></div><div class="tsd-signature"><span class="tsd-signature-keyword">interface </span><span class="tsd-kind-interface">JSONPathOptionsAutoStart</span> <span class="tsd-signature-symbol">{ </span><br/><span> </span><a class="tsd-kind-property" href="JSONPathOptionsAutoStart.html#autostart">autostart</a><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">false</span><span class="tsd-signature-symbol">; </span><br/><span> </span><a class="tsd-kind-property" href="JSONPathOptionsAutoStart.html#callback">callback</a><span class="tsd-signature-symbol">?: </span><a href="../types/JSONPathCallback.html" class="tsd-signature-type tsd-kind-type-alias">JSONPathCallback</a><span class="tsd-signature-symbol">; </span><br/><span> </span><a class="tsd-kind-property" href="JSONPathOptionsAutoStart.html#eval">eval</a><span class="tsd-signature-symbol">?: </span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">boolean</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-keyword">typeof </span><a href="../classes/EvalClass.html" class="tsd-signature-type tsd-kind-class">EvalClass</a><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">"safe"</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">"native"</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">code</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span>, <span class="tsd-kind-parameter">context</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">object</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol"> => </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">; </span><br/><span> </span><a class="tsd-kind-property" href="JSONPathOptionsAutoStart.html#flatten">flatten</a><span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">boolean</span><span class="tsd-signature-symbol">; </span><br/><span> </span><a class="tsd-kind-property" href="JSONPathOptionsAutoStart.html#ignoreEvalErrors">ignoreEvalErrors</a><span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">boolean</span><span class="tsd-signature-symbol">; </span><br/><span> </span><a class="tsd-kind-property" href="JSONPathOptionsAutoStart.html#json">json</a><span class="tsd-signature-symbol">: </span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">string</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">number</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">boolean</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">object</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">; </span><br/><span> </span><a class="tsd-kind-property" href="JSONPathOptionsAutoStart.html#otherTypeCallback">otherTypeCallback</a><span class="tsd-signature-symbol">?: </span><a href="../types/JSONPathOtherTypeCallback.html" class="tsd-signature-type tsd-kind-type-alias">JSONPathOtherTypeCallback</a><span class="tsd-signature-symbol">; </span><br/><span> </span><a class="tsd-kind-property" href="JSONPathOptionsAutoStart.html#parent">parent</a><span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">; </span><br/><span> </span><a class="tsd-kind-property" href="JSONPathOptionsAutoStart.html#parentProperty">parentProperty</a><span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">; </span><br/><span> </span><a class="tsd-kind-property" href="JSONPathOptionsAutoStart.html#path">path</a><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">; </span><br/><span> </span><a class="tsd-kind-property" href="JSONPathOptionsAutoStart.html#resultType">resultType</a><span class="tsd-signature-symbol">?: </span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">"value"</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">"path"</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">"pointer"</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">"parent"</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">"parentProperty"</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">"all"</span><span class="tsd-signature-symbol">; </span><br/><span> </span><a class="tsd-kind-property" href="JSONPathOptionsAutoStart.html#sandbox">sandbox</a><span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">Map</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">; </span><br/><span> </span><a class="tsd-kind-property" href="JSONPathOptionsAutoStart.html#wrap">wrap</a><span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">boolean</span><span class="tsd-signature-symbol">; </span><br/><span class="tsd-signature-symbol">}</span></div><section class="tsd-panel tsd-hierarchy"><h4>Hierarchy (<a href="../hierarchy.html#JSONPathOptionsAutoStart">view full</a>)</h4><ul class="tsd-hierarchy"><li><a href="JSONPathOptions.html" class="tsd-signature-type tsd-kind-interface">JSONPathOptions</a><ul class="tsd-hierarchy"><li><span class="target">JSONPathOptionsAutoStart</span></li></ul></li></ul></section><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/a119240a17591a50176ef162e77d4305ebda73bd/src/jsonpath.d.ts#L158">jsonpath.d.ts:158</a></li></ul></aside><section class="tsd-panel-group tsd-index-group"><section class="tsd-panel tsd-index-panel"><details class="tsd-index-content tsd-accordion" open><summary class="tsd-accordion-summary tsd-index-summary"><h5 class="tsd-index-heading uppercase" role="button" aria-expanded="false" tabIndex="0"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-chevronSmall"></use></svg> Index</h5></summary><div class="tsd-accordion-details"><section class="tsd-index-section"><h3 class="tsd-index-heading">Properties</h3><div class="tsd-index-list"><a href="JSONPathOptionsAutoStart.html#autostart" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1024"></use></svg><span>autostart</span></a> +<!DOCTYPE html><html class="default" lang="en"><head><meta charset="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>JSONPathOptionsAutoStart | jsonpath-plus</title><meta name="description" content="Documentation for jsonpath-plus"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script defer src="../assets/main.js"></script><script async src="../assets/icons.js" id="tsd-icons-script"></script><script async src="../assets/search.js" id="tsd-search-script"></script><script async src="../assets/navigation.js" id="tsd-nav-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><div class="table-cell" id="tsd-search" data-base=".."><div class="field"><label for="tsd-search-field" class="tsd-widget tsd-toolbar-icon search no-caption"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-search"></use></svg></label><input type="text" id="tsd-search-field" aria-label="Search"/></div><div class="field"><div id="tsd-toolbar-links"></div></div><ul class="results"><li class="state loading">Preparing search index...</li><li class="state failure">The search index is not available</li></ul><a href="../index.html" class="title">jsonpath-plus</a></div><div class="table-cell" id="tsd-widgets"><a href="#" class="tsd-widget tsd-toolbar-icon menu no-caption" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-menu"></use></svg></a></div></div></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><ul class="tsd-breadcrumb"><li><a href="../modules.html">jsonpath-plus</a></li><li><a href="JSONPathOptionsAutoStart.html">JSONPathOptionsAutoStart</a></li></ul><h1>Interface JSONPathOptionsAutoStart</h1></div><div class="tsd-signature"><span class="tsd-signature-keyword">interface </span><span class="tsd-kind-interface">JSONPathOptionsAutoStart</span> <span class="tsd-signature-symbol">{ </span><br/><span> </span><a class="tsd-kind-property" href="JSONPathOptionsAutoStart.html#autostart">autostart</a><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">false</span><span class="tsd-signature-symbol">; </span><br/><span> </span><a class="tsd-kind-property" href="JSONPathOptionsAutoStart.html#callback">callback</a><span class="tsd-signature-symbol">?: </span><a href="../types/JSONPathCallback.html" class="tsd-signature-type tsd-kind-type-alias">JSONPathCallback</a><span class="tsd-signature-symbol">; </span><br/><span> </span><a class="tsd-kind-property" href="JSONPathOptionsAutoStart.html#eval">eval</a><span class="tsd-signature-symbol">?: </span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">boolean</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-keyword">typeof </span><a href="../classes/EvalClass.html" class="tsd-signature-type tsd-kind-class">EvalClass</a><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">"safe"</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">"native"</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">code</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span>, <span class="tsd-kind-parameter">context</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">object</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol"> => </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">; </span><br/><span> </span><a class="tsd-kind-property" href="JSONPathOptionsAutoStart.html#flatten">flatten</a><span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">boolean</span><span class="tsd-signature-symbol">; </span><br/><span> </span><a class="tsd-kind-property" href="JSONPathOptionsAutoStart.html#ignoreEvalErrors">ignoreEvalErrors</a><span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">boolean</span><span class="tsd-signature-symbol">; </span><br/><span> </span><a class="tsd-kind-property" href="JSONPathOptionsAutoStart.html#json">json</a><span class="tsd-signature-symbol">: </span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">string</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">number</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">boolean</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">object</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">; </span><br/><span> </span><a class="tsd-kind-property" href="JSONPathOptionsAutoStart.html#otherTypeCallback">otherTypeCallback</a><span class="tsd-signature-symbol">?: </span><a href="../types/JSONPathOtherTypeCallback.html" class="tsd-signature-type tsd-kind-type-alias">JSONPathOtherTypeCallback</a><span class="tsd-signature-symbol">; </span><br/><span> </span><a class="tsd-kind-property" href="JSONPathOptionsAutoStart.html#parent">parent</a><span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">; </span><br/><span> </span><a class="tsd-kind-property" href="JSONPathOptionsAutoStart.html#parentProperty">parentProperty</a><span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">; </span><br/><span> </span><a class="tsd-kind-property" href="JSONPathOptionsAutoStart.html#path">path</a><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">; </span><br/><span> </span><a class="tsd-kind-property" href="JSONPathOptionsAutoStart.html#resultType">resultType</a><span class="tsd-signature-symbol">?: </span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">"value"</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">"path"</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">"pointer"</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">"parent"</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">"parentProperty"</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">"all"</span><span class="tsd-signature-symbol">; </span><br/><span> </span><a class="tsd-kind-property" href="JSONPathOptionsAutoStart.html#sandbox">sandbox</a><span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">Map</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">; </span><br/><span> </span><a class="tsd-kind-property" href="JSONPathOptionsAutoStart.html#wrap">wrap</a><span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">boolean</span><span class="tsd-signature-symbol">; </span><br/><span class="tsd-signature-symbol">}</span></div><section class="tsd-panel tsd-hierarchy"><h4>Hierarchy (<a href="../hierarchy.html#JSONPathOptionsAutoStart">view full</a>)</h4><ul class="tsd-hierarchy"><li><a href="JSONPathOptions.html" class="tsd-signature-type tsd-kind-interface">JSONPathOptions</a><ul class="tsd-hierarchy"><li><span class="target">JSONPathOptionsAutoStart</span></li></ul></li></ul></section><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/39ee1844c610f9fd8925d3095ed3971e3d48025e/src/jsonpath.d.ts#L158">jsonpath.d.ts:158</a></li></ul></aside><section class="tsd-panel-group tsd-index-group"><section class="tsd-panel tsd-index-panel"><details class="tsd-index-content tsd-accordion" open><summary class="tsd-accordion-summary tsd-index-summary"><h5 class="tsd-index-heading uppercase" role="button" aria-expanded="false" tabIndex="0"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-chevronSmall"></use></svg> Index</h5></summary><div class="tsd-accordion-details"><section class="tsd-index-section"><h3 class="tsd-index-heading">Properties</h3><div class="tsd-index-list"><a href="JSONPathOptionsAutoStart.html#autostart" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1024"></use></svg><span>autostart</span></a> <a href="JSONPathOptionsAutoStart.html#callback" class="tsd-index-link tsd-is-inherited"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1024"></use></svg><span>callback?</span></a> <a href="JSONPathOptionsAutoStart.html#eval" class="tsd-index-link tsd-is-inherited"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1024"></use></svg><span>eval?</span></a> <a href="JSONPathOptionsAutoStart.html#flatten" class="tsd-index-link tsd-is-inherited"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1024"></use></svg><span>flatten?</span></a> @@ -16,7 +16,7 @@ </div><div class="tsd-comment tsd-typography"><div class="tsd-tag-Default"><h4 class="tsd-anchor-link"><a id="Default" class="tsd-anchor"></a>Default<a href="#Default" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h4><pre><code class="ts"><span class="hl-3">true</span> </code><button type="button">Copy</button></pre> -</div></div><aside class="tsd-sources"><p>Overrides <a href="JSONPathOptions.html">JSONPathOptions</a>.<a href="JSONPathOptions.html#autostart">autostart</a></p><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/a119240a17591a50176ef162e77d4305ebda73bd/src/jsonpath.d.ts#L159">jsonpath.d.ts:159</a></li></ul></aside></section><section class="tsd-panel tsd-member tsd-is-inherited"><a id="callback" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><code class="tsd-tag">Optional</code><span>callback</span><a href="#callback" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><div class="tsd-signature"><span class="tsd-kind-property">callback</span><span class="tsd-signature-symbol">?:</span> <a href="../types/JSONPathCallback.html" class="tsd-signature-type tsd-kind-type-alias">JSONPathCallback</a></div><div class="tsd-comment tsd-typography"><p>If supplied, a callback will be called immediately upon retrieval of +</div></div><aside class="tsd-sources"><p>Overrides <a href="JSONPathOptions.html">JSONPathOptions</a>.<a href="JSONPathOptions.html#autostart">autostart</a></p><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/39ee1844c610f9fd8925d3095ed3971e3d48025e/src/jsonpath.d.ts#L159">jsonpath.d.ts:159</a></li></ul></aside></section><section class="tsd-panel tsd-member tsd-is-inherited"><a id="callback" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><code class="tsd-tag">Optional</code><span>callback</span><a href="#callback" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><div class="tsd-signature"><span class="tsd-kind-property">callback</span><span class="tsd-signature-symbol">?:</span> <a href="../types/JSONPathCallback.html" class="tsd-signature-type tsd-kind-type-alias">JSONPathCallback</a></div><div class="tsd-comment tsd-typography"><p>If supplied, a callback will be called immediately upon retrieval of an end point value.</p> <p>The three arguments supplied will be the value of the payload (according to <code>resultType</code>), the type of the payload (whether it is @@ -25,7 +25,7 @@ </div><div class="tsd-comment tsd-typography"><div class="tsd-tag-Default"><h4 class="tsd-anchor-link"><a id="Default-1" class="tsd-anchor"></a>Default<a href="#Default-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h4><pre><code class="ts"><span class="hl-3">undefined</span> </code><button type="button">Copy</button></pre> -</div></div><aside class="tsd-sources"><p>Inherited from <a href="JSONPathOptions.html">JSONPathOptions</a>.<a href="JSONPathOptions.html#callback">callback</a></p><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/a119240a17591a50176ef162e77d4305ebda73bd/src/jsonpath.d.ts#L140">jsonpath.d.ts:140</a></li></ul></aside></section><section class="tsd-panel tsd-member tsd-is-inherited"><a id="eval" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><code class="tsd-tag">Optional</code><span>eval</span><a href="#eval" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><div class="tsd-signature"><span class="tsd-kind-property">eval</span><span class="tsd-signature-symbol">?:</span> <br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">boolean</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-keyword">typeof </span><a href="../classes/EvalClass.html" class="tsd-signature-type tsd-kind-class">EvalClass</a><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">"safe"</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">"native"</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">code</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span>, <span class="tsd-kind-parameter">context</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">object</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol"> => </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">)</span></div><div class="tsd-comment tsd-typography"><p>Script evaluation method.</p> +</div></div><aside class="tsd-sources"><p>Inherited from <a href="JSONPathOptions.html">JSONPathOptions</a>.<a href="JSONPathOptions.html#callback">callback</a></p><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/39ee1844c610f9fd8925d3095ed3971e3d48025e/src/jsonpath.d.ts#L140">jsonpath.d.ts:140</a></li></ul></aside></section><section class="tsd-panel tsd-member tsd-is-inherited"><a id="eval" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><code class="tsd-tag">Optional</code><span>eval</span><a href="#eval" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><div class="tsd-signature"><span class="tsd-kind-property">eval</span><span class="tsd-signature-symbol">?:</span> <br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">boolean</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-keyword">typeof </span><a href="../classes/EvalClass.html" class="tsd-signature-type tsd-kind-class">EvalClass</a><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">"safe"</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">"native"</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">code</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span>, <span class="tsd-kind-parameter">context</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">object</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol"> => </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">)</span></div><div class="tsd-comment tsd-typography"><p>Script evaluation method.</p> <p><code>safe</code>: In browser, it will use a minimal scripting engine which doesn't use <code>eval</code> or <code>Function</code> and satisfies Content Security Policy. In NodeJS, it has no effect and is equivalent to native as scripting is safe there.</p> @@ -40,20 +40,20 @@ </div><div class="tsd-comment tsd-typography"><div class="tsd-tag-Default"><h4 class="tsd-anchor-link"><a id="Default-2" class="tsd-anchor"></a>Default<a href="#Default-2" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h4><pre><code class="ts"><span class="hl-2">'safe'</span> </code><button type="button">Copy</button></pre> -</div></div><aside class="tsd-sources"><p>Inherited from <a href="JSONPathOptions.html">JSONPathOptions</a>.<a href="JSONPathOptions.html#eval">eval</a></p><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/a119240a17591a50176ef162e77d4305ebda73bd/src/jsonpath.d.ts#L102">jsonpath.d.ts:102</a></li></ul></aside></section><section class="tsd-panel tsd-member tsd-is-inherited"><a id="flatten" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><code class="tsd-tag">Optional</code><span>flatten</span><a href="#flatten" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><div class="tsd-signature"><span class="tsd-kind-property">flatten</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">boolean</span></div><div class="tsd-comment tsd-typography"><p>Whether the returned array of results will be flattened to a +</div></div><aside class="tsd-sources"><p>Inherited from <a href="JSONPathOptions.html">JSONPathOptions</a>.<a href="JSONPathOptions.html#eval">eval</a></p><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/39ee1844c610f9fd8925d3095ed3971e3d48025e/src/jsonpath.d.ts#L102">jsonpath.d.ts:102</a></li></ul></aside></section><section class="tsd-panel tsd-member tsd-is-inherited"><a id="flatten" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><code class="tsd-tag">Optional</code><span>flatten</span><a href="#flatten" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><div class="tsd-signature"><span class="tsd-kind-property">flatten</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">boolean</span></div><div class="tsd-comment tsd-typography"><p>Whether the returned array of results will be flattened to a single dimension array.</p> </div><div class="tsd-comment tsd-typography"><div class="tsd-tag-Default"><h4 class="tsd-anchor-link"><a id="Default-3" class="tsd-anchor"></a>Default<a href="#Default-3" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h4><pre><code class="ts"><span class="hl-3">false</span> </code><button type="button">Copy</button></pre> -</div></div><aside class="tsd-sources"><p>Inherited from <a href="JSONPathOptions.html">JSONPathOptions</a>.<a href="JSONPathOptions.html#flatten">flatten</a></p><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/a119240a17591a50176ef162e77d4305ebda73bd/src/jsonpath.d.ts#L40">jsonpath.d.ts:40</a></li></ul></aside></section><section class="tsd-panel tsd-member tsd-is-inherited"><a id="ignoreEvalErrors" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><code class="tsd-tag">Optional</code><span>ignore<wbr/>Eval<wbr/>Errors</span><a href="#ignoreEvalErrors" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><div class="tsd-signature"><span class="tsd-kind-property">ignore<wbr/>Eval<wbr/>Errors</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">boolean</span></div><div class="tsd-comment tsd-typography"><p>Ignore errors while evaluating JSONPath expression.</p> +</div></div><aside class="tsd-sources"><p>Inherited from <a href="JSONPathOptions.html">JSONPathOptions</a>.<a href="JSONPathOptions.html#flatten">flatten</a></p><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/39ee1844c610f9fd8925d3095ed3971e3d48025e/src/jsonpath.d.ts#L40">jsonpath.d.ts:40</a></li></ul></aside></section><section class="tsd-panel tsd-member tsd-is-inherited"><a id="ignoreEvalErrors" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><code class="tsd-tag">Optional</code><span>ignore<wbr/>Eval<wbr/>Errors</span><a href="#ignoreEvalErrors" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><div class="tsd-signature"><span class="tsd-kind-property">ignore<wbr/>Eval<wbr/>Errors</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">boolean</span></div><div class="tsd-comment tsd-typography"><p>Ignore errors while evaluating JSONPath expression.</p> <p><code>true</code>: Don't break entire search if an error occurs while evaluating JSONPath expression on one key/value pair.</p> <p><code>false</code>: Break entire search if an error occurs while evaluating JSONPath expression on one key/value pair.</p> </div><div class="tsd-comment tsd-typography"><div class="tsd-tag-Default"><h4 class="tsd-anchor-link"><a id="Default-4" class="tsd-anchor"></a>Default<a href="#Default-4" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h4><pre><code class="ts"><span class="hl-3">false</span> </code><button type="button">Copy</button></pre> -</div></div><aside class="tsd-sources"><p>Inherited from <a href="JSONPathOptions.html">JSONPathOptions</a>.<a href="JSONPathOptions.html#ignoreEvalErrors">ignoreEvalErrors</a></p><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/a119240a17591a50176ef162e77d4305ebda73bd/src/jsonpath.d.ts#L113">jsonpath.d.ts:113</a></li></ul></aside></section><section class="tsd-panel tsd-member tsd-is-inherited"><a id="json" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span>json</span><a href="#json" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><div class="tsd-signature"><span class="tsd-kind-property">json</span><span class="tsd-signature-symbol">:</span> <br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">string</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">number</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">boolean</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">object</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">[]</span></div><div class="tsd-comment tsd-typography"><p>The JSON object to evaluate (whether of null, boolean, number, +</div></div><aside class="tsd-sources"><p>Inherited from <a href="JSONPathOptions.html">JSONPathOptions</a>.<a href="JSONPathOptions.html#ignoreEvalErrors">ignoreEvalErrors</a></p><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/39ee1844c610f9fd8925d3095ed3971e3d48025e/src/jsonpath.d.ts#L113">jsonpath.d.ts:113</a></li></ul></aside></section><section class="tsd-panel tsd-member tsd-is-inherited"><a id="json" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span>json</span><a href="#json" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><div class="tsd-signature"><span class="tsd-kind-property">json</span><span class="tsd-signature-symbol">:</span> <br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">string</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">number</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">boolean</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">object</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">[]</span></div><div class="tsd-comment tsd-typography"><p>The JSON object to evaluate (whether of null, boolean, number, string, object, or array type).</p> -</div><div class="tsd-comment tsd-typography"></div><aside class="tsd-sources"><p>Inherited from <a href="JSONPathOptions.html">JSONPathOptions</a>.<a href="JSONPathOptions.html#json">json</a></p><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/a119240a17591a50176ef162e77d4305ebda73bd/src/jsonpath.d.ts#L26">jsonpath.d.ts:26</a></li></ul></aside></section><section class="tsd-panel tsd-member tsd-is-inherited"><a id="otherTypeCallback" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><code class="tsd-tag">Optional</code><span>other<wbr/>Type<wbr/>Callback</span><a href="#otherTypeCallback" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><div class="tsd-signature"><span class="tsd-kind-property">other<wbr/>Type<wbr/>Callback</span><span class="tsd-signature-symbol">?:</span> <a href="../types/JSONPathOtherTypeCallback.html" class="tsd-signature-type tsd-kind-type-alias">JSONPathOtherTypeCallback</a></div><div class="tsd-comment tsd-typography"><p>In the current absence of JSON Schema support, +</div><div class="tsd-comment tsd-typography"></div><aside class="tsd-sources"><p>Inherited from <a href="JSONPathOptions.html">JSONPathOptions</a>.<a href="JSONPathOptions.html#json">json</a></p><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/39ee1844c610f9fd8925d3095ed3971e3d48025e/src/jsonpath.d.ts#L26">jsonpath.d.ts:26</a></li></ul></aside></section><section class="tsd-panel tsd-member tsd-is-inherited"><a id="otherTypeCallback" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><code class="tsd-tag">Optional</code><span>other<wbr/>Type<wbr/>Callback</span><a href="#otherTypeCallback" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><div class="tsd-signature"><span class="tsd-kind-property">other<wbr/>Type<wbr/>Callback</span><span class="tsd-signature-symbol">?:</span> <a href="../types/JSONPathOtherTypeCallback.html" class="tsd-signature-type tsd-kind-type-alias">JSONPathOtherTypeCallback</a></div><div class="tsd-comment tsd-typography"><p>In the current absence of JSON Schema support, one can determine types beyond the built-in types by adding the perator <code>@other()</code> at the end of one's query.</p> <p>If such a path is encountered, the <code>otherTypeCallback</code> will be invoked @@ -63,20 +63,20 @@ transformations and return false).</p> </div><div class="tsd-comment tsd-typography"><div class="tsd-tag-Default"><h4 class="tsd-anchor-link"><a id="Default-5" class="tsd-anchor"></a>Default<a href="#Default-5" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h4><p>undefined <A function that throws an error when <code>@other()</code> is encountered></p> -</div></div><aside class="tsd-sources"><p>Inherited from <a href="JSONPathOptions.html">JSONPathOptions</a>.<a href="JSONPathOptions.html#otherTypeCallback">otherTypeCallback</a></p><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/a119240a17591a50176ef162e77d4305ebda73bd/src/jsonpath.d.ts#L155">jsonpath.d.ts:155</a></li></ul></aside></section><section class="tsd-panel tsd-member tsd-is-inherited"><a id="parent" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><code class="tsd-tag">Optional</code><span>parent</span><a href="#parent" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><div class="tsd-signature"><span class="tsd-kind-property">parent</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">any</span></div><div class="tsd-comment tsd-typography"><p>In the event that a query could be made to return the root node, +</div></div><aside class="tsd-sources"><p>Inherited from <a href="JSONPathOptions.html">JSONPathOptions</a>.<a href="JSONPathOptions.html#otherTypeCallback">otherTypeCallback</a></p><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/39ee1844c610f9fd8925d3095ed3971e3d48025e/src/jsonpath.d.ts#L155">jsonpath.d.ts:155</a></li></ul></aside></section><section class="tsd-panel tsd-member tsd-is-inherited"><a id="parent" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><code class="tsd-tag">Optional</code><span>parent</span><a href="#parent" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><div class="tsd-signature"><span class="tsd-kind-property">parent</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">any</span></div><div class="tsd-comment tsd-typography"><p>In the event that a query could be made to return the root node, this allows the parent of that root node to be returned within results.</p> </div><div class="tsd-comment tsd-typography"><div class="tsd-tag-Default"><h4 class="tsd-anchor-link"><a id="Default-6" class="tsd-anchor"></a>Default<a href="#Default-6" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h4><pre><code class="ts"><span class="hl-3">null</span> </code><button type="button">Copy</button></pre> -</div></div><aside class="tsd-sources"><p>Inherited from <a href="JSONPathOptions.html">JSONPathOptions</a>.<a href="JSONPathOptions.html#parent">parent</a></p><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/a119240a17591a50176ef162e77d4305ebda73bd/src/jsonpath.d.ts#L120">jsonpath.d.ts:120</a></li></ul></aside></section><section class="tsd-panel tsd-member tsd-is-inherited"><a id="parentProperty" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><code class="tsd-tag">Optional</code><span>parent<wbr/>Property</span><a href="#parentProperty" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><div class="tsd-signature"><span class="tsd-kind-property">parent<wbr/>Property</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">any</span></div><div class="tsd-comment tsd-typography"><p>In the event that a query could be made to return the root node, +</div></div><aside class="tsd-sources"><p>Inherited from <a href="JSONPathOptions.html">JSONPathOptions</a>.<a href="JSONPathOptions.html#parent">parent</a></p><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/39ee1844c610f9fd8925d3095ed3971e3d48025e/src/jsonpath.d.ts#L120">jsonpath.d.ts:120</a></li></ul></aside></section><section class="tsd-panel tsd-member tsd-is-inherited"><a id="parentProperty" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><code class="tsd-tag">Optional</code><span>parent<wbr/>Property</span><a href="#parentProperty" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><div class="tsd-signature"><span class="tsd-kind-property">parent<wbr/>Property</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">any</span></div><div class="tsd-comment tsd-typography"><p>In the event that a query could be made to return the root node, this allows the parentProperty of that root node to be returned within results.</p> </div><div class="tsd-comment tsd-typography"><div class="tsd-tag-Default"><h4 class="tsd-anchor-link"><a id="Default-7" class="tsd-anchor"></a>Default<a href="#Default-7" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h4><pre><code class="ts"><span class="hl-3">null</span> </code><button type="button">Copy</button></pre> -</div></div><aside class="tsd-sources"><p>Inherited from <a href="JSONPathOptions.html">JSONPathOptions</a>.<a href="JSONPathOptions.html#parentProperty">parentProperty</a></p><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/a119240a17591a50176ef162e77d4305ebda73bd/src/jsonpath.d.ts#L128">jsonpath.d.ts:128</a></li></ul></aside></section><section class="tsd-panel tsd-member tsd-is-inherited"><a id="path" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span>path</span><a href="#path" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><div class="tsd-signature"><span class="tsd-kind-property">path</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">[]</span></div><div class="tsd-comment tsd-typography"><p>The JSONPath expression as a (normalized or unnormalized) string or +</div></div><aside class="tsd-sources"><p>Inherited from <a href="JSONPathOptions.html">JSONPathOptions</a>.<a href="JSONPathOptions.html#parentProperty">parentProperty</a></p><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/39ee1844c610f9fd8925d3095ed3971e3d48025e/src/jsonpath.d.ts#L128">jsonpath.d.ts:128</a></li></ul></aside></section><section class="tsd-panel tsd-member tsd-is-inherited"><a id="path" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span>path</span><a href="#path" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><div class="tsd-signature"><span class="tsd-kind-property">path</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">[]</span></div><div class="tsd-comment tsd-typography"><p>The JSONPath expression as a (normalized or unnormalized) string or array.</p> -</div><div class="tsd-comment tsd-typography"></div><aside class="tsd-sources"><p>Inherited from <a href="JSONPathOptions.html">JSONPathOptions</a>.<a href="JSONPathOptions.html#path">path</a></p><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/a119240a17591a50176ef162e77d4305ebda73bd/src/jsonpath.d.ts#L21">jsonpath.d.ts:21</a></li></ul></aside></section><section class="tsd-panel tsd-member tsd-is-inherited"><a id="resultType" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><code class="tsd-tag">Optional</code><span>result<wbr/>Type</span><a href="#resultType" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><div class="tsd-signature"><span class="tsd-kind-property">result<wbr/>Type</span><span class="tsd-signature-symbol">?:</span> <br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">"value"</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">"path"</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">"pointer"</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">"parent"</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">"parentProperty"</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">"all"</span></div><div class="tsd-comment tsd-typography"><p>Can be case-insensitive form of "value", "path", "pointer", "parent", +</div><div class="tsd-comment tsd-typography"></div><aside class="tsd-sources"><p>Inherited from <a href="JSONPathOptions.html">JSONPathOptions</a>.<a href="JSONPathOptions.html#path">path</a></p><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/39ee1844c610f9fd8925d3095ed3971e3d48025e/src/jsonpath.d.ts#L21">jsonpath.d.ts:21</a></li></ul></aside></section><section class="tsd-panel tsd-member tsd-is-inherited"><a id="resultType" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><code class="tsd-tag">Optional</code><span>result<wbr/>Type</span><a href="#resultType" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><div class="tsd-signature"><span class="tsd-kind-property">result<wbr/>Type</span><span class="tsd-signature-symbol">?:</span> <br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">"value"</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">"path"</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">"pointer"</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">"parent"</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">"parentProperty"</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">"all"</span></div><div class="tsd-comment tsd-typography"><p>Can be case-insensitive form of "value", "path", "pointer", "parent", or "parentProperty" to determine respectively whether to return results as the values of the found items, as their absolute paths, as JSON Pointers to the absolute paths, as their parent objects, @@ -86,11 +86,11 @@ </div><div class="tsd-comment tsd-typography"><div class="tsd-tag-Default"><h4 class="tsd-anchor-link"><a id="Default-8" class="tsd-anchor"></a>Default<a href="#Default-8" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h4><pre><code class="ts"><span class="hl-2">'value'</span> </code><button type="button">Copy</button></pre> -</div></div><aside class="tsd-sources"><p>Inherited from <a href="JSONPathOptions.html">JSONPathOptions</a>.<a href="JSONPathOptions.html#resultType">resultType</a></p><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/a119240a17591a50176ef162e77d4305ebda73bd/src/jsonpath.d.ts#L53">jsonpath.d.ts:53</a></li></ul></aside></section><section class="tsd-panel tsd-member tsd-is-inherited"><a id="sandbox" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><code class="tsd-tag">Optional</code><span>sandbox</span><a href="#sandbox" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><div class="tsd-signature"><span class="tsd-kind-property">sandbox</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">Map</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">></span></div><div class="tsd-comment tsd-typography"><p>Key-value map of variables to be available to code evaluations such +</div></div><aside class="tsd-sources"><p>Inherited from <a href="JSONPathOptions.html">JSONPathOptions</a>.<a href="JSONPathOptions.html#resultType">resultType</a></p><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/39ee1844c610f9fd8925d3095ed3971e3d48025e/src/jsonpath.d.ts#L53">jsonpath.d.ts:53</a></li></ul></aside></section><section class="tsd-panel tsd-member tsd-is-inherited"><a id="sandbox" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><code class="tsd-tag">Optional</code><span>sandbox</span><a href="#sandbox" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><div class="tsd-signature"><span class="tsd-kind-property">sandbox</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">Map</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">></span></div><div class="tsd-comment tsd-typography"><p>Key-value map of variables to be available to code evaluations such as filtering expressions. (Note that the current path and value will also be available to those expressions; see the Syntax section for details.)</p> -</div><div class="tsd-comment tsd-typography"></div><aside class="tsd-sources"><p>Inherited from <a href="JSONPathOptions.html">JSONPathOptions</a>.<a href="JSONPathOptions.html#sandbox">sandbox</a></p><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/a119240a17591a50176ef162e77d4305ebda73bd/src/jsonpath.d.ts#L62">jsonpath.d.ts:62</a></li></ul></aside></section><section class="tsd-panel tsd-member tsd-is-inherited"><a id="wrap" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><code class="tsd-tag">Optional</code><span>wrap</span><a href="#wrap" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><div class="tsd-signature"><span class="tsd-kind-property">wrap</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">boolean</span></div><div class="tsd-comment tsd-typography"><p>Whether or not to wrap the results in an array.</p> +</div><div class="tsd-comment tsd-typography"></div><aside class="tsd-sources"><p>Inherited from <a href="JSONPathOptions.html">JSONPathOptions</a>.<a href="JSONPathOptions.html#sandbox">sandbox</a></p><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/39ee1844c610f9fd8925d3095ed3971e3d48025e/src/jsonpath.d.ts#L62">jsonpath.d.ts:62</a></li></ul></aside></section><section class="tsd-panel tsd-member tsd-is-inherited"><a id="wrap" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><code class="tsd-tag">Optional</code><span>wrap</span><a href="#wrap" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><div class="tsd-signature"><span class="tsd-kind-property">wrap</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">boolean</span></div><div class="tsd-comment tsd-typography"><p>Whether or not to wrap the results in an array.</p> <p>If wrap is set to false, and no results are found, undefined will be returned (as opposed to an empty array when wrap is set to true).</p> <p>If wrap is set to false and a single non-array result is found, that @@ -102,4 +102,4 @@ </div><div class="tsd-comment tsd-typography"><div class="tsd-tag-Default"><h4 class="tsd-anchor-link"><a id="Default-9" class="tsd-anchor"></a>Default<a href="#Default-9" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h4><pre><code class="ts"><span class="hl-3">true</span> </code><button type="button">Copy</button></pre> -</div></div><aside class="tsd-sources"><p>Inherited from <a href="JSONPathOptions.html">JSONPathOptions</a>.<a href="JSONPathOptions.html#wrap">wrap</a></p><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/a119240a17591a50176ef162e77d4305ebda73bd/src/jsonpath.d.ts#L79">jsonpath.d.ts:79</a></li></ul></aside></section></section></details></div><div class="col-sidebar"><div class="page-menu"><div class="tsd-navigation settings"><details class="tsd-accordion"><summary class="tsd-accordion-summary"><h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Settings</h3></summary><div class="tsd-accordion-details"><div class="tsd-filter-visibility"><span class="settings-label">Member Visibility</span><ul id="tsd-filter-options"><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-protected" name="protected"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Protected</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-inherited" name="inherited" checked/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Inherited</span></label></li></ul></div><div class="tsd-theme-toggle"><label class="settings-label" for="tsd-theme">Theme</label><select id="tsd-theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div><details open class="tsd-accordion tsd-page-navigation"><summary class="tsd-accordion-summary"><h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>On This Page</h3></summary><div class="tsd-accordion-details"><details open class="tsd-accordion tsd-page-navigation-section"><summary class="tsd-accordion-summary" data-key="tsd-otp-Properties"><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Properties</summary><div><a href="#autostart" class=""><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1024"></use></svg><span>autostart</span></a><a href="#callback" class="tsd-is-inherited"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1024"></use></svg><span>callback</span></a><a href="#eval" class="tsd-is-inherited"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1024"></use></svg><span>eval</span></a><a href="#flatten" class="tsd-is-inherited"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1024"></use></svg><span>flatten</span></a><a href="#ignoreEvalErrors" class="tsd-is-inherited"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1024"></use></svg><span>ignore<wbr/>Eval<wbr/>Errors</span></a><a href="#json" class="tsd-is-inherited"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1024"></use></svg><span>json</span></a><a href="#otherTypeCallback" class="tsd-is-inherited"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1024"></use></svg><span>other<wbr/>Type<wbr/>Callback</span></a><a href="#parent" class="tsd-is-inherited"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1024"></use></svg><span>parent</span></a><a href="#parentProperty" class="tsd-is-inherited"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1024"></use></svg><span>parent<wbr/>Property</span></a><a href="#path" class="tsd-is-inherited"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1024"></use></svg><span>path</span></a><a href="#resultType" class="tsd-is-inherited"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1024"></use></svg><span>result<wbr/>Type</span></a><a href="#sandbox" class="tsd-is-inherited"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1024"></use></svg><span>sandbox</span></a><a href="#wrap" class="tsd-is-inherited"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1024"></use></svg><span>wrap</span></a></div></details></div></details></div><div class="site-menu"><nav class="tsd-navigation"><a href="../modules.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1"></use></svg><span>jsonpath-plus</span></a><ul class="tsd-small-nested-navigation" id="tsd-nav-container" data-base=".."><li>Loading...</li></ul></nav></div></div></div><footer><p class="tsd-generator">Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></footer><div class="overlay"></div></body></html> +</div></div><aside class="tsd-sources"><p>Inherited from <a href="JSONPathOptions.html">JSONPathOptions</a>.<a href="JSONPathOptions.html#wrap">wrap</a></p><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/39ee1844c610f9fd8925d3095ed3971e3d48025e/src/jsonpath.d.ts#L79">jsonpath.d.ts:79</a></li></ul></aside></section></section></details></div><div class="col-sidebar"><div class="page-menu"><div class="tsd-navigation settings"><details class="tsd-accordion"><summary class="tsd-accordion-summary"><h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Settings</h3></summary><div class="tsd-accordion-details"><div class="tsd-filter-visibility"><span class="settings-label">Member Visibility</span><ul id="tsd-filter-options"><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-protected" name="protected"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Protected</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-inherited" name="inherited" checked/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Inherited</span></label></li></ul></div><div class="tsd-theme-toggle"><label class="settings-label" for="tsd-theme">Theme</label><select id="tsd-theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div><details open class="tsd-accordion tsd-page-navigation"><summary class="tsd-accordion-summary"><h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>On This Page</h3></summary><div class="tsd-accordion-details"><details open class="tsd-accordion tsd-page-navigation-section"><summary class="tsd-accordion-summary" data-key="tsd-otp-Properties"><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Properties</summary><div><a href="#autostart" class=""><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1024"></use></svg><span>autostart</span></a><a href="#callback" class="tsd-is-inherited"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1024"></use></svg><span>callback</span></a><a href="#eval" class="tsd-is-inherited"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1024"></use></svg><span>eval</span></a><a href="#flatten" class="tsd-is-inherited"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1024"></use></svg><span>flatten</span></a><a href="#ignoreEvalErrors" class="tsd-is-inherited"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1024"></use></svg><span>ignore<wbr/>Eval<wbr/>Errors</span></a><a href="#json" class="tsd-is-inherited"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1024"></use></svg><span>json</span></a><a href="#otherTypeCallback" class="tsd-is-inherited"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1024"></use></svg><span>other<wbr/>Type<wbr/>Callback</span></a><a href="#parent" class="tsd-is-inherited"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1024">< ... [truncated]
docs/ts/interfaces/JSONPathOptions.html+14 −14 modified@@ -1,4 +1,4 @@ -<!DOCTYPE html><html class="default" lang="en"><head><meta charset="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>JSONPathOptions | jsonpath-plus</title><meta name="description" content="Documentation for jsonpath-plus"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script defer src="../assets/main.js"></script><script async src="../assets/icons.js" id="tsd-icons-script"></script><script async src="../assets/search.js" id="tsd-search-script"></script><script async src="../assets/navigation.js" id="tsd-nav-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><div class="table-cell" id="tsd-search" data-base=".."><div class="field"><label for="tsd-search-field" class="tsd-widget tsd-toolbar-icon search no-caption"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-search"></use></svg></label><input type="text" id="tsd-search-field" aria-label="Search"/></div><div class="field"><div id="tsd-toolbar-links"></div></div><ul class="results"><li class="state loading">Preparing search index...</li><li class="state failure">The search index is not available</li></ul><a href="../index.html" class="title">jsonpath-plus</a></div><div class="table-cell" id="tsd-widgets"><a href="#" class="tsd-widget tsd-toolbar-icon menu no-caption" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-menu"></use></svg></a></div></div></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><ul class="tsd-breadcrumb"><li><a href="../modules.html">jsonpath-plus</a></li><li><a href="JSONPathOptions.html">JSONPathOptions</a></li></ul><h1>Interface JSONPathOptions</h1></div><div class="tsd-signature"><span class="tsd-signature-keyword">interface </span><span class="tsd-kind-interface">JSONPathOptions</span> <span class="tsd-signature-symbol">{ </span><br/><span> </span><a class="tsd-kind-property" href="JSONPathOptions.html#autostart">autostart</a><span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">boolean</span><span class="tsd-signature-symbol">; </span><br/><span> </span><a class="tsd-kind-property" href="JSONPathOptions.html#callback">callback</a><span class="tsd-signature-symbol">?: </span><a href="../types/JSONPathCallback.html" class="tsd-signature-type tsd-kind-type-alias">JSONPathCallback</a><span class="tsd-signature-symbol">; </span><br/><span> </span><a class="tsd-kind-property" href="JSONPathOptions.html#eval">eval</a><span class="tsd-signature-symbol">?: </span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">boolean</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-keyword">typeof </span><a href="../classes/EvalClass.html" class="tsd-signature-type tsd-kind-class">EvalClass</a><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">"safe"</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">"native"</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">code</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span>, <span class="tsd-kind-parameter">context</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">object</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol"> => </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">; </span><br/><span> </span><a class="tsd-kind-property" href="JSONPathOptions.html#flatten">flatten</a><span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">boolean</span><span class="tsd-signature-symbol">; </span><br/><span> </span><a class="tsd-kind-property" href="JSONPathOptions.html#ignoreEvalErrors">ignoreEvalErrors</a><span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">boolean</span><span class="tsd-signature-symbol">; </span><br/><span> </span><a class="tsd-kind-property" href="JSONPathOptions.html#json">json</a><span class="tsd-signature-symbol">: </span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">string</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">number</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">boolean</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">object</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">; </span><br/><span> </span><a class="tsd-kind-property" href="JSONPathOptions.html#otherTypeCallback">otherTypeCallback</a><span class="tsd-signature-symbol">?: </span><a href="../types/JSONPathOtherTypeCallback.html" class="tsd-signature-type tsd-kind-type-alias">JSONPathOtherTypeCallback</a><span class="tsd-signature-symbol">; </span><br/><span> </span><a class="tsd-kind-property" href="JSONPathOptions.html#parent">parent</a><span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">; </span><br/><span> </span><a class="tsd-kind-property" href="JSONPathOptions.html#parentProperty">parentProperty</a><span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">; </span><br/><span> </span><a class="tsd-kind-property" href="JSONPathOptions.html#path">path</a><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">; </span><br/><span> </span><a class="tsd-kind-property" href="JSONPathOptions.html#resultType">resultType</a><span class="tsd-signature-symbol">?: </span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">"value"</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">"path"</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">"pointer"</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">"parent"</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">"parentProperty"</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">"all"</span><span class="tsd-signature-symbol">; </span><br/><span> </span><a class="tsd-kind-property" href="JSONPathOptions.html#sandbox">sandbox</a><span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">Map</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">; </span><br/><span> </span><a class="tsd-kind-property" href="JSONPathOptions.html#wrap">wrap</a><span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">boolean</span><span class="tsd-signature-symbol">; </span><br/><span class="tsd-signature-symbol">}</span></div><section class="tsd-panel tsd-hierarchy"><h4>Hierarchy (<a href="../hierarchy.html#JSONPathOptions">view full</a>)</h4><ul class="tsd-hierarchy"><li><span class="target">JSONPathOptions</span><ul class="tsd-hierarchy"><li><a href="JSONPathOptionsAutoStart.html" class="tsd-signature-type tsd-kind-interface">JSONPathOptionsAutoStart</a></li></ul></li></ul></section><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/a119240a17591a50176ef162e77d4305ebda73bd/src/jsonpath.d.ts#L16">jsonpath.d.ts:16</a></li></ul></aside><section class="tsd-panel-group tsd-index-group"><section class="tsd-panel tsd-index-panel"><details class="tsd-index-content tsd-accordion" open><summary class="tsd-accordion-summary tsd-index-summary"><h5 class="tsd-index-heading uppercase" role="button" aria-expanded="false" tabIndex="0"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-chevronSmall"></use></svg> Index</h5></summary><div class="tsd-accordion-details"><section class="tsd-index-section"><h3 class="tsd-index-heading">Properties</h3><div class="tsd-index-list"><a href="JSONPathOptions.html#autostart" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1024"></use></svg><span>autostart?</span></a> +<!DOCTYPE html><html class="default" lang="en"><head><meta charset="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>JSONPathOptions | jsonpath-plus</title><meta name="description" content="Documentation for jsonpath-plus"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script defer src="../assets/main.js"></script><script async src="../assets/icons.js" id="tsd-icons-script"></script><script async src="../assets/search.js" id="tsd-search-script"></script><script async src="../assets/navigation.js" id="tsd-nav-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><div class="table-cell" id="tsd-search" data-base=".."><div class="field"><label for="tsd-search-field" class="tsd-widget tsd-toolbar-icon search no-caption"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-search"></use></svg></label><input type="text" id="tsd-search-field" aria-label="Search"/></div><div class="field"><div id="tsd-toolbar-links"></div></div><ul class="results"><li class="state loading">Preparing search index...</li><li class="state failure">The search index is not available</li></ul><a href="../index.html" class="title">jsonpath-plus</a></div><div class="table-cell" id="tsd-widgets"><a href="#" class="tsd-widget tsd-toolbar-icon menu no-caption" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-menu"></use></svg></a></div></div></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><ul class="tsd-breadcrumb"><li><a href="../modules.html">jsonpath-plus</a></li><li><a href="JSONPathOptions.html">JSONPathOptions</a></li></ul><h1>Interface JSONPathOptions</h1></div><div class="tsd-signature"><span class="tsd-signature-keyword">interface </span><span class="tsd-kind-interface">JSONPathOptions</span> <span class="tsd-signature-symbol">{ </span><br/><span> </span><a class="tsd-kind-property" href="JSONPathOptions.html#autostart">autostart</a><span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">boolean</span><span class="tsd-signature-symbol">; </span><br/><span> </span><a class="tsd-kind-property" href="JSONPathOptions.html#callback">callback</a><span class="tsd-signature-symbol">?: </span><a href="../types/JSONPathCallback.html" class="tsd-signature-type tsd-kind-type-alias">JSONPathCallback</a><span class="tsd-signature-symbol">; </span><br/><span> </span><a class="tsd-kind-property" href="JSONPathOptions.html#eval">eval</a><span class="tsd-signature-symbol">?: </span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">boolean</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-keyword">typeof </span><a href="../classes/EvalClass.html" class="tsd-signature-type tsd-kind-class">EvalClass</a><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">"safe"</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">"native"</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">code</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span>, <span class="tsd-kind-parameter">context</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">object</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol"> => </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">; </span><br/><span> </span><a class="tsd-kind-property" href="JSONPathOptions.html#flatten">flatten</a><span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">boolean</span><span class="tsd-signature-symbol">; </span><br/><span> </span><a class="tsd-kind-property" href="JSONPathOptions.html#ignoreEvalErrors">ignoreEvalErrors</a><span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">boolean</span><span class="tsd-signature-symbol">; </span><br/><span> </span><a class="tsd-kind-property" href="JSONPathOptions.html#json">json</a><span class="tsd-signature-symbol">: </span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">string</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">number</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">boolean</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">object</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">; </span><br/><span> </span><a class="tsd-kind-property" href="JSONPathOptions.html#otherTypeCallback">otherTypeCallback</a><span class="tsd-signature-symbol">?: </span><a href="../types/JSONPathOtherTypeCallback.html" class="tsd-signature-type tsd-kind-type-alias">JSONPathOtherTypeCallback</a><span class="tsd-signature-symbol">; </span><br/><span> </span><a class="tsd-kind-property" href="JSONPathOptions.html#parent">parent</a><span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">; </span><br/><span> </span><a class="tsd-kind-property" href="JSONPathOptions.html#parentProperty">parentProperty</a><span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">; </span><br/><span> </span><a class="tsd-kind-property" href="JSONPathOptions.html#path">path</a><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">; </span><br/><span> </span><a class="tsd-kind-property" href="JSONPathOptions.html#resultType">resultType</a><span class="tsd-signature-symbol">?: </span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">"value"</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">"path"</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">"pointer"</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">"parent"</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">"parentProperty"</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">"all"</span><span class="tsd-signature-symbol">; </span><br/><span> </span><a class="tsd-kind-property" href="JSONPathOptions.html#sandbox">sandbox</a><span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">Map</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">; </span><br/><span> </span><a class="tsd-kind-property" href="JSONPathOptions.html#wrap">wrap</a><span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">boolean</span><span class="tsd-signature-symbol">; </span><br/><span class="tsd-signature-symbol">}</span></div><section class="tsd-panel tsd-hierarchy"><h4>Hierarchy (<a href="../hierarchy.html#JSONPathOptions">view full</a>)</h4><ul class="tsd-hierarchy"><li><span class="target">JSONPathOptions</span><ul class="tsd-hierarchy"><li><a href="JSONPathOptionsAutoStart.html" class="tsd-signature-type tsd-kind-interface">JSONPathOptionsAutoStart</a></li></ul></li></ul></section><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/39ee1844c610f9fd8925d3095ed3971e3d48025e/src/jsonpath.d.ts#L16">jsonpath.d.ts:16</a></li></ul></aside><section class="tsd-panel-group tsd-index-group"><section class="tsd-panel tsd-index-panel"><details class="tsd-index-content tsd-accordion" open><summary class="tsd-accordion-summary tsd-index-summary"><h5 class="tsd-index-heading uppercase" role="button" aria-expanded="false" tabIndex="0"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-chevronSmall"></use></svg> Index</h5></summary><div class="tsd-accordion-details"><section class="tsd-index-section"><h3 class="tsd-index-heading">Properties</h3><div class="tsd-index-list"><a href="JSONPathOptions.html#autostart" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1024"></use></svg><span>autostart?</span></a> <a href="JSONPathOptions.html#callback" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1024"></use></svg><span>callback?</span></a> <a href="JSONPathOptions.html#eval" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1024"></use></svg><span>eval?</span></a> <a href="JSONPathOptions.html#flatten" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1024"></use></svg><span>flatten?</span></a> @@ -16,7 +16,7 @@ </div><div class="tsd-comment tsd-typography"><div class="tsd-tag-Default"><h4 class="tsd-anchor-link"><a id="Default" class="tsd-anchor"></a>Default<a href="#Default" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h4><pre><code class="ts"><span class="hl-3">true</span> </code><button type="button">Copy</button></pre> -</div></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/a119240a17591a50176ef162e77d4305ebda73bd/src/jsonpath.d.ts#L33">jsonpath.d.ts:33</a></li></ul></aside></section><section class="tsd-panel tsd-member"><a id="callback" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><code class="tsd-tag">Optional</code><span>callback</span><a href="#callback" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><div class="tsd-signature"><span class="tsd-kind-property">callback</span><span class="tsd-signature-symbol">?:</span> <a href="../types/JSONPathCallback.html" class="tsd-signature-type tsd-kind-type-alias">JSONPathCallback</a></div><div class="tsd-comment tsd-typography"><p>If supplied, a callback will be called immediately upon retrieval of +</div></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/39ee1844c610f9fd8925d3095ed3971e3d48025e/src/jsonpath.d.ts#L33">jsonpath.d.ts:33</a></li></ul></aside></section><section class="tsd-panel tsd-member"><a id="callback" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><code class="tsd-tag">Optional</code><span>callback</span><a href="#callback" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><div class="tsd-signature"><span class="tsd-kind-property">callback</span><span class="tsd-signature-symbol">?:</span> <a href="../types/JSONPathCallback.html" class="tsd-signature-type tsd-kind-type-alias">JSONPathCallback</a></div><div class="tsd-comment tsd-typography"><p>If supplied, a callback will be called immediately upon retrieval of an end point value.</p> <p>The three arguments supplied will be the value of the payload (according to <code>resultType</code>), the type of the payload (whether it is @@ -25,7 +25,7 @@ </div><div class="tsd-comment tsd-typography"><div class="tsd-tag-Default"><h4 class="tsd-anchor-link"><a id="Default-1" class="tsd-anchor"></a>Default<a href="#Default-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h4><pre><code class="ts"><span class="hl-3">undefined</span> </code><button type="button">Copy</button></pre> -</div></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/a119240a17591a50176ef162e77d4305ebda73bd/src/jsonpath.d.ts#L140">jsonpath.d.ts:140</a></li></ul></aside></section><section class="tsd-panel tsd-member"><a id="eval" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><code class="tsd-tag">Optional</code><span>eval</span><a href="#eval" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><div class="tsd-signature"><span class="tsd-kind-property">eval</span><span class="tsd-signature-symbol">?:</span> <br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">boolean</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-keyword">typeof </span><a href="../classes/EvalClass.html" class="tsd-signature-type tsd-kind-class">EvalClass</a><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">"safe"</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">"native"</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">code</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span>, <span class="tsd-kind-parameter">context</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">object</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol"> => </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">)</span></div><div class="tsd-comment tsd-typography"><p>Script evaluation method.</p> +</div></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/39ee1844c610f9fd8925d3095ed3971e3d48025e/src/jsonpath.d.ts#L140">jsonpath.d.ts:140</a></li></ul></aside></section><section class="tsd-panel tsd-member"><a id="eval" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><code class="tsd-tag">Optional</code><span>eval</span><a href="#eval" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><div class="tsd-signature"><span class="tsd-kind-property">eval</span><span class="tsd-signature-symbol">?:</span> <br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">boolean</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-keyword">typeof </span><a href="../classes/EvalClass.html" class="tsd-signature-type tsd-kind-class">EvalClass</a><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">"safe"</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">"native"</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">code</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span>, <span class="tsd-kind-parameter">context</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">object</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol"> => </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">)</span></div><div class="tsd-comment tsd-typography"><p>Script evaluation method.</p> <p><code>safe</code>: In browser, it will use a minimal scripting engine which doesn't use <code>eval</code> or <code>Function</code> and satisfies Content Security Policy. In NodeJS, it has no effect and is equivalent to native as scripting is safe there.</p> @@ -40,20 +40,20 @@ </div><div class="tsd-comment tsd-typography"><div class="tsd-tag-Default"><h4 class="tsd-anchor-link"><a id="Default-2" class="tsd-anchor"></a>Default<a href="#Default-2" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h4><pre><code class="ts"><span class="hl-2">'safe'</span> </code><button type="button">Copy</button></pre> -</div></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/a119240a17591a50176ef162e77d4305ebda73bd/src/jsonpath.d.ts#L102">jsonpath.d.ts:102</a></li></ul></aside></section><section class="tsd-panel tsd-member"><a id="flatten" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><code class="tsd-tag">Optional</code><span>flatten</span><a href="#flatten" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><div class="tsd-signature"><span class="tsd-kind-property">flatten</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">boolean</span></div><div class="tsd-comment tsd-typography"><p>Whether the returned array of results will be flattened to a +</div></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/39ee1844c610f9fd8925d3095ed3971e3d48025e/src/jsonpath.d.ts#L102">jsonpath.d.ts:102</a></li></ul></aside></section><section class="tsd-panel tsd-member"><a id="flatten" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><code class="tsd-tag">Optional</code><span>flatten</span><a href="#flatten" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><div class="tsd-signature"><span class="tsd-kind-property">flatten</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">boolean</span></div><div class="tsd-comment tsd-typography"><p>Whether the returned array of results will be flattened to a single dimension array.</p> </div><div class="tsd-comment tsd-typography"><div class="tsd-tag-Default"><h4 class="tsd-anchor-link"><a id="Default-3" class="tsd-anchor"></a>Default<a href="#Default-3" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h4><pre><code class="ts"><span class="hl-3">false</span> </code><button type="button">Copy</button></pre> -</div></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/a119240a17591a50176ef162e77d4305ebda73bd/src/jsonpath.d.ts#L40">jsonpath.d.ts:40</a></li></ul></aside></section><section class="tsd-panel tsd-member"><a id="ignoreEvalErrors" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><code class="tsd-tag">Optional</code><span>ignore<wbr/>Eval<wbr/>Errors</span><a href="#ignoreEvalErrors" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><div class="tsd-signature"><span class="tsd-kind-property">ignore<wbr/>Eval<wbr/>Errors</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">boolean</span></div><div class="tsd-comment tsd-typography"><p>Ignore errors while evaluating JSONPath expression.</p> +</div></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/39ee1844c610f9fd8925d3095ed3971e3d48025e/src/jsonpath.d.ts#L40">jsonpath.d.ts:40</a></li></ul></aside></section><section class="tsd-panel tsd-member"><a id="ignoreEvalErrors" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><code class="tsd-tag">Optional</code><span>ignore<wbr/>Eval<wbr/>Errors</span><a href="#ignoreEvalErrors" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><div class="tsd-signature"><span class="tsd-kind-property">ignore<wbr/>Eval<wbr/>Errors</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">boolean</span></div><div class="tsd-comment tsd-typography"><p>Ignore errors while evaluating JSONPath expression.</p> <p><code>true</code>: Don't break entire search if an error occurs while evaluating JSONPath expression on one key/value pair.</p> <p><code>false</code>: Break entire search if an error occurs while evaluating JSONPath expression on one key/value pair.</p> </div><div class="tsd-comment tsd-typography"><div class="tsd-tag-Default"><h4 class="tsd-anchor-link"><a id="Default-4" class="tsd-anchor"></a>Default<a href="#Default-4" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h4><pre><code class="ts"><span class="hl-3">false</span> </code><button type="button">Copy</button></pre> -</div></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/a119240a17591a50176ef162e77d4305ebda73bd/src/jsonpath.d.ts#L113">jsonpath.d.ts:113</a></li></ul></aside></section><section class="tsd-panel tsd-member"><a id="json" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span>json</span><a href="#json" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><div class="tsd-signature"><span class="tsd-kind-property">json</span><span class="tsd-signature-symbol">:</span> <br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">string</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">number</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">boolean</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">object</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">[]</span></div><div class="tsd-comment tsd-typography"><p>The JSON object to evaluate (whether of null, boolean, number, +</div></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/39ee1844c610f9fd8925d3095ed3971e3d48025e/src/jsonpath.d.ts#L113">jsonpath.d.ts:113</a></li></ul></aside></section><section class="tsd-panel tsd-member"><a id="json" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span>json</span><a href="#json" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><div class="tsd-signature"><span class="tsd-kind-property">json</span><span class="tsd-signature-symbol">:</span> <br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">string</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">number</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">boolean</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">object</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">[]</span></div><div class="tsd-comment tsd-typography"><p>The JSON object to evaluate (whether of null, boolean, number, string, object, or array type).</p> -</div><div class="tsd-comment tsd-typography"></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/a119240a17591a50176ef162e77d4305ebda73bd/src/jsonpath.d.ts#L26">jsonpath.d.ts:26</a></li></ul></aside></section><section class="tsd-panel tsd-member"><a id="otherTypeCallback" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><code class="tsd-tag">Optional</code><span>other<wbr/>Type<wbr/>Callback</span><a href="#otherTypeCallback" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><div class="tsd-signature"><span class="tsd-kind-property">other<wbr/>Type<wbr/>Callback</span><span class="tsd-signature-symbol">?:</span> <a href="../types/JSONPathOtherTypeCallback.html" class="tsd-signature-type tsd-kind-type-alias">JSONPathOtherTypeCallback</a></div><div class="tsd-comment tsd-typography"><p>In the current absence of JSON Schema support, +</div><div class="tsd-comment tsd-typography"></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/39ee1844c610f9fd8925d3095ed3971e3d48025e/src/jsonpath.d.ts#L26">jsonpath.d.ts:26</a></li></ul></aside></section><section class="tsd-panel tsd-member"><a id="otherTypeCallback" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><code class="tsd-tag">Optional</code><span>other<wbr/>Type<wbr/>Callback</span><a href="#otherTypeCallback" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><div class="tsd-signature"><span class="tsd-kind-property">other<wbr/>Type<wbr/>Callback</span><span class="tsd-signature-symbol">?:</span> <a href="../types/JSONPathOtherTypeCallback.html" class="tsd-signature-type tsd-kind-type-alias">JSONPathOtherTypeCallback</a></div><div class="tsd-comment tsd-typography"><p>In the current absence of JSON Schema support, one can determine types beyond the built-in types by adding the perator <code>@other()</code> at the end of one's query.</p> <p>If such a path is encountered, the <code>otherTypeCallback</code> will be invoked @@ -63,20 +63,20 @@ transformations and return false).</p> </div><div class="tsd-comment tsd-typography"><div class="tsd-tag-Default"><h4 class="tsd-anchor-link"><a id="Default-5" class="tsd-anchor"></a>Default<a href="#Default-5" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h4><p>undefined <A function that throws an error when <code>@other()</code> is encountered></p> -</div></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/a119240a17591a50176ef162e77d4305ebda73bd/src/jsonpath.d.ts#L155">jsonpath.d.ts:155</a></li></ul></aside></section><section class="tsd-panel tsd-member"><a id="parent" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><code class="tsd-tag">Optional</code><span>parent</span><a href="#parent" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><div class="tsd-signature"><span class="tsd-kind-property">parent</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">any</span></div><div class="tsd-comment tsd-typography"><p>In the event that a query could be made to return the root node, +</div></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/39ee1844c610f9fd8925d3095ed3971e3d48025e/src/jsonpath.d.ts#L155">jsonpath.d.ts:155</a></li></ul></aside></section><section class="tsd-panel tsd-member"><a id="parent" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><code class="tsd-tag">Optional</code><span>parent</span><a href="#parent" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><div class="tsd-signature"><span class="tsd-kind-property">parent</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">any</span></div><div class="tsd-comment tsd-typography"><p>In the event that a query could be made to return the root node, this allows the parent of that root node to be returned within results.</p> </div><div class="tsd-comment tsd-typography"><div class="tsd-tag-Default"><h4 class="tsd-anchor-link"><a id="Default-6" class="tsd-anchor"></a>Default<a href="#Default-6" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h4><pre><code class="ts"><span class="hl-3">null</span> </code><button type="button">Copy</button></pre> -</div></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/a119240a17591a50176ef162e77d4305ebda73bd/src/jsonpath.d.ts#L120">jsonpath.d.ts:120</a></li></ul></aside></section><section class="tsd-panel tsd-member"><a id="parentProperty" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><code class="tsd-tag">Optional</code><span>parent<wbr/>Property</span><a href="#parentProperty" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><div class="tsd-signature"><span class="tsd-kind-property">parent<wbr/>Property</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">any</span></div><div class="tsd-comment tsd-typography"><p>In the event that a query could be made to return the root node, +</div></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/39ee1844c610f9fd8925d3095ed3971e3d48025e/src/jsonpath.d.ts#L120">jsonpath.d.ts:120</a></li></ul></aside></section><section class="tsd-panel tsd-member"><a id="parentProperty" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><code class="tsd-tag">Optional</code><span>parent<wbr/>Property</span><a href="#parentProperty" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><div class="tsd-signature"><span class="tsd-kind-property">parent<wbr/>Property</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">any</span></div><div class="tsd-comment tsd-typography"><p>In the event that a query could be made to return the root node, this allows the parentProperty of that root node to be returned within results.</p> </div><div class="tsd-comment tsd-typography"><div class="tsd-tag-Default"><h4 class="tsd-anchor-link"><a id="Default-7" class="tsd-anchor"></a>Default<a href="#Default-7" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h4><pre><code class="ts"><span class="hl-3">null</span> </code><button type="button">Copy</button></pre> -</div></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/a119240a17591a50176ef162e77d4305ebda73bd/src/jsonpath.d.ts#L128">jsonpath.d.ts:128</a></li></ul></aside></section><section class="tsd-panel tsd-member"><a id="path" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span>path</span><a href="#path" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><div class="tsd-signature"><span class="tsd-kind-property">path</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">[]</span></div><div class="tsd-comment tsd-typography"><p>The JSONPath expression as a (normalized or unnormalized) string or +</div></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/39ee1844c610f9fd8925d3095ed3971e3d48025e/src/jsonpath.d.ts#L128">jsonpath.d.ts:128</a></li></ul></aside></section><section class="tsd-panel tsd-member"><a id="path" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span>path</span><a href="#path" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><div class="tsd-signature"><span class="tsd-kind-property">path</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">[]</span></div><div class="tsd-comment tsd-typography"><p>The JSONPath expression as a (normalized or unnormalized) string or array.</p> -</div><div class="tsd-comment tsd-typography"></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/a119240a17591a50176ef162e77d4305ebda73bd/src/jsonpath.d.ts#L21">jsonpath.d.ts:21</a></li></ul></aside></section><section class="tsd-panel tsd-member"><a id="resultType" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><code class="tsd-tag">Optional</code><span>result<wbr/>Type</span><a href="#resultType" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><div class="tsd-signature"><span class="tsd-kind-property">result<wbr/>Type</span><span class="tsd-signature-symbol">?:</span> <br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">"value"</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">"path"</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">"pointer"</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">"parent"</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">"parentProperty"</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">"all"</span></div><div class="tsd-comment tsd-typography"><p>Can be case-insensitive form of "value", "path", "pointer", "parent", +</div><div class="tsd-comment tsd-typography"></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/39ee1844c610f9fd8925d3095ed3971e3d48025e/src/jsonpath.d.ts#L21">jsonpath.d.ts:21</a></li></ul></aside></section><section class="tsd-panel tsd-member"><a id="resultType" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><code class="tsd-tag">Optional</code><span>result<wbr/>Type</span><a href="#resultType" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><div class="tsd-signature"><span class="tsd-kind-property">result<wbr/>Type</span><span class="tsd-signature-symbol">?:</span> <br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">"value"</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">"path"</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">"pointer"</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">"parent"</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">"parentProperty"</span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">"all"</span></div><div class="tsd-comment tsd-typography"><p>Can be case-insensitive form of "value", "path", "pointer", "parent", or "parentProperty" to determine respectively whether to return results as the values of the found items, as their absolute paths, as JSON Pointers to the absolute paths, as their parent objects, @@ -86,11 +86,11 @@ </div><div class="tsd-comment tsd-typography"><div class="tsd-tag-Default"><h4 class="tsd-anchor-link"><a id="Default-8" class="tsd-anchor"></a>Default<a href="#Default-8" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h4><pre><code class="ts"><span class="hl-2">'value'</span> </code><button type="button">Copy</button></pre> -</div></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/a119240a17591a50176ef162e77d4305ebda73bd/src/jsonpath.d.ts#L53">jsonpath.d.ts:53</a></li></ul></aside></section><section class="tsd-panel tsd-member"><a id="sandbox" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><code class="tsd-tag">Optional</code><span>sandbox</span><a href="#sandbox" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><div class="tsd-signature"><span class="tsd-kind-property">sandbox</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">Map</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">></span></div><div class="tsd-comment tsd-typography"><p>Key-value map of variables to be available to code evaluations such +</div></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/39ee1844c610f9fd8925d3095ed3971e3d48025e/src/jsonpath.d.ts#L53">jsonpath.d.ts:53</a></li></ul></aside></section><section class="tsd-panel tsd-member"><a id="sandbox" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><code class="tsd-tag">Optional</code><span>sandbox</span><a href="#sandbox" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><div class="tsd-signature"><span class="tsd-kind-property">sandbox</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">Map</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">></span></div><div class="tsd-comment tsd-typography"><p>Key-value map of variables to be available to code evaluations such as filtering expressions. (Note that the current path and value will also be available to those expressions; see the Syntax section for details.)</p> -</div><div class="tsd-comment tsd-typography"></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/a119240a17591a50176ef162e77d4305ebda73bd/src/jsonpath.d.ts#L62">jsonpath.d.ts:62</a></li></ul></aside></section><section class="tsd-panel tsd-member"><a id="wrap" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><code class="tsd-tag">Optional</code><span>wrap</span><a href="#wrap" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><div class="tsd-signature"><span class="tsd-kind-property">wrap</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">boolean</span></div><div class="tsd-comment tsd-typography"><p>Whether or not to wrap the results in an array.</p> +</div><div class="tsd-comment tsd-typography"></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/39ee1844c610f9fd8925d3095ed3971e3d48025e/src/jsonpath.d.ts#L62">jsonpath.d.ts:62</a></li></ul></aside></section><section class="tsd-panel tsd-member"><a id="wrap" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><code class="tsd-tag">Optional</code><span>wrap</span><a href="#wrap" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><div class="tsd-signature"><span class="tsd-kind-property">wrap</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">boolean</span></div><div class="tsd-comment tsd-typography"><p>Whether or not to wrap the results in an array.</p> <p>If wrap is set to false, and no results are found, undefined will be returned (as opposed to an empty array when wrap is set to true).</p> <p>If wrap is set to false and a single non-array result is found, that @@ -102,4 +102,4 @@ </div><div class="tsd-comment tsd-typography"><div class="tsd-tag-Default"><h4 class="tsd-anchor-link"><a id="Default-9" class="tsd-anchor"></a>Default<a href="#Default-9" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h4><pre><code class="ts"><span class="hl-3">true</span> </code><button type="button">Copy</button></pre> -</div></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/a119240a17591a50176ef162e77d4305ebda73bd/src/jsonpath.d.ts#L79">jsonpath.d.ts:79</a></li></ul></aside></section></section></details></div><div class="col-sidebar"><div class="page-menu"><div class="tsd-navigation settings"><details class="tsd-accordion"><summary class="tsd-accordion-summary"><h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Settings</h3></summary><div class="tsd-accordion-details"><div class="tsd-filter-visibility"><span class="settings-label">Member Visibility</span><ul id="tsd-filter-options"><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-protected" name="protected"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Protected</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-inherited" name="inherited" checked/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Inherited</span></label></li></ul></div><div class="tsd-theme-toggle"><label class="settings-label" for="tsd-theme">Theme</label><select id="tsd-theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div><details open class="tsd-accordion tsd-page-navigation"><summary class="tsd-accordion-summary"><h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>On This Page</h3></summary><div class="tsd-accordion-details"><details open class="tsd-accordion tsd-page-navigation-section"><summary class="tsd-accordion-summary" data-key="tsd-otp-Properties"><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Properties</summary><div><a href="#autostart" class=""><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1024"></use></svg><span>autostart</span></a><a href="#callback" class=""><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1024"></use></svg><span>callback</span></a><a href="#eval" class=""><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1024"></use></svg><span>eval</span></a><a href="#flatten" class=""><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1024"></use></svg><span>flatten</span></a><a href="#ignoreEvalErrors" class=""><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1024"></use></svg><span>ignore<wbr/>Eval<wbr/>Errors</span></a><a href="#json" class=""><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1024"></use></svg><span>json</span></a><a href="#otherTypeCallback" class=""><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1024"></use></svg><span>other<wbr/>Type<wbr/>Callback</span></a><a href="#parent" class=""><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1024"></use></svg><span>parent</span></a><a href="#parentProperty" class=""><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1024"></use></svg><span>parent<wbr/>Property</span></a><a href="#path" class=""><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1024"></use></svg><span>path</span></a><a href="#resultType" class=""><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1024"></use></svg><span>result<wbr/>Type</span></a><a href="#sandbox" class=""><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1024"></use></svg><span>sandbox</span></a><a href="#wrap" class=""><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1024"></use></svg><span>wrap</span></a></div></details></div></details></div><div class="site-menu"><nav class="tsd-navigation"><a href="../modules.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1"></use></svg><span>jsonpath-plus</span></a><ul class="tsd-small-nested-navigation" id="tsd-nav-container" data-base=".."><li>Loading...</li></ul></nav></div></div></div><footer><p class="tsd-generator">Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></footer><div class="overlay"></div></body></html> +</div></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/39ee1844c610f9fd8925d3095ed3971e3d48025e/src/jsonpath.d.ts#L79">jsonpath.d.ts:79</a></li></ul></aside></section></section></details></div><div class="col-sidebar"><div class="page-menu"><div class="tsd-navigation settings"><details class="tsd-accordion"><summary class="tsd-accordion-summary"><h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Settings</h3></summary><div class="tsd-accordion-details"><div class="tsd-filter-visibility"><span class="settings-label">Member Visibility</span><ul id="tsd-filter-options"><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-protected" name="protected"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Protected</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-inherited" name="inherited" checked/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Inherited</span></label></li></ul></div><div class="tsd-theme-toggle"><label class="settings-label" for="tsd-theme">Theme</label><select id="tsd-theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div><details open class="tsd-accordion tsd-page-navigation"><summary class="tsd-accordion-summary"><h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>On This Page</h3></summary><div class="tsd-accordion-details"><details open class="tsd-accordion tsd-page-navigation-section"><summary class="tsd-accordion-summary" data-key="tsd-otp-Properties"><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Properties</summary><div><a href="#autostart" class=""><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1024"></use></svg><span>autostart</span></a><a href="#callback" class=""><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1024"></use></svg><span>callback</span></a><a href="#eval" class=""><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1024"></use></svg><span>eval</span></a><a href="#flatten" class=""><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1024"></use></svg><span>flatten</span></a><a href="#ignoreEvalErrors" class=""><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1024"></use></svg><span>ignore<wbr/>Eval<wbr/>Errors</span></a><a href="#json" class=""><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1024"></use></svg><span>json</span></a><a href="#otherTypeCallback" class=""><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1024"></use></svg><span>other<wbr/>Type<wbr/>Callback</span></a><a href="#parent" class=""><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1024"></use></svg><span>parent</span></a><a href="#parentProperty" class=""><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1024"></use></svg><span>parent<wbr/>Property</span></a><a href="#path" class=""><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1024"></use></svg><span>path</span></a><a href="#resultType" class=""><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1024"></use></svg><span>result<wbr/>Type</span></a><a href="#sandbox" class=""><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1024"></use></svg><span>sandbox</span></a><a href="#wrap" class=""><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1024"></use></svg><span>wrap</span></a></div></details></div></details></div><div class="site-menu"><nav class="tsd-navigation"><a href="../modules.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1"></use></svg><span>jsonpath-plus</span></a><ul class="tsd-small-nested-navigation" id="tsd-nav-container" data-base=".."><li>Loading...</li></ul></nav></div></div></div><footer><p class="tsd-generator">Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></footer><div class="overlay"></div></body></html>
docs/ts/types/JSONPathCallback.html+1 −1 modified@@ -1 +1 @@ -<!DOCTYPE html><html class="default" lang="en"><head><meta charset="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>JSONPathCallback | jsonpath-plus</title><meta name="description" content="Documentation for jsonpath-plus"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script defer src="../assets/main.js"></script><script async src="../assets/icons.js" id="tsd-icons-script"></script><script async src="../assets/search.js" id="tsd-search-script"></script><script async src="../assets/navigation.js" id="tsd-nav-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><div class="table-cell" id="tsd-search" data-base=".."><div class="field"><label for="tsd-search-field" class="tsd-widget tsd-toolbar-icon search no-caption"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-search"></use></svg></label><input type="text" id="tsd-search-field" aria-label="Search"/></div><div class="field"><div id="tsd-toolbar-links"></div></div><ul class="results"><li class="state loading">Preparing search index...</li><li class="state failure">The search index is not available</li></ul><a href="../index.html" class="title">jsonpath-plus</a></div><div class="table-cell" id="tsd-widgets"><a href="#" class="tsd-widget tsd-toolbar-icon menu no-caption" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-menu"></use></svg></a></div></div></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><ul class="tsd-breadcrumb"><li><a href="../modules.html">jsonpath-plus</a></li><li><a href="JSONPathCallback.html">JSONPathCallback</a></li></ul><h1>Type Alias JSONPathCallback</h1></div><div class="tsd-signature"><span class="tsd-kind-type-alias">JSONPath<wbr/>Callback</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">payload</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">any</span>, <span class="tsd-kind-parameter">payloadType</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">any</span>, <span class="tsd-kind-parameter">fullPayload</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol"> => </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">)</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/a119240a17591a50176ef162e77d4305ebda73bd/src/jsonpath.d.ts#L5">jsonpath.d.ts:5</a></li></ul></aside></div><div class="col-sidebar"><div class="page-menu"><div class="tsd-navigation settings"><details class="tsd-accordion"><summary class="tsd-accordion-summary"><h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Settings</h3></summary><div class="tsd-accordion-details"><div class="tsd-filter-visibility"><span class="settings-label">Member Visibility</span><ul id="tsd-filter-options"><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-protected" name="protected"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Protected</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-inherited" name="inherited" checked/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Inherited</span></label></li></ul></div><div class="tsd-theme-toggle"><label class="settings-label" for="tsd-theme">Theme</label><select id="tsd-theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div></div><div class="site-menu"><nav class="tsd-navigation"><a href="../modules.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1"></use></svg><span>jsonpath-plus</span></a><ul class="tsd-small-nested-navigation" id="tsd-nav-container" data-base=".."><li>Loading...</li></ul></nav></div></div></div><footer><p class="tsd-generator">Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></footer><div class="overlay"></div></body></html> +<!DOCTYPE html><html class="default" lang="en"><head><meta charset="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>JSONPathCallback | jsonpath-plus</title><meta name="description" content="Documentation for jsonpath-plus"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script defer src="../assets/main.js"></script><script async src="../assets/icons.js" id="tsd-icons-script"></script><script async src="../assets/search.js" id="tsd-search-script"></script><script async src="../assets/navigation.js" id="tsd-nav-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><div class="table-cell" id="tsd-search" data-base=".."><div class="field"><label for="tsd-search-field" class="tsd-widget tsd-toolbar-icon search no-caption"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-search"></use></svg></label><input type="text" id="tsd-search-field" aria-label="Search"/></div><div class="field"><div id="tsd-toolbar-links"></div></div><ul class="results"><li class="state loading">Preparing search index...</li><li class="state failure">The search index is not available</li></ul><a href="../index.html" class="title">jsonpath-plus</a></div><div class="table-cell" id="tsd-widgets"><a href="#" class="tsd-widget tsd-toolbar-icon menu no-caption" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-menu"></use></svg></a></div></div></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><ul class="tsd-breadcrumb"><li><a href="../modules.html">jsonpath-plus</a></li><li><a href="JSONPathCallback.html">JSONPathCallback</a></li></ul><h1>Type Alias JSONPathCallback</h1></div><div class="tsd-signature"><span class="tsd-kind-type-alias">JSONPath<wbr/>Callback</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">payload</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">any</span>, <span class="tsd-kind-parameter">payloadType</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">any</span>, <span class="tsd-kind-parameter">fullPayload</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol"> => </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">)</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/39ee1844c610f9fd8925d3095ed3971e3d48025e/src/jsonpath.d.ts#L5">jsonpath.d.ts:5</a></li></ul></aside></div><div class="col-sidebar"><div class="page-menu"><div class="tsd-navigation settings"><details class="tsd-accordion"><summary class="tsd-accordion-summary"><h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Settings</h3></summary><div class="tsd-accordion-details"><div class="tsd-filter-visibility"><span class="settings-label">Member Visibility</span><ul id="tsd-filter-options"><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-protected" name="protected"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Protected</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-inherited" name="inherited" checked/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Inherited</span></label></li></ul></div><div class="tsd-theme-toggle"><label class="settings-label" for="tsd-theme">Theme</label><select id="tsd-theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div></div><div class="site-menu"><nav class="tsd-navigation"><a href="../modules.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1"></use></svg><span>jsonpath-plus</span></a><ul class="tsd-small-nested-navigation" id="tsd-nav-container" data-base=".."><li>Loading...</li></ul></nav></div></div></div><footer><p class="tsd-generator">Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></footer><div class="overlay"></div></body></html>
docs/ts/types/JSONPathOtherTypeCallback.html+1 −1 modified@@ -1 +1 @@ -<!DOCTYPE html><html class="default" lang="en"><head><meta charset="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>JSONPathOtherTypeCallback | jsonpath-plus</title><meta name="description" content="Documentation for jsonpath-plus"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script defer src="../assets/main.js"></script><script async src="../assets/icons.js" id="tsd-icons-script"></script><script async src="../assets/search.js" id="tsd-search-script"></script><script async src="../assets/navigation.js" id="tsd-nav-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><div class="table-cell" id="tsd-search" data-base=".."><div class="field"><label for="tsd-search-field" class="tsd-widget tsd-toolbar-icon search no-caption"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-search"></use></svg></label><input type="text" id="tsd-search-field" aria-label="Search"/></div><div class="field"><div id="tsd-toolbar-links"></div></div><ul class="results"><li class="state loading">Preparing search index...</li><li class="state failure">The search index is not available</li></ul><a href="../index.html" class="title">jsonpath-plus</a></div><div class="table-cell" id="tsd-widgets"><a href="#" class="tsd-widget tsd-toolbar-icon menu no-caption" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-menu"></use></svg></a></div></div></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><ul class="tsd-breadcrumb"><li><a href="../modules.html">jsonpath-plus</a></li><li><a href="JSONPathOtherTypeCallback.html">JSONPathOtherTypeCallback</a></li></ul><h1>Type Alias JSONPathOtherTypeCallback</h1></div><div class="tsd-signature"><span class="tsd-kind-type-alias">JSONPath<wbr/>Other<wbr/>Type<wbr/>Callback</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">...</span><span class="tsd-kind-parameter">args</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol"> => </span><span class="tsd-signature-type">void</span><span class="tsd-signature-symbol">)</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/a119240a17591a50176ef162e77d4305ebda73bd/src/jsonpath.d.ts#L9">jsonpath.d.ts:9</a></li></ul></aside></div><div class="col-sidebar"><div class="page-menu"><div class="tsd-navigation settings"><details class="tsd-accordion"><summary class="tsd-accordion-summary"><h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Settings</h3></summary><div class="tsd-accordion-details"><div class="tsd-filter-visibility"><span class="settings-label">Member Visibility</span><ul id="tsd-filter-options"><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-protected" name="protected"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Protected</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-inherited" name="inherited" checked/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Inherited</span></label></li></ul></div><div class="tsd-theme-toggle"><label class="settings-label" for="tsd-theme">Theme</label><select id="tsd-theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div></div><div class="site-menu"><nav class="tsd-navigation"><a href="../modules.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1"></use></svg><span>jsonpath-plus</span></a><ul class="tsd-small-nested-navigation" id="tsd-nav-container" data-base=".."><li>Loading...</li></ul></nav></div></div></div><footer><p class="tsd-generator">Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></footer><div class="overlay"></div></body></html> +<!DOCTYPE html><html class="default" lang="en"><head><meta charset="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>JSONPathOtherTypeCallback | jsonpath-plus</title><meta name="description" content="Documentation for jsonpath-plus"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script defer src="../assets/main.js"></script><script async src="../assets/icons.js" id="tsd-icons-script"></script><script async src="../assets/search.js" id="tsd-search-script"></script><script async src="../assets/navigation.js" id="tsd-nav-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><div class="table-cell" id="tsd-search" data-base=".."><div class="field"><label for="tsd-search-field" class="tsd-widget tsd-toolbar-icon search no-caption"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-search"></use></svg></label><input type="text" id="tsd-search-field" aria-label="Search"/></div><div class="field"><div id="tsd-toolbar-links"></div></div><ul class="results"><li class="state loading">Preparing search index...</li><li class="state failure">The search index is not available</li></ul><a href="../index.html" class="title">jsonpath-plus</a></div><div class="table-cell" id="tsd-widgets"><a href="#" class="tsd-widget tsd-toolbar-icon menu no-caption" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-menu"></use></svg></a></div></div></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><ul class="tsd-breadcrumb"><li><a href="../modules.html">jsonpath-plus</a></li><li><a href="JSONPathOtherTypeCallback.html">JSONPathOtherTypeCallback</a></li></ul><h1>Type Alias JSONPathOtherTypeCallback</h1></div><div class="tsd-signature"><span class="tsd-kind-type-alias">JSONPath<wbr/>Other<wbr/>Type<wbr/>Callback</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">...</span><span class="tsd-kind-parameter">args</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol"> => </span><span class="tsd-signature-type">void</span><span class="tsd-signature-symbol">)</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/39ee1844c610f9fd8925d3095ed3971e3d48025e/src/jsonpath.d.ts#L9">jsonpath.d.ts:9</a></li></ul></aside></div><div class="col-sidebar"><div class="page-menu"><div class="tsd-navigation settings"><details class="tsd-accordion"><summary class="tsd-accordion-summary"><h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Settings</h3></summary><div class="tsd-accordion-details"><div class="tsd-filter-visibility"><span class="settings-label">Member Visibility</span><ul id="tsd-filter-options"><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-protected" name="protected"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Protected</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-inherited" name="inherited" checked/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Inherited</span></label></li></ul></div><div class="tsd-theme-toggle"><label class="settings-label" for="tsd-theme">Theme</label><select id="tsd-theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div></div><div class="site-menu"><nav class="tsd-navigation"><a href="../modules.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1"></use></svg><span>jsonpath-plus</span></a><ul class="tsd-small-nested-navigation" id="tsd-nav-container" data-base=".."><li>Loading...</li></ul></nav></div></div></div><footer><p class="tsd-generator">Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></footer><div class="overlay"></div></body></html>
docs/ts/types/JSONPathType.html+1 −1 modified@@ -1 +1 @@ -<!DOCTYPE html><html class="default" lang="en"><head><meta charset="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>JSONPathType | jsonpath-plus</title><meta name="description" content="Documentation for jsonpath-plus"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script defer src="../assets/main.js"></script><script async src="../assets/icons.js" id="tsd-icons-script"></script><script async src="../assets/search.js" id="tsd-search-script"></script><script async src="../assets/navigation.js" id="tsd-nav-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><div class="table-cell" id="tsd-search" data-base=".."><div class="field"><label for="tsd-search-field" class="tsd-widget tsd-toolbar-icon search no-caption"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-search"></use></svg></label><input type="text" id="tsd-search-field" aria-label="Search"/></div><div class="field"><div id="tsd-toolbar-links"></div></div><ul class="results"><li class="state loading">Preparing search index...</li><li class="state failure">The search index is not available</li></ul><a href="../index.html" class="title">jsonpath-plus</a></div><div class="table-cell" id="tsd-widgets"><a href="#" class="tsd-widget tsd-toolbar-icon menu no-caption" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-menu"></use></svg></a></div></div></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><ul class="tsd-breadcrumb"><li><a href="../modules.html">jsonpath-plus</a></li><li><a href="JSONPathType.html">JSONPathType</a></li></ul><h1>Type Alias JSONPathType</h1></div><div class="tsd-signature"><span class="tsd-kind-type-alias">JSONPath<wbr/>Type</span><span class="tsd-signature-symbol">:</span> <a href="../interfaces/JSONPathCallable.html" class="tsd-signature-type tsd-kind-interface">JSONPathCallable</a><span class="tsd-signature-symbol"> & </span><a href="../classes/JSONPathClass.html" class="tsd-signature-type tsd-kind-class">JSONPathClass</a></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/a119240a17591a50176ef162e77d4305ebda73bd/src/jsonpath.d.ts#L223">jsonpath.d.ts:223</a></li></ul></aside></div><div class="col-sidebar"><div class="page-menu"><div class="tsd-navigation settings"><details class="tsd-accordion"><summary class="tsd-accordion-summary"><h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Settings</h3></summary><div class="tsd-accordion-details"><div class="tsd-filter-visibility"><span class="settings-label">Member Visibility</span><ul id="tsd-filter-options"><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-protected" name="protected"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Protected</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-inherited" name="inherited" checked/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Inherited</span></label></li></ul></div><div class="tsd-theme-toggle"><label class="settings-label" for="tsd-theme">Theme</label><select id="tsd-theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div></div><div class="site-menu"><nav class="tsd-navigation"><a href="../modules.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1"></use></svg><span>jsonpath-plus</span></a><ul class="tsd-small-nested-navigation" id="tsd-nav-container" data-base=".."><li>Loading...</li></ul></nav></div></div></div><footer><p class="tsd-generator">Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></footer><div class="overlay"></div></body></html> +<!DOCTYPE html><html class="default" lang="en"><head><meta charset="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>JSONPathType | jsonpath-plus</title><meta name="description" content="Documentation for jsonpath-plus"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script defer src="../assets/main.js"></script><script async src="../assets/icons.js" id="tsd-icons-script"></script><script async src="../assets/search.js" id="tsd-search-script"></script><script async src="../assets/navigation.js" id="tsd-nav-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><div class="table-cell" id="tsd-search" data-base=".."><div class="field"><label for="tsd-search-field" class="tsd-widget tsd-toolbar-icon search no-caption"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-search"></use></svg></label><input type="text" id="tsd-search-field" aria-label="Search"/></div><div class="field"><div id="tsd-toolbar-links"></div></div><ul class="results"><li class="state loading">Preparing search index...</li><li class="state failure">The search index is not available</li></ul><a href="../index.html" class="title">jsonpath-plus</a></div><div class="table-cell" id="tsd-widgets"><a href="#" class="tsd-widget tsd-toolbar-icon menu no-caption" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-menu"></use></svg></a></div></div></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><ul class="tsd-breadcrumb"><li><a href="../modules.html">jsonpath-plus</a></li><li><a href="JSONPathType.html">JSONPathType</a></li></ul><h1>Type Alias JSONPathType</h1></div><div class="tsd-signature"><span class="tsd-kind-type-alias">JSONPath<wbr/>Type</span><span class="tsd-signature-symbol">:</span> <a href="../interfaces/JSONPathCallable.html" class="tsd-signature-type tsd-kind-interface">JSONPathCallable</a><span class="tsd-signature-symbol"> & </span><a href="../classes/JSONPathClass.html" class="tsd-signature-type tsd-kind-class">JSONPathClass</a></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/80avin/JSONPath/blob/39ee1844c610f9fd8925d3095ed3971e3d48025e/src/jsonpath.d.ts#L223">jsonpath.d.ts:223</a></li></ul></aside></div><div class="col-sidebar"><div class="page-menu"><div class="tsd-navigation settings"><details class="tsd-accordion"><summary class="tsd-accordion-summary"><h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Settings</h3></summary><div class="tsd-accordion-details"><div class="tsd-filter-visibility"><span class="settings-label">Member Visibility</span><ul id="tsd-filter-options"><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-protected" name="protected"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Protected</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-inherited" name="inherited" checked/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Inherited</span></label></li></ul></div><div class="tsd-theme-toggle"><label class="settings-label" for="tsd-theme">Theme</label><select id="tsd-theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div></div><div class="site-menu"><nav class="tsd-navigation"><a href="../modules.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1"></use></svg><span>jsonpath-plus</span></a><ul class="tsd-small-nested-navigation" id="tsd-nav-container" data-base=".."><li>Loading...</li></ul></nav></div></div></div><footer><p class="tsd-generator">Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></footer><div class="overlay"></div></body></html>
src/Safe-Script.js+24 −33 modified@@ -9,6 +9,13 @@ jsep.addUnaryOp('typeof'); jsep.addLiteral('null', null); jsep.addLiteral('undefined', undefined); +const BLOCKED_PROTO_PROPERTIES = new Set([ + 'constructor', + '__proto__', + '__defineGetter__', + '__defineSetter__' +]); + const SafeEval = { /** * @param {jsep.Expression} ast @@ -66,10 +73,7 @@ const SafeEval = { '*': (a, b) => a * b(), '/': (a, b) => a / b(), '%': (a, b) => a % b() - }[ast.operator]( - SafeEval.evalAst(ast.left, subs), - () => SafeEval.evalAst(ast.right, subs) - ); + }[ast.operator](SafeEval.evalAst(ast.left, subs), () => SafeEval.evalAst(ast.right, subs)); return result; }, evalCompound (ast, subs) { @@ -99,7 +103,7 @@ const SafeEval = { return SafeEval.evalAst(ast.alternate, subs); }, evalIdentifier (ast, subs) { - if (ast.name in subs) { + if (Object.hasOwn(subs, ast.name)) { return subs[ast.name]; } throw ReferenceError(`${ast.name} is not defined`); @@ -108,33 +112,22 @@ const SafeEval = { return ast.value; }, evalMemberExpression (ast, subs) { - if ( - (ast.property.type === 'Identifier' && - ast.property.name === 'constructor') || - (ast.object.type === 'Identifier' && - ast.object.name === 'constructor') - ) { - throw new Error("'constructor' property is disabled"); - } - const prop = ast.computed ? SafeEval.evalAst(ast.property) // `object[property]` : ast.property.name; // `object.property` property is Identifier const obj = SafeEval.evalAst(ast.object, subs); + if (obj === undefined || obj === null) { + throw TypeError( + `Cannot read properties of ${obj} (reading '${prop}')` + ); + } + if (!Object.hasOwn(obj, prop) && BLOCKED_PROTO_PROPERTIES.has(prop)) { + throw TypeError( + `Cannot read properties of ${obj} (reading '${prop}')` + ); + } const result = obj[prop]; if (typeof result === 'function') { - if (obj === Function && prop === 'bind') { - throw new Error('Function.prototype.bind is disabled'); - } - if (obj === Function && (prop === 'call' || prop === 'apply')) { - throw new Error( - 'Function.prototype.call and ' + - 'Function.prototype.apply are disabled' - ); - } - if (result === Function) { - return result; // Don't bind so can identify and throw later - } return result.bind(obj); // arrow functions aren't affected by bind. } return result; @@ -156,19 +149,16 @@ const SafeEval = { evalCallExpression (ast, subs) { const args = ast.arguments.map((arg) => SafeEval.evalAst(arg, subs)); const func = SafeEval.evalAst(ast.callee, subs); - if (func === Function) { - throw new Error('Function constructor is disabled'); - } + // if (func === Function) { + // throw new Error('Function constructor is disabled'); + // } return func(...args); }, evalAssignmentExpression (ast, subs) { if (ast.left.type !== 'Identifier') { throw SyntaxError('Invalid left-hand side in assignment'); } const id = ast.left.name; - if (id === '__proto__') { - throw new Error('Assignment to __proto__ is disabled'); - } const value = SafeEval.evalAst(ast.right, subs); subs[id] = value; return subs[id]; @@ -193,7 +183,8 @@ class SafeScript { * @returns {EvaluatedResult} Result of evaluated code */ runInNewContext (context) { - const keyMap = {...context}; + // `Object.create(null)` creates a prototypeless object + const keyMap = Object.assign(Object.create(null), context); return SafeEval.evalAst(this.ast, keyMap); } }
test/test.safe-eval.js+46 −0 modified@@ -245,5 +245,51 @@ checkBuiltInVMAndNodeVM(function (vmType, setBuiltInState) { }); } }); + + describe('security tests', () => { + it('issue #226 1', () => { + assert.throws(() => { + jsonpath({ + path: String.raw`$[?(var _$_root=[].constructor.constructor("console.log(this.process.mainModule.require(\"child_process\").execSync(\"id\").toString())");@root())]`, + json: {a: 'x'} + }); + }, "Cannot read properties of (reading 'constructor')"); + }); + + it('issue #226 2', () => { + assert.throws(() => { + const pathDoS = + "$[?(con = constructor; dp = con.defineProperty; gopd = con.getOwnPropertyDescriptor; f = gopd(con, 'entries').value; alt = gopd(con.getPrototypeOf(f), 'apply'); dp(con.getPrototypeOf(_$_root.body), 'toString', alt);)]"; + + const result = jsonpath({ + json: { + referrer: { + value: 'https://authorized.com', + writable: true + }, + method: { + value: 'POST', + writable: true + }, + body: { + value: 'Hello, World!', + writable: true + } + }, + path: pathDoS + }); + + result.toString(); // DoS + }, 'constructor is not defined'); + }); + + it('issue #226 3', () => { + assert.throws(() => { + const path = + "$[?(__proto__ = 0; __proto__ = constructor; __proto__ = constructor; __proto__(\"process.mainModule.require('child_process').execSync('open /Users/andrea');\")())]"; + jsonpath({json: {x: 1}, path}); + }, 'constructor is not defined'); + }); + }); }); });
b70aa713553cfix(security): prevent `constructor` access in safe vm
14 files changed · +54 −6
badges/coverage-badge.svg+1 −1 modified@@ -1 +1 @@ -<svg xmlns="http://www.w3.org/2000/svg" width="417" height="20"><defs><style>text{font-size:11px;font-family:Verdana,DejaVu Sans,Geneva,sans-serif}text.shadow{fill:#010101;fill-opacity:.3}text.high{fill:#fff}</style><linearGradient id="smooth" x2="0" y2="100%"><stop offset="0" stop-color="#aaa" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><mask id="round"><rect width="100%" height="100%" rx="3" fill="#fff"/></mask></defs><g id="bg" mask="url(#round)"><path fill="orange" stroke="#000" d="M0 0h120v20H0zM120 0h109v20H120zM229 0h87v20h-87z"/><path fill="green" stroke="#000" d="M316 0h101v20H316z"/><path fill="url(#smooth)" d="M0 0h417v20H0z"/></g><g id="fg"><text class="shadow" x="5.5" y="15">Statements 98.83%</text><text class="high" x="5" y="14">Statements 98.83%</text><text class="shadow" x="125.5" y="15">Branches 98.04%</text><text class="high" x="125" y="14">Branches 98.04%</text><text class="shadow" x="234.5" y="15">Lines 98.83%</text><text class="high" x="234" y="14">Lines 98.83%</text><text class="shadow" x="321.5" y="15">Functions 100%</text><text class="high" x="321" y="14">Functions 100%</text></g></svg> +<svg xmlns="http://www.w3.org/2000/svg" width="417" height="20"><defs><style>text{font-size:11px;font-family:Verdana,DejaVu Sans,Geneva,sans-serif}text.shadow{fill:#010101;fill-opacity:.3}text.high{fill:#fff}</style><linearGradient id="smooth" x2="0" y2="100%"><stop offset="0" stop-color="#aaa" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><mask id="round"><rect width="100%" height="100%" rx="3" fill="#fff"/></mask></defs><g id="bg" mask="url(#round)"><path fill="orange" stroke="#000" d="M0 0h120v20H0zM120 0h109v20H120zM229 0h87v20h-87z"/><path fill="green" stroke="#000" d="M316 0h101v20H316z"/><path fill="url(#smooth)" d="M0 0h417v20H0z"/></g><g id="fg"><text class="shadow" x="5.5" y="15">Statements 98.66%</text><text class="high" x="5" y="14">Statements 98.66%</text><text class="shadow" x="125.5" y="15">Branches 97.78%</text><text class="high" x="125" y="14">Branches 97.78%</text><text class="shadow" x="234.5" y="15">Lines 98.66%</text><text class="high" x="234" y="14">Lines 98.66%</text><text class="shadow" x="321.5" y="15">Functions 100%</text><text class="high" x="321" y="14">Functions 100%</text></g></svg>
CHANGES.md+5 −0 modified@@ -1,5 +1,10 @@ # CHANGES for jsonpath-plus +## 10.0.7 + +- fix(security): prevent `constructor` access +- docs: add security policy file + ## 10.0.6 - fix(security): prevent `call`/`apply` invocation of `Function`
dist/index-browser-esm.js+3 −0 modified@@ -1291,6 +1291,9 @@ const SafeEval = { return ast.value; }, evalMemberExpression(ast, subs) { + if (ast.property.type === 'Identifier' && ast.property.name === 'constructor' || ast.object.type === 'Identifier' && ast.object.name === 'constructor') { + throw new Error("'constructor' property is disabled"); + } const prop = ast.computed ? SafeEval.evalAst(ast.property) // `object[property]` : ast.property.name; // `object.property` property is Identifier const obj = SafeEval.evalAst(ast.object, subs);
dist/index-browser-esm.min.js+1 −1 modified@@ -1,2 +1,2 @@ -class e{static get version(){return"1.3.9"}static toString(){return"JavaScript Expression Parser (JSEP) v"+e.version}static addUnaryOp(t){return e.max_unop_len=Math.max(t.length,e.max_unop_len),e.unary_ops[t]=1,e}static addBinaryOp(t,r,s){return e.max_binop_len=Math.max(t.length,e.max_binop_len),e.binary_ops[t]=r,s?e.right_associative.add(t):e.right_associative.delete(t),e}static addIdentifierChar(t){return e.additional_identifier_chars.add(t),e}static addLiteral(t,r){return e.literals[t]=r,e}static removeUnaryOp(t){return delete e.unary_ops[t],t.length===e.max_unop_len&&(e.max_unop_len=e.getMaxKeyLen(e.unary_ops)),e}static removeAllUnaryOps(){return e.unary_ops={},e.max_unop_len=0,e}static removeIdentifierChar(t){return e.additional_identifier_chars.delete(t),e}static removeBinaryOp(t){return delete e.binary_ops[t],t.length===e.max_binop_len&&(e.max_binop_len=e.getMaxKeyLen(e.binary_ops)),e.right_associative.delete(t),e}static removeAllBinaryOps(){return e.binary_ops={},e.max_binop_len=0,e}static removeLiteral(t){return delete e.literals[t],e}static removeAllLiterals(){return e.literals={},e}get char(){return this.expr.charAt(this.index)}get code(){return this.expr.charCodeAt(this.index)}constructor(e){this.expr=e,this.index=0}static parse(t){return new e(t).parse()}static getMaxKeyLen(e){return Math.max(0,...Object.keys(e).map((e=>e.length)))}static isDecimalDigit(e){return e>=48&&e<=57}static binaryPrecedence(t){return e.binary_ops[t]||0}static isIdentifierStart(t){return t>=65&&t<=90||t>=97&&t<=122||t>=128&&!e.binary_ops[String.fromCharCode(t)]||e.additional_identifier_chars.has(String.fromCharCode(t))}static isIdentifierPart(t){return e.isIdentifierStart(t)||e.isDecimalDigit(t)}throwError(e){const t=new Error(e+" at character "+this.index);throw t.index=this.index,t.description=e,t}runHook(t,r){if(e.hooks[t]){const s={context:this,node:r};return e.hooks.run(t,s),s.node}return r}searchHook(t){if(e.hooks[t]){const r={context:this};return e.hooks[t].find((function(e){return e.call(r.context,r),r.node})),r.node}}gobbleSpaces(){let t=this.code;for(;t===e.SPACE_CODE||t===e.TAB_CODE||t===e.LF_CODE||t===e.CR_CODE;)t=this.expr.charCodeAt(++this.index);this.runHook("gobble-spaces")}parse(){this.runHook("before-all");const t=this.gobbleExpressions(),r=1===t.length?t[0]:{type:e.COMPOUND,body:t};return this.runHook("after-all",r)}gobbleExpressions(t){let r,s,i=[];for(;this.index<this.expr.length;)if(r=this.code,r===e.SEMCOL_CODE||r===e.COMMA_CODE)this.index++;else if(s=this.gobbleExpression())i.push(s);else if(this.index<this.expr.length){if(r===t)break;this.throwError('Unexpected "'+this.char+'"')}return i}gobbleExpression(){const e=this.searchHook("gobble-expression")||this.gobbleBinaryExpression();return this.gobbleSpaces(),this.runHook("after-expression",e)}gobbleBinaryOp(){this.gobbleSpaces();let t=this.expr.substr(this.index,e.max_binop_len),r=t.length;for(;r>0;){if(e.binary_ops.hasOwnProperty(t)&&(!e.isIdentifierStart(this.code)||this.index+t.length<this.expr.length&&!e.isIdentifierPart(this.expr.charCodeAt(this.index+t.length))))return this.index+=r,t;t=t.substr(0,--r)}return!1}gobbleBinaryExpression(){let t,r,s,i,n,o,a,h,l;if(o=this.gobbleToken(),!o)return o;if(r=this.gobbleBinaryOp(),!r)return o;for(n={value:r,prec:e.binaryPrecedence(r),right_a:e.right_associative.has(r)},a=this.gobbleToken(),a||this.throwError("Expected expression after "+r),i=[o,n,a];r=this.gobbleBinaryOp();){if(s=e.binaryPrecedence(r),0===s){this.index-=r.length;break}n={value:r,prec:s,right_a:e.right_associative.has(r)},l=r;const h=e=>n.right_a&&e.right_a?s>e.prec:s<=e.prec;for(;i.length>2&&h(i[i.length-2]);)a=i.pop(),r=i.pop().value,o=i.pop(),t={type:e.BINARY_EXP,operator:r,left:o,right:a},i.push(t);t=this.gobbleToken(),t||this.throwError("Expected expression after "+l),i.push(n,t)}for(h=i.length-1,t=i[h];h>1;)t={type:e.BINARY_EXP,operator:i[h-1].value,left:i[h-2],right:t},h-=2;return t}gobbleToken(){let t,r,s,i;if(this.gobbleSpaces(),i=this.searchHook("gobble-token"),i)return this.runHook("after-token",i);if(t=this.code,e.isDecimalDigit(t)||t===e.PERIOD_CODE)return this.gobbleNumericLiteral();if(t===e.SQUOTE_CODE||t===e.DQUOTE_CODE)i=this.gobbleStringLiteral();else if(t===e.OBRACK_CODE)i=this.gobbleArray();else{for(r=this.expr.substr(this.index,e.max_unop_len),s=r.length;s>0;){if(e.unary_ops.hasOwnProperty(r)&&(!e.isIdentifierStart(this.code)||this.index+r.length<this.expr.length&&!e.isIdentifierPart(this.expr.charCodeAt(this.index+r.length)))){this.index+=s;const t=this.gobbleToken();return t||this.throwError("missing unaryOp argument"),this.runHook("after-token",{type:e.UNARY_EXP,operator:r,argument:t,prefix:!0})}r=r.substr(0,--s)}e.isIdentifierStart(t)?(i=this.gobbleIdentifier(),e.literals.hasOwnProperty(i.name)?i={type:e.LITERAL,value:e.literals[i.name],raw:i.name}:i.name===e.this_str&&(i={type:e.THIS_EXP})):t===e.OPAREN_CODE&&(i=this.gobbleGroup())}return i?(i=this.gobbleTokenProperty(i),this.runHook("after-token",i)):this.runHook("after-token",!1)}gobbleTokenProperty(t){this.gobbleSpaces();let r=this.code;for(;r===e.PERIOD_CODE||r===e.OBRACK_CODE||r===e.OPAREN_CODE||r===e.QUMARK_CODE;){let s;if(r===e.QUMARK_CODE){if(this.expr.charCodeAt(this.index+1)!==e.PERIOD_CODE)break;s=!0,this.index+=2,this.gobbleSpaces(),r=this.code}this.index++,r===e.OBRACK_CODE?((t={type:e.MEMBER_EXP,computed:!0,object:t,property:this.gobbleExpression()}).property||this.throwError('Unexpected "'+this.char+'"'),this.gobbleSpaces(),r=this.code,r!==e.CBRACK_CODE&&this.throwError("Unclosed ["),this.index++):r===e.OPAREN_CODE?t={type:e.CALL_EXP,arguments:this.gobbleArguments(e.CPAREN_CODE),callee:t}:(r===e.PERIOD_CODE||s)&&(s&&this.index--,this.gobbleSpaces(),t={type:e.MEMBER_EXP,computed:!1,object:t,property:this.gobbleIdentifier()}),s&&(t.optional=!0),this.gobbleSpaces(),r=this.code}return t}gobbleNumericLiteral(){let t,r,s="";for(;e.isDecimalDigit(this.code);)s+=this.expr.charAt(this.index++);if(this.code===e.PERIOD_CODE)for(s+=this.expr.charAt(this.index++);e.isDecimalDigit(this.code);)s+=this.expr.charAt(this.index++);if(t=this.char,"e"===t||"E"===t){for(s+=this.expr.charAt(this.index++),t=this.char,"+"!==t&&"-"!==t||(s+=this.expr.charAt(this.index++));e.isDecimalDigit(this.code);)s+=this.expr.charAt(this.index++);e.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+s+this.char+")")}return r=this.code,e.isIdentifierStart(r)?this.throwError("Variable names cannot start with a number ("+s+this.char+")"):(r===e.PERIOD_CODE||1===s.length&&s.charCodeAt(0)===e.PERIOD_CODE)&&this.throwError("Unexpected period"),{type:e.LITERAL,value:parseFloat(s),raw:s}}gobbleStringLiteral(){let t="";const r=this.index,s=this.expr.charAt(this.index++);let i=!1;for(;this.index<this.expr.length;){let e=this.expr.charAt(this.index++);if(e===s){i=!0;break}if("\\"===e)switch(e=this.expr.charAt(this.index++),e){case"n":t+="\n";break;case"r":t+="\r";break;case"t":t+="\t";break;case"b":t+="\b";break;case"f":t+="\f";break;case"v":t+="\v";break;default:t+=e}else t+=e}return i||this.throwError('Unclosed quote after "'+t+'"'),{type:e.LITERAL,value:t,raw:this.expr.substring(r,this.index)}}gobbleIdentifier(){let t=this.code,r=this.index;for(e.isIdentifierStart(t)?this.index++:this.throwError("Unexpected "+this.char);this.index<this.expr.length&&(t=this.code,e.isIdentifierPart(t));)this.index++;return{type:e.IDENTIFIER,name:this.expr.slice(r,this.index)}}gobbleArguments(t){const r=[];let s=!1,i=0;for(;this.index<this.expr.length;){this.gobbleSpaces();let n=this.code;if(n===t){s=!0,this.index++,t===e.CPAREN_CODE&&i&&i>=r.length&&this.throwError("Unexpected token "+String.fromCharCode(t));break}if(n===e.COMMA_CODE){if(this.index++,i++,i!==r.length)if(t===e.CPAREN_CODE)this.throwError("Unexpected token ,");else if(t===e.CBRACK_CODE)for(let e=r.length;e<i;e++)r.push(null)}else if(r.length!==i&&0!==i)this.throwError("Expected comma");else{const t=this.gobbleExpression();t&&t.type!==e.COMPOUND||this.throwError("Expected comma"),r.push(t)}}return s||this.throwError("Expected "+String.fromCharCode(t)),r}gobbleGroup(){this.index++;let t=this.gobbleExpressions(e.CPAREN_CODE);if(this.code===e.CPAREN_CODE)return this.index++,1===t.length?t[0]:!!t.length&&{type:e.SEQUENCE_EXP,expressions:t};this.throwError("Unclosed (")}gobbleArray(){return this.index++,{type:e.ARRAY_EXP,elements:this.gobbleArguments(e.CBRACK_CODE)}}}const t=new class{add(e,t,r){if("string"!=typeof arguments[0])for(let e in arguments[0])this.add(e,arguments[0][e],arguments[1]);else(Array.isArray(e)?e:[e]).forEach((function(e){this[e]=this[e]||[],t&&this[e][r?"unshift":"push"](t)}),this)}run(e,t){this[e]=this[e]||[],this[e].forEach((function(e){e.call(t&&t.context?t.context:t,t)}))}};Object.assign(e,{hooks:t,plugins:new class{constructor(e){this.jsep=e,this.registered={}}register(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];t.forEach((e=>{if("object"!=typeof e||!e.name||!e.init)throw new Error("Invalid JSEP plugin format");this.registered[e.name]||(e.init(this.jsep),this.registered[e.name]=e)}))}}(e),COMPOUND:"Compound",SEQUENCE_EXP:"SequenceExpression",IDENTIFIER:"Identifier",MEMBER_EXP:"MemberExpression",LITERAL:"Literal",THIS_EXP:"ThisExpression",CALL_EXP:"CallExpression",UNARY_EXP:"UnaryExpression",BINARY_EXP:"BinaryExpression",ARRAY_EXP:"ArrayExpression",TAB_CODE:9,LF_CODE:10,CR_CODE:13,SPACE_CODE:32,PERIOD_CODE:46,COMMA_CODE:44,SQUOTE_CODE:39,DQUOTE_CODE:34,OPAREN_CODE:40,CPAREN_CODE:41,OBRACK_CODE:91,CBRACK_CODE:93,QUMARK_CODE:63,SEMCOL_CODE:59,COLON_CODE:58,unary_ops:{"-":1,"!":1,"~":1,"+":1},binary_ops:{"||":1,"&&":2,"|":3,"^":4,"&":5,"==":6,"!=":6,"===":6,"!==":6,"<":7,">":7,"<=":7,">=":7,"<<":8,">>":8,">>>":8,"+":9,"-":9,"*":10,"/":10,"%":10},right_associative:new Set,additional_identifier_chars:new Set(["$","_"]),literals:{true:!0,false:!1,null:null},this_str:"this"}),e.max_unop_len=e.getMaxKeyLen(e.unary_ops),e.max_binop_len=e.getMaxKeyLen(e.binary_ops);const r=t=>new e(t).parse(),s=Object.getOwnPropertyNames(class{});Object.getOwnPropertyNames(e).filter((e=>!s.includes(e)&&void 0===r[e])).forEach((t=>{r[t]=e[t]})),r.Jsep=e;var i={name:"ternary",init(e){e.hooks.add("after-expression",(function(t){if(t.node&&this.code===e.QUMARK_CODE){this.index++;const r=t.node,s=this.gobbleExpression();if(s||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===e.COLON_CODE){this.index++;const i=this.gobbleExpression();if(i||this.throwError("Expected expression"),t.node={type:"ConditionalExpression",test:r,consequent:s,alternate:i},r.operator&&e.binary_ops[r.operator]<=.9){let s=r;for(;s.right.operator&&e.binary_ops[s.right.operator]<=.9;)s=s.right;t.node.test=s.right,s.right=t.node,t.node=r}}else this.throwError("Expected :")}}))}};r.plugins.register(i);var n={name:"regex",init(e){e.hooks.add("gobble-token",(function(t){if(47===this.code){const r=++this.index;let s=!1;for(;this.index<this.expr.length;){if(47===this.code&&!s){const s=this.expr.slice(r,this.index);let i,n="";for(;++this.index<this.expr.length;){const e=this.code;if(!(e>=97&&e<=122||e>=65&&e<=90||e>=48&&e<=57))break;n+=this.char}try{i=new RegExp(s,n)}catch(e){this.throwError(e.message)}return t.node={type:e.LITERAL,value:i,raw:this.expr.slice(r-1,this.index)},t.node=this.gobbleTokenProperty(t.node),t.node}this.code===e.OBRACK_CODE?s=!0:s&&this.code===e.CBRACK_CODE&&(s=!1),this.index+=92===this.code?2:1}this.throwError("Unclosed Regex")}}))}};const o={name:"assignment",assignmentOperators:new Set(["=","*=","**=","/=","%=","+=","-=","<<=",">>=",">>>=","&=","^=","|="]),updateOperators:[43,45],assignmentPrecedence:.9,init(e){const t=[e.IDENTIFIER,e.MEMBER_EXP];function r(e){o.assignmentOperators.has(e.operator)?(e.type="AssignmentExpression",r(e.left),r(e.right)):e.operator||Object.values(e).forEach((e=>{e&&"object"==typeof e&&r(e)}))}o.assignmentOperators.forEach((t=>e.addBinaryOp(t,o.assignmentPrecedence,!0))),e.hooks.add("gobble-token",(function(e){const r=this.code;o.updateOperators.some((e=>e===r&&e===this.expr.charCodeAt(this.index+1)))&&(this.index+=2,e.node={type:"UpdateExpression",operator:43===r?"++":"--",argument:this.gobbleTokenProperty(this.gobbleIdentifier()),prefix:!0},e.node.argument&&t.includes(e.node.argument.type)||this.throwError(`Unexpected ${e.node.operator}`))})),e.hooks.add("after-token",(function(e){if(e.node){const r=this.code;o.updateOperators.some((e=>e===r&&e===this.expr.charCodeAt(this.index+1)))&&(t.includes(e.node.type)||this.throwError(`Unexpected ${e.node.operator}`),this.index+=2,e.node={type:"UpdateExpression",operator:43===r?"++":"--",argument:e.node,prefix:!1})}})),e.hooks.add("after-expression",(function(e){e.node&&r(e.node)}))}};r.plugins.register(n,o);const a={evalAst(e,t){switch(e.type){case"BinaryExpression":case"LogicalExpression":return a.evalBinaryExpression(e,t);case"Compound":return a.evalCompound(e,t);case"ConditionalExpression":return a.evalConditionalExpression(e,t);case"Identifier":return a.evalIdentifier(e,t);case"Literal":return a.evalLiteral(e,t);case"MemberExpression":return a.evalMemberExpression(e,t);case"UnaryExpression":return a.evalUnaryExpression(e,t);case"ArrayExpression":return a.evalArrayExpression(e,t);case"CallExpression":return a.evalCallExpression(e,t);case"AssignmentExpression":return a.evalAssignmentExpression(e,t);default:throw SyntaxError("Unexpected expression",e)}},evalBinaryExpression:(e,t)=>({"||":(e,t)=>e||t(),"&&":(e,t)=>e&&t(),"|":(e,t)=>e|t(),"^":(e,t)=>e^t(),"&":(e,t)=>e&t(),"==":(e,t)=>e==t(),"!=":(e,t)=>e!=t(),"===":(e,t)=>e===t(),"!==":(e,t)=>e!==t(),"<":(e,t)=>e<t(),">":(e,t)=>e>t(),"<=":(e,t)=>e<=t(),">=":(e,t)=>e>=t(),"<<":(e,t)=>e<<t(),">>":(e,t)=>e>>t(),">>>":(e,t)=>e>>>t(),"+":(e,t)=>e+t(),"-":(e,t)=>e-t(),"*":(e,t)=>e*t(),"/":(e,t)=>e/t(),"%":(e,t)=>e%t()}[e.operator](a.evalAst(e.left,t),(()=>a.evalAst(e.right,t)))),evalCompound(e,t){let r;for(let s=0;s<e.body.length;s++){"Identifier"===e.body[s].type&&["var","let","const"].includes(e.body[s].name)&&e.body[s+1]&&"AssignmentExpression"===e.body[s+1].type&&(s+=1);const i=e.body[s];r=a.evalAst(i,t)}return r},evalConditionalExpression:(e,t)=>a.evalAst(e.test,t)?a.evalAst(e.consequent,t):a.evalAst(e.alternate,t),evalIdentifier(e,t){if(e.name in t)return t[e.name];throw ReferenceError(`${e.name} is not defined`)},evalLiteral:e=>e.value,evalMemberExpression(e,t){const r=e.computed?a.evalAst(e.property):e.property.name,s=a.evalAst(e.object,t),i=s[r];if("function"==typeof i){if(s===Function&&"bind"===r)throw new Error("Function.prototype.bind is disabled");if(s===Function&&("call"===r||"apply"===r))throw new Error("Function.prototype.call and Function.prototype.apply are disabled");return i===Function?i:i.bind(s)}return i},evalUnaryExpression:(e,t)=>({"-":e=>-a.evalAst(e,t),"!":e=>!a.evalAst(e,t),"~":e=>~a.evalAst(e,t),"+":e=>+a.evalAst(e,t)}[e.operator](e.argument)),evalArrayExpression:(e,t)=>e.elements.map((e=>a.evalAst(e,t))),evalCallExpression(e,t){const r=e.arguments.map((e=>a.evalAst(e,t))),s=a.evalAst(e.callee,t);if(s===Function)throw new Error("Function constructor is disabled");return s(...r)},evalAssignmentExpression(e,t){if("Identifier"!==e.left.type)throw SyntaxError("Invalid left-hand side in assignment");const r=e.left.name;if("__proto__"===r)throw new Error("Assignment to __proto__ is disabled");const s=a.evalAst(e.right,t);return t[r]=s,t[r]}};function h(e,t){return(e=e.slice()).push(t),e}function l(e,t){return(t=t.slice()).unshift(e),t}class c extends Error{constructor(e){super('JSONPath should not be called with "new" (it prevents return of (unwrapped) scalar values)'),this.avoidNew=!0,this.value=e,this.name="NewError"}}function p(e,t,r,s,i){if(!(this instanceof p))try{return new p(e,t,r,s,i)}catch(e){if(!e.avoidNew)throw e;return e.value}"string"==typeof e&&(i=s,s=r,r=t,t=e,e=null);const n=e&&"object"==typeof e;if(e=e||{},this.json=e.json||r,this.path=e.path||t,this.resultType=e.resultType||"value",this.flatten=e.flatten||!1,this.wrap=!Object.hasOwn(e,"wrap")||e.wrap,this.sandbox=e.sandbox||{},this.eval=void 0===e.eval?"safe":e.eval,this.ignoreEvalErrors=void 0!==e.ignoreEvalErrors&&e.ignoreEvalErrors,this.parent=e.parent||null,this.parentProperty=e.parentProperty||null,this.callback=e.callback||s||null,this.otherTypeCallback=e.otherTypeCallback||i||function(){throw new TypeError("You must supply an otherTypeCallback callback option with the @other() operator.")},!1!==e.autostart){const s={path:n?e.path:t};n?"json"in e&&(s.json=e.json):s.json=r;const i=this.evaluate(s);if(!i||"object"!=typeof i)throw new c(i);return i}}p.prototype.evaluate=function(e,t,r,s){let i=this.parent,n=this.parentProperty,{flatten:o,wrap:a}=this;if(this.currResultType=this.resultType,this.currEval=this.eval,this.currSandbox=this.sandbox,r=r||this.callback,this.currOtherTypeCallback=s||this.otherTypeCallback,t=t||this.json,(e=e||this.path)&&"object"==typeof e&&!Array.isArray(e)){if(!e.path&&""!==e.path)throw new TypeError('You must supply a "path" property when providing an object argument to JSONPath.evaluate().');if(!Object.hasOwn(e,"json"))throw new TypeError('You must supply a "json" property when providing an object argument to JSONPath.evaluate().');({json:t}=e),o=Object.hasOwn(e,"flatten")?e.flatten:o,this.currResultType=Object.hasOwn(e,"resultType")?e.resultType:this.currResultType,this.currSandbox=Object.hasOwn(e,"sandbox")?e.sandbox:this.currSandbox,a=Object.hasOwn(e,"wrap")?e.wrap:a,this.currEval=Object.hasOwn(e,"eval")?e.eval:this.currEval,r=Object.hasOwn(e,"callback")?e.callback:r,this.currOtherTypeCallback=Object.hasOwn(e,"otherTypeCallback")?e.otherTypeCallback:this.currOtherTypeCallback,i=Object.hasOwn(e,"parent")?e.parent:i,n=Object.hasOwn(e,"parentProperty")?e.parentProperty:n,e=e.path}if(i=i||null,n=n||null,Array.isArray(e)&&(e=p.toPathString(e)),!e&&""!==e||!t)return;const h=p.toPathArray(e);"$"===h[0]&&h.length>1&&h.shift(),this._hasParentSelector=null;const l=this._trace(h,t,["$"],i,n,r).filter((function(e){return e&&!e.isParentSelector}));return l.length?a||1!==l.length||l[0].hasArrExpr?l.reduce(((e,t)=>{const r=this._getPreferredOutput(t);return o&&Array.isArray(r)?e=e.concat(r):e.push(r),e}),[]):this._getPreferredOutput(l[0]):a?[]:void 0},p.prototype._getPreferredOutput=function(e){const t=this.currResultType;switch(t){case"all":{const t=Array.isArray(e.path)?e.path:p.toPathArray(e.path);return e.pointer=p.toPointer(t),e.path="string"==typeof e.path?e.path:p.toPathString(e.path),e}case"value":case"parent":case"parentProperty":return e[t];case"path":return p.toPathString(e[t]);case"pointer":return p.toPointer(e.path);default:throw new TypeError("Unknown result type")}},p.prototype._handleCallback=function(e,t,r){if(t){const s=this._getPreferredOutput(e);e.path="string"==typeof e.path?e.path:p.toPathString(e.path),t(s,r,e)}},p.prototype._trace=function(e,t,r,s,i,n,o,a){let c;if(!e.length)return c={path:r,value:t,parent:s,parentProperty:i,hasArrExpr:o},this._handleCallback(c,n,"value"),c;const p=e[0],u=e.slice(1),d=[];function f(e){Array.isArray(e)?e.forEach((e=>{d.push(e)})):d.push(e)}if(("string"!=typeof p||a)&&t&&Object.hasOwn(t,p))f(this._trace(u,t[p],h(r,p),t,p,n,o));else if("*"===p)this._walk(t,(e=>{f(this._trace(u,t[e],h(r,e),t,e,n,!0,!0))}));else if(".."===p)f(this._trace(u,t,r,s,i,n,o)),this._walk(t,(s=>{"object"==typeof t[s]&&f(this._trace(e.slice(),t[s],h(r,s),t,s,n,!0))}));else{if("^"===p)return this._hasParentSelector=!0,{path:r.slice(0,-1),expr:u,isParentSelector:!0};if("~"===p)return c={path:h(r,p),value:i,parent:s,parentProperty:null},this._handleCallback(c,n,"property"),c;if("$"===p)f(this._trace(u,t,r,null,null,n,o));else if(/^(-?\d*):(-?\d*):?(\d*)$/u.test(p))f(this._slice(p,u,t,r,s,i,n));else if(0===p.indexOf("?(")){if(!1===this.currEval)throw new Error("Eval [?(expr)] prevented in JSONPath expression.");const e=p.replace(/^\?\((.*?)\)$/u,"$1"),o=/@.?([^?]*)[['](\??\(.*?\))(?!.\)\])[\]']/gu.exec(e);o?this._walk(t,(e=>{const a=[o[2]],l=o[1]?t[e][o[1]]:t[e];this._trace(a,l,r,s,i,n,!0).length>0&&f(this._trace(u,t[e],h(r,e),t,e,n,!0))})):this._walk(t,(o=>{this._eval(e,t[o],o,r,s,i)&&f(this._trace(u,t[o],h(r,o),t,o,n,!0))}))}else if("("===p[0]){if(!1===this.currEval)throw new Error("Eval [(expr)] prevented in JSONPath expression.");f(this._trace(l(this._eval(p,t,r.at(-1),r.slice(0,-1),s,i),u),t,r,s,i,n,o))}else if("@"===p[0]){let e=!1;const o=p.slice(1,-2);switch(o){case"scalar":t&&["object","function"].includes(typeof t)||(e=!0);break;case"boolean":case"string":case"undefined":case"function":typeof t===o&&(e=!0);break;case"integer":!Number.isFinite(t)||t%1||(e=!0);break;case"number":Number.isFinite(t)&&(e=!0);break;case"nonFinite":"number"!=typeof t||Number.isFinite(t)||(e=!0);break;case"object":t&&typeof t===o&&(e=!0);break;case"array":Array.isArray(t)&&(e=!0);break;case"other":e=this.currOtherTypeCallback(t,r,s,i);break;case"null":null===t&&(e=!0);break;default:throw new TypeError("Unknown value type "+o)}if(e)return c={path:r,value:t,parent:s,parentProperty:i},this._handleCallback(c,n,"value"),c}else if("`"===p[0]&&t&&Object.hasOwn(t,p.slice(1))){const e=p.slice(1);f(this._trace(u,t[e],h(r,e),t,e,n,o,!0))}else if(p.includes(",")){const e=p.split(",");for(const o of e)f(this._trace(l(o,u),t,r,s,i,n,!0))}else!a&&t&&Object.hasOwn(t,p)&&f(this._trace(u,t[p],h(r,p),t,p,n,o,!0))}if(this._hasParentSelector)for(let e=0;e<d.length;e++){const r=d[e];if(r&&r.isParentSelector){const a=this._trace(r.expr,t,r.path,s,i,n,o);if(Array.isArray(a)){d[e]=a[0];const t=a.length;for(let r=1;r<t;r++)e++,d.splice(e,0,a[r])}else d[e]=a}}return d},p.prototype._walk=function(e,t){if(Array.isArray(e)){const r=e.length;for(let e=0;e<r;e++)t(e)}else e&&"object"==typeof e&&Object.keys(e).forEach((e=>{t(e)}))},p.prototype._slice=function(e,t,r,s,i,n,o){if(!Array.isArray(r))return;const a=r.length,h=e.split(":"),c=h[2]&&Number.parseInt(h[2])||1;let p=h[0]&&Number.parseInt(h[0])||0,u=h[1]&&Number.parseInt(h[1])||a;p=p<0?Math.max(0,p+a):Math.min(a,p),u=u<0?Math.max(0,u+a):Math.min(a,u);const d=[];for(let e=p;e<u;e+=c){this._trace(l(e,t),r,s,i,n,o,!0).forEach((e=>{d.push(e)}))}return d},p.prototype._eval=function(e,t,r,s,i,n){this.currSandbox._$_parentProperty=n,this.currSandbox._$_parent=i,this.currSandbox._$_property=r,this.currSandbox._$_root=this.json,this.currSandbox._$_v=t;const o=e.includes("@path");o&&(this.currSandbox._$_path=p.toPathString(s.concat([r])));const a=this.currEval+"Script:"+e;if(!p.cache[a]){let t=e.replaceAll("@parentProperty","_$_parentProperty").replaceAll("@parent","_$_parent").replaceAll("@property","_$_property").replaceAll("@root","_$_root").replaceAll(/@([.\s)[])/gu,"_$_v$1");if(o&&(t=t.replaceAll("@path","_$_path")),"safe"===this.currEval||!0===this.currEval||void 0===this.currEval)p.cache[a]=new this.safeVm.Script(t);else if("native"===this.currEval)p.cache[a]=new this.vm.Script(t);else if("function"==typeof this.currEval&&this.currEval.prototype&&Object.hasOwn(this.currEval.prototype,"runInNewContext")){const e=this.currEval;p.cache[a]=new e(t)}else{if("function"!=typeof this.currEval)throw new TypeError(`Unknown "eval" property "${this.currEval}"`);p.cache[a]={runInNewContext:e=>this.currEval(t,e)}}}try{return p.cache[a].runInNewContext(this.currSandbox)}catch(t){if(this.ignoreEvalErrors)return!1;throw new Error("jsonPath: "+t.message+": "+e)}},p.cache={},p.toPathString=function(e){const t=e,r=t.length;let s="$";for(let e=1;e<r;e++)/^(~|\^|@.*?\(\))$/u.test(t[e])||(s+=/^[0-9*]+$/u.test(t[e])?"["+t[e]+"]":"['"+t[e]+"']");return s},p.toPointer=function(e){const t=e,r=t.length;let s="";for(let e=1;e<r;e++)/^(~|\^|@.*?\(\))$/u.test(t[e])||(s+="/"+t[e].toString().replaceAll("~","~0").replaceAll("/","~1"));return s},p.toPathArray=function(e){const{cache:t}=p;if(t[e])return t[e].concat();const r=[],s=e.replaceAll(/@(?:null|boolean|number|string|integer|undefined|nonFinite|scalar|array|object|function|other)\(\)/gu,";$&;").replaceAll(/[['](\??\(.*?\))[\]'](?!.\])/gu,(function(e,t){return"[#"+(r.push(t)-1)+"]"})).replaceAll(/\[['"]([^'\]]*)['"]\]/gu,(function(e,t){return"['"+t.replaceAll(".","%@%").replaceAll("~","%%@@%%")+"']"})).replaceAll("~",";~;").replaceAll(/['"]?\.['"]?(?![^[]*\])|\[['"]?/gu,";").replaceAll("%@%",".").replaceAll("%%@@%%","~").replaceAll(/(?:;)?(\^+)(?:;)?/gu,(function(e,t){return";"+t.split("").join(";")+";"})).replaceAll(/;;;|;;/gu,";..;").replaceAll(/;$|'?\]|'$/gu,"").split(";").map((function(e){const t=e.match(/#(\d+)/u);return t&&t[1]?r[t[1]]:e}));return t[e]=s,t[e].concat()},p.prototype.safeVm={Script:class{constructor(e){this.code=e,this.ast=r(this.code)}runInNewContext(e){const t={...e};return a.evalAst(this.ast,t)}}};p.prototype.vm={Script:class{constructor(e){this.code=e}runInNewContext(e){let t=this.code;const r=Object.keys(e),s=[];!function(e,t,r){const s=e.length;for(let i=0;i<s;i++)r(e[i])&&t.push(e.splice(i--,1)[0])}(r,s,(t=>"function"==typeof e[t]));const i=r.map((t=>e[t]));t=s.reduce(((t,r)=>{let s=e[r].toString();return/function/u.test(s)||(s="function "+s),"var "+r+"="+s+";"+t}),"")+t,/(['"])use strict\1/u.test(t)||r.includes("arguments")||(t="var arguments = undefined;"+t),t=t.replace(/;\s*$/u,"");const n=t.lastIndexOf(";"),o=n>-1?t.slice(0,n+1)+" return "+t.slice(n+1):" return "+t;return new Function(...r,o)(...i)}}};export{p as JSONPath}; +class e{static get version(){return"1.3.9"}static toString(){return"JavaScript Expression Parser (JSEP) v"+e.version}static addUnaryOp(t){return e.max_unop_len=Math.max(t.length,e.max_unop_len),e.unary_ops[t]=1,e}static addBinaryOp(t,r,i){return e.max_binop_len=Math.max(t.length,e.max_binop_len),e.binary_ops[t]=r,i?e.right_associative.add(t):e.right_associative.delete(t),e}static addIdentifierChar(t){return e.additional_identifier_chars.add(t),e}static addLiteral(t,r){return e.literals[t]=r,e}static removeUnaryOp(t){return delete e.unary_ops[t],t.length===e.max_unop_len&&(e.max_unop_len=e.getMaxKeyLen(e.unary_ops)),e}static removeAllUnaryOps(){return e.unary_ops={},e.max_unop_len=0,e}static removeIdentifierChar(t){return e.additional_identifier_chars.delete(t),e}static removeBinaryOp(t){return delete e.binary_ops[t],t.length===e.max_binop_len&&(e.max_binop_len=e.getMaxKeyLen(e.binary_ops)),e.right_associative.delete(t),e}static removeAllBinaryOps(){return e.binary_ops={},e.max_binop_len=0,e}static removeLiteral(t){return delete e.literals[t],e}static removeAllLiterals(){return e.literals={},e}get char(){return this.expr.charAt(this.index)}get code(){return this.expr.charCodeAt(this.index)}constructor(e){this.expr=e,this.index=0}static parse(t){return new e(t).parse()}static getMaxKeyLen(e){return Math.max(0,...Object.keys(e).map((e=>e.length)))}static isDecimalDigit(e){return e>=48&&e<=57}static binaryPrecedence(t){return e.binary_ops[t]||0}static isIdentifierStart(t){return t>=65&&t<=90||t>=97&&t<=122||t>=128&&!e.binary_ops[String.fromCharCode(t)]||e.additional_identifier_chars.has(String.fromCharCode(t))}static isIdentifierPart(t){return e.isIdentifierStart(t)||e.isDecimalDigit(t)}throwError(e){const t=new Error(e+" at character "+this.index);throw t.index=this.index,t.description=e,t}runHook(t,r){if(e.hooks[t]){const i={context:this,node:r};return e.hooks.run(t,i),i.node}return r}searchHook(t){if(e.hooks[t]){const r={context:this};return e.hooks[t].find((function(e){return e.call(r.context,r),r.node})),r.node}}gobbleSpaces(){let t=this.code;for(;t===e.SPACE_CODE||t===e.TAB_CODE||t===e.LF_CODE||t===e.CR_CODE;)t=this.expr.charCodeAt(++this.index);this.runHook("gobble-spaces")}parse(){this.runHook("before-all");const t=this.gobbleExpressions(),r=1===t.length?t[0]:{type:e.COMPOUND,body:t};return this.runHook("after-all",r)}gobbleExpressions(t){let r,i,n=[];for(;this.index<this.expr.length;)if(r=this.code,r===e.SEMCOL_CODE||r===e.COMMA_CODE)this.index++;else if(i=this.gobbleExpression())n.push(i);else if(this.index<this.expr.length){if(r===t)break;this.throwError('Unexpected "'+this.char+'"')}return n}gobbleExpression(){const e=this.searchHook("gobble-expression")||this.gobbleBinaryExpression();return this.gobbleSpaces(),this.runHook("after-expression",e)}gobbleBinaryOp(){this.gobbleSpaces();let t=this.expr.substr(this.index,e.max_binop_len),r=t.length;for(;r>0;){if(e.binary_ops.hasOwnProperty(t)&&(!e.isIdentifierStart(this.code)||this.index+t.length<this.expr.length&&!e.isIdentifierPart(this.expr.charCodeAt(this.index+t.length))))return this.index+=r,t;t=t.substr(0,--r)}return!1}gobbleBinaryExpression(){let t,r,i,n,s,o,a,h,l;if(o=this.gobbleToken(),!o)return o;if(r=this.gobbleBinaryOp(),!r)return o;for(s={value:r,prec:e.binaryPrecedence(r),right_a:e.right_associative.has(r)},a=this.gobbleToken(),a||this.throwError("Expected expression after "+r),n=[o,s,a];r=this.gobbleBinaryOp();){if(i=e.binaryPrecedence(r),0===i){this.index-=r.length;break}s={value:r,prec:i,right_a:e.right_associative.has(r)},l=r;const h=e=>s.right_a&&e.right_a?i>e.prec:i<=e.prec;for(;n.length>2&&h(n[n.length-2]);)a=n.pop(),r=n.pop().value,o=n.pop(),t={type:e.BINARY_EXP,operator:r,left:o,right:a},n.push(t);t=this.gobbleToken(),t||this.throwError("Expected expression after "+l),n.push(s,t)}for(h=n.length-1,t=n[h];h>1;)t={type:e.BINARY_EXP,operator:n[h-1].value,left:n[h-2],right:t},h-=2;return t}gobbleToken(){let t,r,i,n;if(this.gobbleSpaces(),n=this.searchHook("gobble-token"),n)return this.runHook("after-token",n);if(t=this.code,e.isDecimalDigit(t)||t===e.PERIOD_CODE)return this.gobbleNumericLiteral();if(t===e.SQUOTE_CODE||t===e.DQUOTE_CODE)n=this.gobbleStringLiteral();else if(t===e.OBRACK_CODE)n=this.gobbleArray();else{for(r=this.expr.substr(this.index,e.max_unop_len),i=r.length;i>0;){if(e.unary_ops.hasOwnProperty(r)&&(!e.isIdentifierStart(this.code)||this.index+r.length<this.expr.length&&!e.isIdentifierPart(this.expr.charCodeAt(this.index+r.length)))){this.index+=i;const t=this.gobbleToken();return t||this.throwError("missing unaryOp argument"),this.runHook("after-token",{type:e.UNARY_EXP,operator:r,argument:t,prefix:!0})}r=r.substr(0,--i)}e.isIdentifierStart(t)?(n=this.gobbleIdentifier(),e.literals.hasOwnProperty(n.name)?n={type:e.LITERAL,value:e.literals[n.name],raw:n.name}:n.name===e.this_str&&(n={type:e.THIS_EXP})):t===e.OPAREN_CODE&&(n=this.gobbleGroup())}return n?(n=this.gobbleTokenProperty(n),this.runHook("after-token",n)):this.runHook("after-token",!1)}gobbleTokenProperty(t){this.gobbleSpaces();let r=this.code;for(;r===e.PERIOD_CODE||r===e.OBRACK_CODE||r===e.OPAREN_CODE||r===e.QUMARK_CODE;){let i;if(r===e.QUMARK_CODE){if(this.expr.charCodeAt(this.index+1)!==e.PERIOD_CODE)break;i=!0,this.index+=2,this.gobbleSpaces(),r=this.code}this.index++,r===e.OBRACK_CODE?((t={type:e.MEMBER_EXP,computed:!0,object:t,property:this.gobbleExpression()}).property||this.throwError('Unexpected "'+this.char+'"'),this.gobbleSpaces(),r=this.code,r!==e.CBRACK_CODE&&this.throwError("Unclosed ["),this.index++):r===e.OPAREN_CODE?t={type:e.CALL_EXP,arguments:this.gobbleArguments(e.CPAREN_CODE),callee:t}:(r===e.PERIOD_CODE||i)&&(i&&this.index--,this.gobbleSpaces(),t={type:e.MEMBER_EXP,computed:!1,object:t,property:this.gobbleIdentifier()}),i&&(t.optional=!0),this.gobbleSpaces(),r=this.code}return t}gobbleNumericLiteral(){let t,r,i="";for(;e.isDecimalDigit(this.code);)i+=this.expr.charAt(this.index++);if(this.code===e.PERIOD_CODE)for(i+=this.expr.charAt(this.index++);e.isDecimalDigit(this.code);)i+=this.expr.charAt(this.index++);if(t=this.char,"e"===t||"E"===t){for(i+=this.expr.charAt(this.index++),t=this.char,"+"!==t&&"-"!==t||(i+=this.expr.charAt(this.index++));e.isDecimalDigit(this.code);)i+=this.expr.charAt(this.index++);e.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+i+this.char+")")}return r=this.code,e.isIdentifierStart(r)?this.throwError("Variable names cannot start with a number ("+i+this.char+")"):(r===e.PERIOD_CODE||1===i.length&&i.charCodeAt(0)===e.PERIOD_CODE)&&this.throwError("Unexpected period"),{type:e.LITERAL,value:parseFloat(i),raw:i}}gobbleStringLiteral(){let t="";const r=this.index,i=this.expr.charAt(this.index++);let n=!1;for(;this.index<this.expr.length;){let e=this.expr.charAt(this.index++);if(e===i){n=!0;break}if("\\"===e)switch(e=this.expr.charAt(this.index++),e){case"n":t+="\n";break;case"r":t+="\r";break;case"t":t+="\t";break;case"b":t+="\b";break;case"f":t+="\f";break;case"v":t+="\v";break;default:t+=e}else t+=e}return n||this.throwError('Unclosed quote after "'+t+'"'),{type:e.LITERAL,value:t,raw:this.expr.substring(r,this.index)}}gobbleIdentifier(){let t=this.code,r=this.index;for(e.isIdentifierStart(t)?this.index++:this.throwError("Unexpected "+this.char);this.index<this.expr.length&&(t=this.code,e.isIdentifierPart(t));)this.index++;return{type:e.IDENTIFIER,name:this.expr.slice(r,this.index)}}gobbleArguments(t){const r=[];let i=!1,n=0;for(;this.index<this.expr.length;){this.gobbleSpaces();let s=this.code;if(s===t){i=!0,this.index++,t===e.CPAREN_CODE&&n&&n>=r.length&&this.throwError("Unexpected token "+String.fromCharCode(t));break}if(s===e.COMMA_CODE){if(this.index++,n++,n!==r.length)if(t===e.CPAREN_CODE)this.throwError("Unexpected token ,");else if(t===e.CBRACK_CODE)for(let e=r.length;e<n;e++)r.push(null)}else if(r.length!==n&&0!==n)this.throwError("Expected comma");else{const t=this.gobbleExpression();t&&t.type!==e.COMPOUND||this.throwError("Expected comma"),r.push(t)}}return i||this.throwError("Expected "+String.fromCharCode(t)),r}gobbleGroup(){this.index++;let t=this.gobbleExpressions(e.CPAREN_CODE);if(this.code===e.CPAREN_CODE)return this.index++,1===t.length?t[0]:!!t.length&&{type:e.SEQUENCE_EXP,expressions:t};this.throwError("Unclosed (")}gobbleArray(){return this.index++,{type:e.ARRAY_EXP,elements:this.gobbleArguments(e.CBRACK_CODE)}}}const t=new class{add(e,t,r){if("string"!=typeof arguments[0])for(let e in arguments[0])this.add(e,arguments[0][e],arguments[1]);else(Array.isArray(e)?e:[e]).forEach((function(e){this[e]=this[e]||[],t&&this[e][r?"unshift":"push"](t)}),this)}run(e,t){this[e]=this[e]||[],this[e].forEach((function(e){e.call(t&&t.context?t.context:t,t)}))}};Object.assign(e,{hooks:t,plugins:new class{constructor(e){this.jsep=e,this.registered={}}register(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];t.forEach((e=>{if("object"!=typeof e||!e.name||!e.init)throw new Error("Invalid JSEP plugin format");this.registered[e.name]||(e.init(this.jsep),this.registered[e.name]=e)}))}}(e),COMPOUND:"Compound",SEQUENCE_EXP:"SequenceExpression",IDENTIFIER:"Identifier",MEMBER_EXP:"MemberExpression",LITERAL:"Literal",THIS_EXP:"ThisExpression",CALL_EXP:"CallExpression",UNARY_EXP:"UnaryExpression",BINARY_EXP:"BinaryExpression",ARRAY_EXP:"ArrayExpression",TAB_CODE:9,LF_CODE:10,CR_CODE:13,SPACE_CODE:32,PERIOD_CODE:46,COMMA_CODE:44,SQUOTE_CODE:39,DQUOTE_CODE:34,OPAREN_CODE:40,CPAREN_CODE:41,OBRACK_CODE:91,CBRACK_CODE:93,QUMARK_CODE:63,SEMCOL_CODE:59,COLON_CODE:58,unary_ops:{"-":1,"!":1,"~":1,"+":1},binary_ops:{"||":1,"&&":2,"|":3,"^":4,"&":5,"==":6,"!=":6,"===":6,"!==":6,"<":7,">":7,"<=":7,">=":7,"<<":8,">>":8,">>>":8,"+":9,"-":9,"*":10,"/":10,"%":10},right_associative:new Set,additional_identifier_chars:new Set(["$","_"]),literals:{true:!0,false:!1,null:null},this_str:"this"}),e.max_unop_len=e.getMaxKeyLen(e.unary_ops),e.max_binop_len=e.getMaxKeyLen(e.binary_ops);const r=t=>new e(t).parse(),i=Object.getOwnPropertyNames(class{});Object.getOwnPropertyNames(e).filter((e=>!i.includes(e)&&void 0===r[e])).forEach((t=>{r[t]=e[t]})),r.Jsep=e;var n={name:"ternary",init(e){e.hooks.add("after-expression",(function(t){if(t.node&&this.code===e.QUMARK_CODE){this.index++;const r=t.node,i=this.gobbleExpression();if(i||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===e.COLON_CODE){this.index++;const n=this.gobbleExpression();if(n||this.throwError("Expected expression"),t.node={type:"ConditionalExpression",test:r,consequent:i,alternate:n},r.operator&&e.binary_ops[r.operator]<=.9){let i=r;for(;i.right.operator&&e.binary_ops[i.right.operator]<=.9;)i=i.right;t.node.test=i.right,i.right=t.node,t.node=r}}else this.throwError("Expected :")}}))}};r.plugins.register(n);var s={name:"regex",init(e){e.hooks.add("gobble-token",(function(t){if(47===this.code){const r=++this.index;let i=!1;for(;this.index<this.expr.length;){if(47===this.code&&!i){const i=this.expr.slice(r,this.index);let n,s="";for(;++this.index<this.expr.length;){const e=this.code;if(!(e>=97&&e<=122||e>=65&&e<=90||e>=48&&e<=57))break;s+=this.char}try{n=new RegExp(i,s)}catch(e){this.throwError(e.message)}return t.node={type:e.LITERAL,value:n,raw:this.expr.slice(r-1,this.index)},t.node=this.gobbleTokenProperty(t.node),t.node}this.code===e.OBRACK_CODE?i=!0:i&&this.code===e.CBRACK_CODE&&(i=!1),this.index+=92===this.code?2:1}this.throwError("Unclosed Regex")}}))}};const o={name:"assignment",assignmentOperators:new Set(["=","*=","**=","/=","%=","+=","-=","<<=",">>=",">>>=","&=","^=","|="]),updateOperators:[43,45],assignmentPrecedence:.9,init(e){const t=[e.IDENTIFIER,e.MEMBER_EXP];function r(e){o.assignmentOperators.has(e.operator)?(e.type="AssignmentExpression",r(e.left),r(e.right)):e.operator||Object.values(e).forEach((e=>{e&&"object"==typeof e&&r(e)}))}o.assignmentOperators.forEach((t=>e.addBinaryOp(t,o.assignmentPrecedence,!0))),e.hooks.add("gobble-token",(function(e){const r=this.code;o.updateOperators.some((e=>e===r&&e===this.expr.charCodeAt(this.index+1)))&&(this.index+=2,e.node={type:"UpdateExpression",operator:43===r?"++":"--",argument:this.gobbleTokenProperty(this.gobbleIdentifier()),prefix:!0},e.node.argument&&t.includes(e.node.argument.type)||this.throwError(`Unexpected ${e.node.operator}`))})),e.hooks.add("after-token",(function(e){if(e.node){const r=this.code;o.updateOperators.some((e=>e===r&&e===this.expr.charCodeAt(this.index+1)))&&(t.includes(e.node.type)||this.throwError(`Unexpected ${e.node.operator}`),this.index+=2,e.node={type:"UpdateExpression",operator:43===r?"++":"--",argument:e.node,prefix:!1})}})),e.hooks.add("after-expression",(function(e){e.node&&r(e.node)}))}};r.plugins.register(s,o);const a={evalAst(e,t){switch(e.type){case"BinaryExpression":case"LogicalExpression":return a.evalBinaryExpression(e,t);case"Compound":return a.evalCompound(e,t);case"ConditionalExpression":return a.evalConditionalExpression(e,t);case"Identifier":return a.evalIdentifier(e,t);case"Literal":return a.evalLiteral(e,t);case"MemberExpression":return a.evalMemberExpression(e,t);case"UnaryExpression":return a.evalUnaryExpression(e,t);case"ArrayExpression":return a.evalArrayExpression(e,t);case"CallExpression":return a.evalCallExpression(e,t);case"AssignmentExpression":return a.evalAssignmentExpression(e,t);default:throw SyntaxError("Unexpected expression",e)}},evalBinaryExpression:(e,t)=>({"||":(e,t)=>e||t(),"&&":(e,t)=>e&&t(),"|":(e,t)=>e|t(),"^":(e,t)=>e^t(),"&":(e,t)=>e&t(),"==":(e,t)=>e==t(),"!=":(e,t)=>e!=t(),"===":(e,t)=>e===t(),"!==":(e,t)=>e!==t(),"<":(e,t)=>e<t(),">":(e,t)=>e>t(),"<=":(e,t)=>e<=t(),">=":(e,t)=>e>=t(),"<<":(e,t)=>e<<t(),">>":(e,t)=>e>>t(),">>>":(e,t)=>e>>>t(),"+":(e,t)=>e+t(),"-":(e,t)=>e-t(),"*":(e,t)=>e*t(),"/":(e,t)=>e/t(),"%":(e,t)=>e%t()}[e.operator](a.evalAst(e.left,t),(()=>a.evalAst(e.right,t)))),evalCompound(e,t){let r;for(let i=0;i<e.body.length;i++){"Identifier"===e.body[i].type&&["var","let","const"].includes(e.body[i].name)&&e.body[i+1]&&"AssignmentExpression"===e.body[i+1].type&&(i+=1);const n=e.body[i];r=a.evalAst(n,t)}return r},evalConditionalExpression:(e,t)=>a.evalAst(e.test,t)?a.evalAst(e.consequent,t):a.evalAst(e.alternate,t),evalIdentifier(e,t){if(e.name in t)return t[e.name];throw ReferenceError(`${e.name} is not defined`)},evalLiteral:e=>e.value,evalMemberExpression(e,t){if("Identifier"===e.property.type&&"constructor"===e.property.name||"Identifier"===e.object.type&&"constructor"===e.object.name)throw new Error("'constructor' property is disabled");const r=e.computed?a.evalAst(e.property):e.property.name,i=a.evalAst(e.object,t),n=i[r];if("function"==typeof n){if(i===Function&&"bind"===r)throw new Error("Function.prototype.bind is disabled");if(i===Function&&("call"===r||"apply"===r))throw new Error("Function.prototype.call and Function.prototype.apply are disabled");return n===Function?n:n.bind(i)}return n},evalUnaryExpression:(e,t)=>({"-":e=>-a.evalAst(e,t),"!":e=>!a.evalAst(e,t),"~":e=>~a.evalAst(e,t),"+":e=>+a.evalAst(e,t)}[e.operator](e.argument)),evalArrayExpression:(e,t)=>e.elements.map((e=>a.evalAst(e,t))),evalCallExpression(e,t){const r=e.arguments.map((e=>a.evalAst(e,t))),i=a.evalAst(e.callee,t);if(i===Function)throw new Error("Function constructor is disabled");return i(...r)},evalAssignmentExpression(e,t){if("Identifier"!==e.left.type)throw SyntaxError("Invalid left-hand side in assignment");const r=e.left.name;if("__proto__"===r)throw new Error("Assignment to __proto__ is disabled");const i=a.evalAst(e.right,t);return t[r]=i,t[r]}};function h(e,t){return(e=e.slice()).push(t),e}function l(e,t){return(t=t.slice()).unshift(e),t}class c extends Error{constructor(e){super('JSONPath should not be called with "new" (it prevents return of (unwrapped) scalar values)'),this.avoidNew=!0,this.value=e,this.name="NewError"}}function p(e,t,r,i,n){if(!(this instanceof p))try{return new p(e,t,r,i,n)}catch(e){if(!e.avoidNew)throw e;return e.value}"string"==typeof e&&(n=i,i=r,r=t,t=e,e=null);const s=e&&"object"==typeof e;if(e=e||{},this.json=e.json||r,this.path=e.path||t,this.resultType=e.resultType||"value",this.flatten=e.flatten||!1,this.wrap=!Object.hasOwn(e,"wrap")||e.wrap,this.sandbox=e.sandbox||{},this.eval=void 0===e.eval?"safe":e.eval,this.ignoreEvalErrors=void 0!==e.ignoreEvalErrors&&e.ignoreEvalErrors,this.parent=e.parent||null,this.parentProperty=e.parentProperty||null,this.callback=e.callback||i||null,this.otherTypeCallback=e.otherTypeCallback||n||function(){throw new TypeError("You must supply an otherTypeCallback callback option with the @other() operator.")},!1!==e.autostart){const i={path:s?e.path:t};s?"json"in e&&(i.json=e.json):i.json=r;const n=this.evaluate(i);if(!n||"object"!=typeof n)throw new c(n);return n}}p.prototype.evaluate=function(e,t,r,i){let n=this.parent,s=this.parentProperty,{flatten:o,wrap:a}=this;if(this.currResultType=this.resultType,this.currEval=this.eval,this.currSandbox=this.sandbox,r=r||this.callback,this.currOtherTypeCallback=i||this.otherTypeCallback,t=t||this.json,(e=e||this.path)&&"object"==typeof e&&!Array.isArray(e)){if(!e.path&&""!==e.path)throw new TypeError('You must supply a "path" property when providing an object argument to JSONPath.evaluate().');if(!Object.hasOwn(e,"json"))throw new TypeError('You must supply a "json" property when providing an object argument to JSONPath.evaluate().');({json:t}=e),o=Object.hasOwn(e,"flatten")?e.flatten:o,this.currResultType=Object.hasOwn(e,"resultType")?e.resultType:this.currResultType,this.currSandbox=Object.hasOwn(e,"sandbox")?e.sandbox:this.currSandbox,a=Object.hasOwn(e,"wrap")?e.wrap:a,this.currEval=Object.hasOwn(e,"eval")?e.eval:this.currEval,r=Object.hasOwn(e,"callback")?e.callback:r,this.currOtherTypeCallback=Object.hasOwn(e,"otherTypeCallback")?e.otherTypeCallback:this.currOtherTypeCallback,n=Object.hasOwn(e,"parent")?e.parent:n,s=Object.hasOwn(e,"parentProperty")?e.parentProperty:s,e=e.path}if(n=n||null,s=s||null,Array.isArray(e)&&(e=p.toPathString(e)),!e&&""!==e||!t)return;const h=p.toPathArray(e);"$"===h[0]&&h.length>1&&h.shift(),this._hasParentSelector=null;const l=this._trace(h,t,["$"],n,s,r).filter((function(e){return e&&!e.isParentSelector}));return l.length?a||1!==l.length||l[0].hasArrExpr?l.reduce(((e,t)=>{const r=this._getPreferredOutput(t);return o&&Array.isArray(r)?e=e.concat(r):e.push(r),e}),[]):this._getPreferredOutput(l[0]):a?[]:void 0},p.prototype._getPreferredOutput=function(e){const t=this.currResultType;switch(t){case"all":{const t=Array.isArray(e.path)?e.path:p.toPathArray(e.path);return e.pointer=p.toPointer(t),e.path="string"==typeof e.path?e.path:p.toPathString(e.path),e}case"value":case"parent":case"parentProperty":return e[t];case"path":return p.toPathString(e[t]);case"pointer":return p.toPointer(e.path);default:throw new TypeError("Unknown result type")}},p.prototype._handleCallback=function(e,t,r){if(t){const i=this._getPreferredOutput(e);e.path="string"==typeof e.path?e.path:p.toPathString(e.path),t(i,r,e)}},p.prototype._trace=function(e,t,r,i,n,s,o,a){let c;if(!e.length)return c={path:r,value:t,parent:i,parentProperty:n,hasArrExpr:o},this._handleCallback(c,s,"value"),c;const p=e[0],u=e.slice(1),d=[];function f(e){Array.isArray(e)?e.forEach((e=>{d.push(e)})):d.push(e)}if(("string"!=typeof p||a)&&t&&Object.hasOwn(t,p))f(this._trace(u,t[p],h(r,p),t,p,s,o));else if("*"===p)this._walk(t,(e=>{f(this._trace(u,t[e],h(r,e),t,e,s,!0,!0))}));else if(".."===p)f(this._trace(u,t,r,i,n,s,o)),this._walk(t,(i=>{"object"==typeof t[i]&&f(this._trace(e.slice(),t[i],h(r,i),t,i,s,!0))}));else{if("^"===p)return this._hasParentSelector=!0,{path:r.slice(0,-1),expr:u,isParentSelector:!0};if("~"===p)return c={path:h(r,p),value:n,parent:i,parentProperty:null},this._handleCallback(c,s,"property"),c;if("$"===p)f(this._trace(u,t,r,null,null,s,o));else if(/^(-?\d*):(-?\d*):?(\d*)$/u.test(p))f(this._slice(p,u,t,r,i,n,s));else if(0===p.indexOf("?(")){if(!1===this.currEval)throw new Error("Eval [?(expr)] prevented in JSONPath expression.");const e=p.replace(/^\?\((.*?)\)$/u,"$1"),o=/@.?([^?]*)[['](\??\(.*?\))(?!.\)\])[\]']/gu.exec(e);o?this._walk(t,(e=>{const a=[o[2]],l=o[1]?t[e][o[1]]:t[e];this._trace(a,l,r,i,n,s,!0).length>0&&f(this._trace(u,t[e],h(r,e),t,e,s,!0))})):this._walk(t,(o=>{this._eval(e,t[o],o,r,i,n)&&f(this._trace(u,t[o],h(r,o),t,o,s,!0))}))}else if("("===p[0]){if(!1===this.currEval)throw new Error("Eval [(expr)] prevented in JSONPath expression.");f(this._trace(l(this._eval(p,t,r.at(-1),r.slice(0,-1),i,n),u),t,r,i,n,s,o))}else if("@"===p[0]){let e=!1;const o=p.slice(1,-2);switch(o){case"scalar":t&&["object","function"].includes(typeof t)||(e=!0);break;case"boolean":case"string":case"undefined":case"function":typeof t===o&&(e=!0);break;case"integer":!Number.isFinite(t)||t%1||(e=!0);break;case"number":Number.isFinite(t)&&(e=!0);break;case"nonFinite":"number"!=typeof t||Number.isFinite(t)||(e=!0);break;case"object":t&&typeof t===o&&(e=!0);break;case"array":Array.isArray(t)&&(e=!0);break;case"other":e=this.currOtherTypeCallback(t,r,i,n);break;case"null":null===t&&(e=!0);break;default:throw new TypeError("Unknown value type "+o)}if(e)return c={path:r,value:t,parent:i,parentProperty:n},this._handleCallback(c,s,"value"),c}else if("`"===p[0]&&t&&Object.hasOwn(t,p.slice(1))){const e=p.slice(1);f(this._trace(u,t[e],h(r,e),t,e,s,o,!0))}else if(p.includes(",")){const e=p.split(",");for(const o of e)f(this._trace(l(o,u),t,r,i,n,s,!0))}else!a&&t&&Object.hasOwn(t,p)&&f(this._trace(u,t[p],h(r,p),t,p,s,o,!0))}if(this._hasParentSelector)for(let e=0;e<d.length;e++){const r=d[e];if(r&&r.isParentSelector){const a=this._trace(r.expr,t,r.path,i,n,s,o);if(Array.isArray(a)){d[e]=a[0];const t=a.length;for(let r=1;r<t;r++)e++,d.splice(e,0,a[r])}else d[e]=a}}return d},p.prototype._walk=function(e,t){if(Array.isArray(e)){const r=e.length;for(let e=0;e<r;e++)t(e)}else e&&"object"==typeof e&&Object.keys(e).forEach((e=>{t(e)}))},p.prototype._slice=function(e,t,r,i,n,s,o){if(!Array.isArray(r))return;const a=r.length,h=e.split(":"),c=h[2]&&Number.parseInt(h[2])||1;let p=h[0]&&Number.parseInt(h[0])||0,u=h[1]&&Number.parseInt(h[1])||a;p=p<0?Math.max(0,p+a):Math.min(a,p),u=u<0?Math.max(0,u+a):Math.min(a,u);const d=[];for(let e=p;e<u;e+=c){this._trace(l(e,t),r,i,n,s,o,!0).forEach((e=>{d.push(e)}))}return d},p.prototype._eval=function(e,t,r,i,n,s){this.currSandbox._$_parentProperty=s,this.currSandbox._$_parent=n,this.currSandbox._$_property=r,this.currSandbox._$_root=this.json,this.currSandbox._$_v=t;const o=e.includes("@path");o&&(this.currSandbox._$_path=p.toPathString(i.concat([r])));const a=this.currEval+"Script:"+e;if(!p.cache[a]){let t=e.replaceAll("@parentProperty","_$_parentProperty").replaceAll("@parent","_$_parent").replaceAll("@property","_$_property").replaceAll("@root","_$_root").replaceAll(/@([.\s)[])/gu,"_$_v$1");if(o&&(t=t.replaceAll("@path","_$_path")),"safe"===this.currEval||!0===this.currEval||void 0===this.currEval)p.cache[a]=new this.safeVm.Script(t);else if("native"===this.currEval)p.cache[a]=new this.vm.Script(t);else if("function"==typeof this.currEval&&this.currEval.prototype&&Object.hasOwn(this.currEval.prototype,"runInNewContext")){const e=this.currEval;p.cache[a]=new e(t)}else{if("function"!=typeof this.currEval)throw new TypeError(`Unknown "eval" property "${this.currEval}"`);p.cache[a]={runInNewContext:e=>this.currEval(t,e)}}}try{return p.cache[a].runInNewContext(this.currSandbox)}catch(t){if(this.ignoreEvalErrors)return!1;throw new Error("jsonPath: "+t.message+": "+e)}},p.cache={},p.toPathString=function(e){const t=e,r=t.length;let i="$";for(let e=1;e<r;e++)/^(~|\^|@.*?\(\))$/u.test(t[e])||(i+=/^[0-9*]+$/u.test(t[e])?"["+t[e]+"]":"['"+t[e]+"']");return i},p.toPointer=function(e){const t=e,r=t.length;let i="";for(let e=1;e<r;e++)/^(~|\^|@.*?\(\))$/u.test(t[e])||(i+="/"+t[e].toString().replaceAll("~","~0").replaceAll("/","~1"));return i},p.toPathArray=function(e){const{cache:t}=p;if(t[e])return t[e].concat();const r=[],i=e.replaceAll(/@(?:null|boolean|number|string|integer|undefined|nonFinite|scalar|array|object|function|other)\(\)/gu,";$&;").replaceAll(/[['](\??\(.*?\))[\]'](?!.\])/gu,(function(e,t){return"[#"+(r.push(t)-1)+"]"})).replaceAll(/\[['"]([^'\]]*)['"]\]/gu,(function(e,t){return"['"+t.replaceAll(".","%@%").replaceAll("~","%%@@%%")+"']"})).replaceAll("~",";~;").replaceAll(/['"]?\.['"]?(?![^[]*\])|\[['"]?/gu,";").replaceAll("%@%",".").replaceAll("%%@@%%","~").replaceAll(/(?:;)?(\^+)(?:;)?/gu,(function(e,t){return";"+t.split("").join(";")+";"})).replaceAll(/;;;|;;/gu,";..;").replaceAll(/;$|'?\]|'$/gu,"").split(";").map((function(e){const t=e.match(/#(\d+)/u);return t&&t[1]?r[t[1]]:e}));return t[e]=i,t[e].concat()},p.prototype.safeVm={Script:class{constructor(e){this.code=e,this.ast=r(this.code)}runInNewContext(e){const t={...e};return a.evalAst(this.ast,t)}}};p.prototype.vm={Script:class{constructor(e){this.code=e}runInNewContext(e){let t=this.code;const r=Object.keys(e),i=[];!function(e,t,r){const i=e.length;for(let n=0;n<i;n++)r(e[n])&&t.push(e.splice(n--,1)[0])}(r,i,(t=>"function"==typeof e[t]));const n=r.map((t=>e[t]));t=i.reduce(((t,r)=>{let i=e[r].toString();return/function/u.test(i)||(i="function "+i),"var "+r+"="+i+";"+t}),"")+t,/(['"])use strict\1/u.test(t)||r.includes("arguments")||(t="var arguments = undefined;"+t),t=t.replace(/;\s*$/u,"");const s=t.lastIndexOf(";"),o=s>-1?t.slice(0,s+1)+" return "+t.slice(s+1):" return "+t;return new Function(...r,o)(...n)}}};export{p as JSONPath}; //# sourceMappingURL=index-browser-esm.min.js.map
dist/index-browser-esm.min.js.map+1 −1 modifieddist/index-browser-umd.cjs+3 −0 modified@@ -1297,6 +1297,9 @@ return ast.value; }, evalMemberExpression(ast, subs) { + if (ast.property.type === 'Identifier' && ast.property.name === 'constructor' || ast.object.type === 'Identifier' && ast.object.name === 'constructor') { + throw new Error("'constructor' property is disabled"); + } const prop = ast.computed ? SafeEval.evalAst(ast.property) // `object[property]` : ast.property.name; // `object.property` property is Identifier const obj = SafeEval.evalAst(ast.object, subs);
dist/index-browser-umd.min.cjs+1 −1 modified@@ -1,2 +1,2 @@ -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).JSONPath={})}(this,(function(e){"use strict";class t{static get version(){return"1.3.9"}static toString(){return"JavaScript Expression Parser (JSEP) v"+t.version}static addUnaryOp(e){return t.max_unop_len=Math.max(e.length,t.max_unop_len),t.unary_ops[e]=1,t}static addBinaryOp(e,r,i){return t.max_binop_len=Math.max(e.length,t.max_binop_len),t.binary_ops[e]=r,i?t.right_associative.add(e):t.right_associative.delete(e),t}static addIdentifierChar(e){return t.additional_identifier_chars.add(e),t}static addLiteral(e,r){return t.literals[e]=r,t}static removeUnaryOp(e){return delete t.unary_ops[e],e.length===t.max_unop_len&&(t.max_unop_len=t.getMaxKeyLen(t.unary_ops)),t}static removeAllUnaryOps(){return t.unary_ops={},t.max_unop_len=0,t}static removeIdentifierChar(e){return t.additional_identifier_chars.delete(e),t}static removeBinaryOp(e){return delete t.binary_ops[e],e.length===t.max_binop_len&&(t.max_binop_len=t.getMaxKeyLen(t.binary_ops)),t.right_associative.delete(e),t}static removeAllBinaryOps(){return t.binary_ops={},t.max_binop_len=0,t}static removeLiteral(e){return delete t.literals[e],t}static removeAllLiterals(){return t.literals={},t}get char(){return this.expr.charAt(this.index)}get code(){return this.expr.charCodeAt(this.index)}constructor(e){this.expr=e,this.index=0}static parse(e){return new t(e).parse()}static getMaxKeyLen(e){return Math.max(0,...Object.keys(e).map((e=>e.length)))}static isDecimalDigit(e){return e>=48&&e<=57}static binaryPrecedence(e){return t.binary_ops[e]||0}static isIdentifierStart(e){return e>=65&&e<=90||e>=97&&e<=122||e>=128&&!t.binary_ops[String.fromCharCode(e)]||t.additional_identifier_chars.has(String.fromCharCode(e))}static isIdentifierPart(e){return t.isIdentifierStart(e)||t.isDecimalDigit(e)}throwError(e){const t=new Error(e+" at character "+this.index);throw t.index=this.index,t.description=e,t}runHook(e,r){if(t.hooks[e]){const i={context:this,node:r};return t.hooks.run(e,i),i.node}return r}searchHook(e){if(t.hooks[e]){const r={context:this};return t.hooks[e].find((function(e){return e.call(r.context,r),r.node})),r.node}}gobbleSpaces(){let e=this.code;for(;e===t.SPACE_CODE||e===t.TAB_CODE||e===t.LF_CODE||e===t.CR_CODE;)e=this.expr.charCodeAt(++this.index);this.runHook("gobble-spaces")}parse(){this.runHook("before-all");const e=this.gobbleExpressions(),r=1===e.length?e[0]:{type:t.COMPOUND,body:e};return this.runHook("after-all",r)}gobbleExpressions(e){let r,i,n=[];for(;this.index<this.expr.length;)if(r=this.code,r===t.SEMCOL_CODE||r===t.COMMA_CODE)this.index++;else if(i=this.gobbleExpression())n.push(i);else if(this.index<this.expr.length){if(r===e)break;this.throwError('Unexpected "'+this.char+'"')}return n}gobbleExpression(){const e=this.searchHook("gobble-expression")||this.gobbleBinaryExpression();return this.gobbleSpaces(),this.runHook("after-expression",e)}gobbleBinaryOp(){this.gobbleSpaces();let e=this.expr.substr(this.index,t.max_binop_len),r=e.length;for(;r>0;){if(t.binary_ops.hasOwnProperty(e)&&(!t.isIdentifierStart(this.code)||this.index+e.length<this.expr.length&&!t.isIdentifierPart(this.expr.charCodeAt(this.index+e.length))))return this.index+=r,e;e=e.substr(0,--r)}return!1}gobbleBinaryExpression(){let e,r,i,n,s,o,a,h,l;if(o=this.gobbleToken(),!o)return o;if(r=this.gobbleBinaryOp(),!r)return o;for(s={value:r,prec:t.binaryPrecedence(r),right_a:t.right_associative.has(r)},a=this.gobbleToken(),a||this.throwError("Expected expression after "+r),n=[o,s,a];r=this.gobbleBinaryOp();){if(i=t.binaryPrecedence(r),0===i){this.index-=r.length;break}s={value:r,prec:i,right_a:t.right_associative.has(r)},l=r;const h=e=>s.right_a&&e.right_a?i>e.prec:i<=e.prec;for(;n.length>2&&h(n[n.length-2]);)a=n.pop(),r=n.pop().value,o=n.pop(),e={type:t.BINARY_EXP,operator:r,left:o,right:a},n.push(e);e=this.gobbleToken(),e||this.throwError("Expected expression after "+l),n.push(s,e)}for(h=n.length-1,e=n[h];h>1;)e={type:t.BINARY_EXP,operator:n[h-1].value,left:n[h-2],right:e},h-=2;return e}gobbleToken(){let e,r,i,n;if(this.gobbleSpaces(),n=this.searchHook("gobble-token"),n)return this.runHook("after-token",n);if(e=this.code,t.isDecimalDigit(e)||e===t.PERIOD_CODE)return this.gobbleNumericLiteral();if(e===t.SQUOTE_CODE||e===t.DQUOTE_CODE)n=this.gobbleStringLiteral();else if(e===t.OBRACK_CODE)n=this.gobbleArray();else{for(r=this.expr.substr(this.index,t.max_unop_len),i=r.length;i>0;){if(t.unary_ops.hasOwnProperty(r)&&(!t.isIdentifierStart(this.code)||this.index+r.length<this.expr.length&&!t.isIdentifierPart(this.expr.charCodeAt(this.index+r.length)))){this.index+=i;const e=this.gobbleToken();return e||this.throwError("missing unaryOp argument"),this.runHook("after-token",{type:t.UNARY_EXP,operator:r,argument:e,prefix:!0})}r=r.substr(0,--i)}t.isIdentifierStart(e)?(n=this.gobbleIdentifier(),t.literals.hasOwnProperty(n.name)?n={type:t.LITERAL,value:t.literals[n.name],raw:n.name}:n.name===t.this_str&&(n={type:t.THIS_EXP})):e===t.OPAREN_CODE&&(n=this.gobbleGroup())}return n?(n=this.gobbleTokenProperty(n),this.runHook("after-token",n)):this.runHook("after-token",!1)}gobbleTokenProperty(e){this.gobbleSpaces();let r=this.code;for(;r===t.PERIOD_CODE||r===t.OBRACK_CODE||r===t.OPAREN_CODE||r===t.QUMARK_CODE;){let i;if(r===t.QUMARK_CODE){if(this.expr.charCodeAt(this.index+1)!==t.PERIOD_CODE)break;i=!0,this.index+=2,this.gobbleSpaces(),r=this.code}this.index++,r===t.OBRACK_CODE?((e={type:t.MEMBER_EXP,computed:!0,object:e,property:this.gobbleExpression()}).property||this.throwError('Unexpected "'+this.char+'"'),this.gobbleSpaces(),r=this.code,r!==t.CBRACK_CODE&&this.throwError("Unclosed ["),this.index++):r===t.OPAREN_CODE?e={type:t.CALL_EXP,arguments:this.gobbleArguments(t.CPAREN_CODE),callee:e}:(r===t.PERIOD_CODE||i)&&(i&&this.index--,this.gobbleSpaces(),e={type:t.MEMBER_EXP,computed:!1,object:e,property:this.gobbleIdentifier()}),i&&(e.optional=!0),this.gobbleSpaces(),r=this.code}return e}gobbleNumericLiteral(){let e,r,i="";for(;t.isDecimalDigit(this.code);)i+=this.expr.charAt(this.index++);if(this.code===t.PERIOD_CODE)for(i+=this.expr.charAt(this.index++);t.isDecimalDigit(this.code);)i+=this.expr.charAt(this.index++);if(e=this.char,"e"===e||"E"===e){for(i+=this.expr.charAt(this.index++),e=this.char,"+"!==e&&"-"!==e||(i+=this.expr.charAt(this.index++));t.isDecimalDigit(this.code);)i+=this.expr.charAt(this.index++);t.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+i+this.char+")")}return r=this.code,t.isIdentifierStart(r)?this.throwError("Variable names cannot start with a number ("+i+this.char+")"):(r===t.PERIOD_CODE||1===i.length&&i.charCodeAt(0)===t.PERIOD_CODE)&&this.throwError("Unexpected period"),{type:t.LITERAL,value:parseFloat(i),raw:i}}gobbleStringLiteral(){let e="";const r=this.index,i=this.expr.charAt(this.index++);let n=!1;for(;this.index<this.expr.length;){let t=this.expr.charAt(this.index++);if(t===i){n=!0;break}if("\\"===t)switch(t=this.expr.charAt(this.index++),t){case"n":e+="\n";break;case"r":e+="\r";break;case"t":e+="\t";break;case"b":e+="\b";break;case"f":e+="\f";break;case"v":e+="\v";break;default:e+=t}else e+=t}return n||this.throwError('Unclosed quote after "'+e+'"'),{type:t.LITERAL,value:e,raw:this.expr.substring(r,this.index)}}gobbleIdentifier(){let e=this.code,r=this.index;for(t.isIdentifierStart(e)?this.index++:this.throwError("Unexpected "+this.char);this.index<this.expr.length&&(e=this.code,t.isIdentifierPart(e));)this.index++;return{type:t.IDENTIFIER,name:this.expr.slice(r,this.index)}}gobbleArguments(e){const r=[];let i=!1,n=0;for(;this.index<this.expr.length;){this.gobbleSpaces();let s=this.code;if(s===e){i=!0,this.index++,e===t.CPAREN_CODE&&n&&n>=r.length&&this.throwError("Unexpected token "+String.fromCharCode(e));break}if(s===t.COMMA_CODE){if(this.index++,n++,n!==r.length)if(e===t.CPAREN_CODE)this.throwError("Unexpected token ,");else if(e===t.CBRACK_CODE)for(let e=r.length;e<n;e++)r.push(null)}else if(r.length!==n&&0!==n)this.throwError("Expected comma");else{const e=this.gobbleExpression();e&&e.type!==t.COMPOUND||this.throwError("Expected comma"),r.push(e)}}return i||this.throwError("Expected "+String.fromCharCode(e)),r}gobbleGroup(){this.index++;let e=this.gobbleExpressions(t.CPAREN_CODE);if(this.code===t.CPAREN_CODE)return this.index++,1===e.length?e[0]:!!e.length&&{type:t.SEQUENCE_EXP,expressions:e};this.throwError("Unclosed (")}gobbleArray(){return this.index++,{type:t.ARRAY_EXP,elements:this.gobbleArguments(t.CBRACK_CODE)}}}const r=new class{add(e,t,r){if("string"!=typeof arguments[0])for(let e in arguments[0])this.add(e,arguments[0][e],arguments[1]);else(Array.isArray(e)?e:[e]).forEach((function(e){this[e]=this[e]||[],t&&this[e][r?"unshift":"push"](t)}),this)}run(e,t){this[e]=this[e]||[],this[e].forEach((function(e){e.call(t&&t.context?t.context:t,t)}))}};Object.assign(t,{hooks:r,plugins:new class{constructor(e){this.jsep=e,this.registered={}}register(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];t.forEach((e=>{if("object"!=typeof e||!e.name||!e.init)throw new Error("Invalid JSEP plugin format");this.registered[e.name]||(e.init(this.jsep),this.registered[e.name]=e)}))}}(t),COMPOUND:"Compound",SEQUENCE_EXP:"SequenceExpression",IDENTIFIER:"Identifier",MEMBER_EXP:"MemberExpression",LITERAL:"Literal",THIS_EXP:"ThisExpression",CALL_EXP:"CallExpression",UNARY_EXP:"UnaryExpression",BINARY_EXP:"BinaryExpression",ARRAY_EXP:"ArrayExpression",TAB_CODE:9,LF_CODE:10,CR_CODE:13,SPACE_CODE:32,PERIOD_CODE:46,COMMA_CODE:44,SQUOTE_CODE:39,DQUOTE_CODE:34,OPAREN_CODE:40,CPAREN_CODE:41,OBRACK_CODE:91,CBRACK_CODE:93,QUMARK_CODE:63,SEMCOL_CODE:59,COLON_CODE:58,unary_ops:{"-":1,"!":1,"~":1,"+":1},binary_ops:{"||":1,"&&":2,"|":3,"^":4,"&":5,"==":6,"!=":6,"===":6,"!==":6,"<":7,">":7,"<=":7,">=":7,"<<":8,">>":8,">>>":8,"+":9,"-":9,"*":10,"/":10,"%":10},right_associative:new Set,additional_identifier_chars:new Set(["$","_"]),literals:{true:!0,false:!1,null:null},this_str:"this"}),t.max_unop_len=t.getMaxKeyLen(t.unary_ops),t.max_binop_len=t.getMaxKeyLen(t.binary_ops);const i=e=>new t(e).parse(),n=Object.getOwnPropertyNames(class{});Object.getOwnPropertyNames(t).filter((e=>!n.includes(e)&&void 0===i[e])).forEach((e=>{i[e]=t[e]})),i.Jsep=t;var s={name:"ternary",init(e){e.hooks.add("after-expression",(function(t){if(t.node&&this.code===e.QUMARK_CODE){this.index++;const r=t.node,i=this.gobbleExpression();if(i||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===e.COLON_CODE){this.index++;const n=this.gobbleExpression();if(n||this.throwError("Expected expression"),t.node={type:"ConditionalExpression",test:r,consequent:i,alternate:n},r.operator&&e.binary_ops[r.operator]<=.9){let i=r;for(;i.right.operator&&e.binary_ops[i.right.operator]<=.9;)i=i.right;t.node.test=i.right,i.right=t.node,t.node=r}}else this.throwError("Expected :")}}))}};i.plugins.register(s);var o={name:"regex",init(e){e.hooks.add("gobble-token",(function(t){if(47===this.code){const r=++this.index;let i=!1;for(;this.index<this.expr.length;){if(47===this.code&&!i){const i=this.expr.slice(r,this.index);let n,s="";for(;++this.index<this.expr.length;){const e=this.code;if(!(e>=97&&e<=122||e>=65&&e<=90||e>=48&&e<=57))break;s+=this.char}try{n=new RegExp(i,s)}catch(e){this.throwError(e.message)}return t.node={type:e.LITERAL,value:n,raw:this.expr.slice(r-1,this.index)},t.node=this.gobbleTokenProperty(t.node),t.node}this.code===e.OBRACK_CODE?i=!0:i&&this.code===e.CBRACK_CODE&&(i=!1),this.index+=92===this.code?2:1}this.throwError("Unclosed Regex")}}))}};const a={name:"assignment",assignmentOperators:new Set(["=","*=","**=","/=","%=","+=","-=","<<=",">>=",">>>=","&=","^=","|="]),updateOperators:[43,45],assignmentPrecedence:.9,init(e){const t=[e.IDENTIFIER,e.MEMBER_EXP];function r(e){a.assignmentOperators.has(e.operator)?(e.type="AssignmentExpression",r(e.left),r(e.right)):e.operator||Object.values(e).forEach((e=>{e&&"object"==typeof e&&r(e)}))}a.assignmentOperators.forEach((t=>e.addBinaryOp(t,a.assignmentPrecedence,!0))),e.hooks.add("gobble-token",(function(e){const r=this.code;a.updateOperators.some((e=>e===r&&e===this.expr.charCodeAt(this.index+1)))&&(this.index+=2,e.node={type:"UpdateExpression",operator:43===r?"++":"--",argument:this.gobbleTokenProperty(this.gobbleIdentifier()),prefix:!0},e.node.argument&&t.includes(e.node.argument.type)||this.throwError(`Unexpected ${e.node.operator}`))})),e.hooks.add("after-token",(function(e){if(e.node){const r=this.code;a.updateOperators.some((e=>e===r&&e===this.expr.charCodeAt(this.index+1)))&&(t.includes(e.node.type)||this.throwError(`Unexpected ${e.node.operator}`),this.index+=2,e.node={type:"UpdateExpression",operator:43===r?"++":"--",argument:e.node,prefix:!1})}})),e.hooks.add("after-expression",(function(e){e.node&&r(e.node)}))}};i.plugins.register(o,a);const h={evalAst(e,t){switch(e.type){case"BinaryExpression":case"LogicalExpression":return h.evalBinaryExpression(e,t);case"Compound":return h.evalCompound(e,t);case"ConditionalExpression":return h.evalConditionalExpression(e,t);case"Identifier":return h.evalIdentifier(e,t);case"Literal":return h.evalLiteral(e,t);case"MemberExpression":return h.evalMemberExpression(e,t);case"UnaryExpression":return h.evalUnaryExpression(e,t);case"ArrayExpression":return h.evalArrayExpression(e,t);case"CallExpression":return h.evalCallExpression(e,t);case"AssignmentExpression":return h.evalAssignmentExpression(e,t);default:throw SyntaxError("Unexpected expression",e)}},evalBinaryExpression:(e,t)=>({"||":(e,t)=>e||t(),"&&":(e,t)=>e&&t(),"|":(e,t)=>e|t(),"^":(e,t)=>e^t(),"&":(e,t)=>e&t(),"==":(e,t)=>e==t(),"!=":(e,t)=>e!=t(),"===":(e,t)=>e===t(),"!==":(e,t)=>e!==t(),"<":(e,t)=>e<t(),">":(e,t)=>e>t(),"<=":(e,t)=>e<=t(),">=":(e,t)=>e>=t(),"<<":(e,t)=>e<<t(),">>":(e,t)=>e>>t(),">>>":(e,t)=>e>>>t(),"+":(e,t)=>e+t(),"-":(e,t)=>e-t(),"*":(e,t)=>e*t(),"/":(e,t)=>e/t(),"%":(e,t)=>e%t()}[e.operator](h.evalAst(e.left,t),(()=>h.evalAst(e.right,t)))),evalCompound(e,t){let r;for(let i=0;i<e.body.length;i++){"Identifier"===e.body[i].type&&["var","let","const"].includes(e.body[i].name)&&e.body[i+1]&&"AssignmentExpression"===e.body[i+1].type&&(i+=1);const n=e.body[i];r=h.evalAst(n,t)}return r},evalConditionalExpression:(e,t)=>h.evalAst(e.test,t)?h.evalAst(e.consequent,t):h.evalAst(e.alternate,t),evalIdentifier(e,t){if(e.name in t)return t[e.name];throw ReferenceError(`${e.name} is not defined`)},evalLiteral:e=>e.value,evalMemberExpression(e,t){const r=e.computed?h.evalAst(e.property):e.property.name,i=h.evalAst(e.object,t),n=i[r];if("function"==typeof n){if(i===Function&&"bind"===r)throw new Error("Function.prototype.bind is disabled");if(i===Function&&("call"===r||"apply"===r))throw new Error("Function.prototype.call and Function.prototype.apply are disabled");return n===Function?n:n.bind(i)}return n},evalUnaryExpression:(e,t)=>({"-":e=>-h.evalAst(e,t),"!":e=>!h.evalAst(e,t),"~":e=>~h.evalAst(e,t),"+":e=>+h.evalAst(e,t)}[e.operator](e.argument)),evalArrayExpression:(e,t)=>e.elements.map((e=>h.evalAst(e,t))),evalCallExpression(e,t){const r=e.arguments.map((e=>h.evalAst(e,t))),i=h.evalAst(e.callee,t);if(i===Function)throw new Error("Function constructor is disabled");return i(...r)},evalAssignmentExpression(e,t){if("Identifier"!==e.left.type)throw SyntaxError("Invalid left-hand side in assignment");const r=e.left.name;if("__proto__"===r)throw new Error("Assignment to __proto__ is disabled");const i=h.evalAst(e.right,t);return t[r]=i,t[r]}};function l(e,t){return(e=e.slice()).push(t),e}function c(e,t){return(t=t.slice()).unshift(e),t}class p extends Error{constructor(e){super('JSONPath should not be called with "new" (it prevents return of (unwrapped) scalar values)'),this.avoidNew=!0,this.value=e,this.name="NewError"}}function u(e,t,r,i,n){if(!(this instanceof u))try{return new u(e,t,r,i,n)}catch(e){if(!e.avoidNew)throw e;return e.value}"string"==typeof e&&(n=i,i=r,r=t,t=e,e=null);const s=e&&"object"==typeof e;if(e=e||{},this.json=e.json||r,this.path=e.path||t,this.resultType=e.resultType||"value",this.flatten=e.flatten||!1,this.wrap=!Object.hasOwn(e,"wrap")||e.wrap,this.sandbox=e.sandbox||{},this.eval=void 0===e.eval?"safe":e.eval,this.ignoreEvalErrors=void 0!==e.ignoreEvalErrors&&e.ignoreEvalErrors,this.parent=e.parent||null,this.parentProperty=e.parentProperty||null,this.callback=e.callback||i||null,this.otherTypeCallback=e.otherTypeCallback||n||function(){throw new TypeError("You must supply an otherTypeCallback callback option with the @other() operator.")},!1!==e.autostart){const i={path:s?e.path:t};s?"json"in e&&(i.json=e.json):i.json=r;const n=this.evaluate(i);if(!n||"object"!=typeof n)throw new p(n);return n}}u.prototype.evaluate=function(e,t,r,i){let n=this.parent,s=this.parentProperty,{flatten:o,wrap:a}=this;if(this.currResultType=this.resultType,this.currEval=this.eval,this.currSandbox=this.sandbox,r=r||this.callback,this.currOtherTypeCallback=i||this.otherTypeCallback,t=t||this.json,(e=e||this.path)&&"object"==typeof e&&!Array.isArray(e)){if(!e.path&&""!==e.path)throw new TypeError('You must supply a "path" property when providing an object argument to JSONPath.evaluate().');if(!Object.hasOwn(e,"json"))throw new TypeError('You must supply a "json" property when providing an object argument to JSONPath.evaluate().');({json:t}=e),o=Object.hasOwn(e,"flatten")?e.flatten:o,this.currResultType=Object.hasOwn(e,"resultType")?e.resultType:this.currResultType,this.currSandbox=Object.hasOwn(e,"sandbox")?e.sandbox:this.currSandbox,a=Object.hasOwn(e,"wrap")?e.wrap:a,this.currEval=Object.hasOwn(e,"eval")?e.eval:this.currEval,r=Object.hasOwn(e,"callback")?e.callback:r,this.currOtherTypeCallback=Object.hasOwn(e,"otherTypeCallback")?e.otherTypeCallback:this.currOtherTypeCallback,n=Object.hasOwn(e,"parent")?e.parent:n,s=Object.hasOwn(e,"parentProperty")?e.parentProperty:s,e=e.path}if(n=n||null,s=s||null,Array.isArray(e)&&(e=u.toPathString(e)),!e&&""!==e||!t)return;const h=u.toPathArray(e);"$"===h[0]&&h.length>1&&h.shift(),this._hasParentSelector=null;const l=this._trace(h,t,["$"],n,s,r).filter((function(e){return e&&!e.isParentSelector}));return l.length?a||1!==l.length||l[0].hasArrExpr?l.reduce(((e,t)=>{const r=this._getPreferredOutput(t);return o&&Array.isArray(r)?e=e.concat(r):e.push(r),e}),[]):this._getPreferredOutput(l[0]):a?[]:void 0},u.prototype._getPreferredOutput=function(e){const t=this.currResultType;switch(t){case"all":{const t=Array.isArray(e.path)?e.path:u.toPathArray(e.path);return e.pointer=u.toPointer(t),e.path="string"==typeof e.path?e.path:u.toPathString(e.path),e}case"value":case"parent":case"parentProperty":return e[t];case"path":return u.toPathString(e[t]);case"pointer":return u.toPointer(e.path);default:throw new TypeError("Unknown result type")}},u.prototype._handleCallback=function(e,t,r){if(t){const i=this._getPreferredOutput(e);e.path="string"==typeof e.path?e.path:u.toPathString(e.path),t(i,r,e)}},u.prototype._trace=function(e,t,r,i,n,s,o,a){let h;if(!e.length)return h={path:r,value:t,parent:i,parentProperty:n,hasArrExpr:o},this._handleCallback(h,s,"value"),h;const p=e[0],u=e.slice(1),d=[];function f(e){Array.isArray(e)?e.forEach((e=>{d.push(e)})):d.push(e)}if(("string"!=typeof p||a)&&t&&Object.hasOwn(t,p))f(this._trace(u,t[p],l(r,p),t,p,s,o));else if("*"===p)this._walk(t,(e=>{f(this._trace(u,t[e],l(r,e),t,e,s,!0,!0))}));else if(".."===p)f(this._trace(u,t,r,i,n,s,o)),this._walk(t,(i=>{"object"==typeof t[i]&&f(this._trace(e.slice(),t[i],l(r,i),t,i,s,!0))}));else{if("^"===p)return this._hasParentSelector=!0,{path:r.slice(0,-1),expr:u,isParentSelector:!0};if("~"===p)return h={path:l(r,p),value:n,parent:i,parentProperty:null},this._handleCallback(h,s,"property"),h;if("$"===p)f(this._trace(u,t,r,null,null,s,o));else if(/^(-?\d*):(-?\d*):?(\d*)$/u.test(p))f(this._slice(p,u,t,r,i,n,s));else if(0===p.indexOf("?(")){if(!1===this.currEval)throw new Error("Eval [?(expr)] prevented in JSONPath expression.");const e=p.replace(/^\?\((.*?)\)$/u,"$1"),o=/@.?([^?]*)[['](\??\(.*?\))(?!.\)\])[\]']/gu.exec(e);o?this._walk(t,(e=>{const a=[o[2]],h=o[1]?t[e][o[1]]:t[e];this._trace(a,h,r,i,n,s,!0).length>0&&f(this._trace(u,t[e],l(r,e),t,e,s,!0))})):this._walk(t,(o=>{this._eval(e,t[o],o,r,i,n)&&f(this._trace(u,t[o],l(r,o),t,o,s,!0))}))}else if("("===p[0]){if(!1===this.currEval)throw new Error("Eval [(expr)] prevented in JSONPath expression.");f(this._trace(c(this._eval(p,t,r.at(-1),r.slice(0,-1),i,n),u),t,r,i,n,s,o))}else if("@"===p[0]){let e=!1;const o=p.slice(1,-2);switch(o){case"scalar":t&&["object","function"].includes(typeof t)||(e=!0);break;case"boolean":case"string":case"undefined":case"function":typeof t===o&&(e=!0);break;case"integer":!Number.isFinite(t)||t%1||(e=!0);break;case"number":Number.isFinite(t)&&(e=!0);break;case"nonFinite":"number"!=typeof t||Number.isFinite(t)||(e=!0);break;case"object":t&&typeof t===o&&(e=!0);break;case"array":Array.isArray(t)&&(e=!0);break;case"other":e=this.currOtherTypeCallback(t,r,i,n);break;case"null":null===t&&(e=!0);break;default:throw new TypeError("Unknown value type "+o)}if(e)return h={path:r,value:t,parent:i,parentProperty:n},this._handleCallback(h,s,"value"),h}else if("`"===p[0]&&t&&Object.hasOwn(t,p.slice(1))){const e=p.slice(1);f(this._trace(u,t[e],l(r,e),t,e,s,o,!0))}else if(p.includes(",")){const e=p.split(",");for(const o of e)f(this._trace(c(o,u),t,r,i,n,s,!0))}else!a&&t&&Object.hasOwn(t,p)&&f(this._trace(u,t[p],l(r,p),t,p,s,o,!0))}if(this._hasParentSelector)for(let e=0;e<d.length;e++){const r=d[e];if(r&&r.isParentSelector){const a=this._trace(r.expr,t,r.path,i,n,s,o);if(Array.isArray(a)){d[e]=a[0];const t=a.length;for(let r=1;r<t;r++)e++,d.splice(e,0,a[r])}else d[e]=a}}return d},u.prototype._walk=function(e,t){if(Array.isArray(e)){const r=e.length;for(let e=0;e<r;e++)t(e)}else e&&"object"==typeof e&&Object.keys(e).forEach((e=>{t(e)}))},u.prototype._slice=function(e,t,r,i,n,s,o){if(!Array.isArray(r))return;const a=r.length,h=e.split(":"),l=h[2]&&Number.parseInt(h[2])||1;let p=h[0]&&Number.parseInt(h[0])||0,u=h[1]&&Number.parseInt(h[1])||a;p=p<0?Math.max(0,p+a):Math.min(a,p),u=u<0?Math.max(0,u+a):Math.min(a,u);const d=[];for(let e=p;e<u;e+=l){this._trace(c(e,t),r,i,n,s,o,!0).forEach((e=>{d.push(e)}))}return d},u.prototype._eval=function(e,t,r,i,n,s){this.currSandbox._$_parentProperty=s,this.currSandbox._$_parent=n,this.currSandbox._$_property=r,this.currSandbox._$_root=this.json,this.currSandbox._$_v=t;const o=e.includes("@path");o&&(this.currSandbox._$_path=u.toPathString(i.concat([r])));const a=this.currEval+"Script:"+e;if(!u.cache[a]){let t=e.replaceAll("@parentProperty","_$_parentProperty").replaceAll("@parent","_$_parent").replaceAll("@property","_$_property").replaceAll("@root","_$_root").replaceAll(/@([.\s)[])/gu,"_$_v$1");if(o&&(t=t.replaceAll("@path","_$_path")),"safe"===this.currEval||!0===this.currEval||void 0===this.currEval)u.cache[a]=new this.safeVm.Script(t);else if("native"===this.currEval)u.cache[a]=new this.vm.Script(t);else if("function"==typeof this.currEval&&this.currEval.prototype&&Object.hasOwn(this.currEval.prototype,"runInNewContext")){const e=this.currEval;u.cache[a]=new e(t)}else{if("function"!=typeof this.currEval)throw new TypeError(`Unknown "eval" property "${this.currEval}"`);u.cache[a]={runInNewContext:e=>this.currEval(t,e)}}}try{return u.cache[a].runInNewContext(this.currSandbox)}catch(t){if(this.ignoreEvalErrors)return!1;throw new Error("jsonPath: "+t.message+": "+e)}},u.cache={},u.toPathString=function(e){const t=e,r=t.length;let i="$";for(let e=1;e<r;e++)/^(~|\^|@.*?\(\))$/u.test(t[e])||(i+=/^[0-9*]+$/u.test(t[e])?"["+t[e]+"]":"['"+t[e]+"']");return i},u.toPointer=function(e){const t=e,r=t.length;let i="";for(let e=1;e<r;e++)/^(~|\^|@.*?\(\))$/u.test(t[e])||(i+="/"+t[e].toString().replaceAll("~","~0").replaceAll("/","~1"));return i},u.toPathArray=function(e){const{cache:t}=u;if(t[e])return t[e].concat();const r=[],i=e.replaceAll(/@(?:null|boolean|number|string|integer|undefined|nonFinite|scalar|array|object|function|other)\(\)/gu,";$&;").replaceAll(/[['](\??\(.*?\))[\]'](?!.\])/gu,(function(e,t){return"[#"+(r.push(t)-1)+"]"})).replaceAll(/\[['"]([^'\]]*)['"]\]/gu,(function(e,t){return"['"+t.replaceAll(".","%@%").replaceAll("~","%%@@%%")+"']"})).replaceAll("~",";~;").replaceAll(/['"]?\.['"]?(?![^[]*\])|\[['"]?/gu,";").replaceAll("%@%",".").replaceAll("%%@@%%","~").replaceAll(/(?:;)?(\^+)(?:;)?/gu,(function(e,t){return";"+t.split("").join(";")+";"})).replaceAll(/;;;|;;/gu,";..;").replaceAll(/;$|'?\]|'$/gu,"").split(";").map((function(e){const t=e.match(/#(\d+)/u);return t&&t[1]?r[t[1]]:e}));return t[e]=i,t[e].concat()},u.prototype.safeVm={Script:class{constructor(e){this.code=e,this.ast=i(this.code)}runInNewContext(e){const t={...e};return h.evalAst(this.ast,t)}}};u.prototype.vm={Script:class{constructor(e){this.code=e}runInNewContext(e){let t=this.code;const r=Object.keys(e),i=[];!function(e,t,r){const i=e.length;for(let n=0;n<i;n++)r(e[n])&&t.push(e.splice(n--,1)[0])}(r,i,(t=>"function"==typeof e[t]));const n=r.map((t=>e[t]));t=i.reduce(((t,r)=>{let i=e[r].toString();return/function/u.test(i)||(i="function "+i),"var "+r+"="+i+";"+t}),"")+t,/(['"])use strict\1/u.test(t)||r.includes("arguments")||(t="var arguments = undefined;"+t),t=t.replace(/;\s*$/u,"");const s=t.lastIndexOf(";"),o=s>-1?t.slice(0,s+1)+" return "+t.slice(s+1):" return "+t;return new Function(...r,o)(...n)}}},e.JSONPath=u})); +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).JSONPath={})}(this,(function(e){"use strict";class t{static get version(){return"1.3.9"}static toString(){return"JavaScript Expression Parser (JSEP) v"+t.version}static addUnaryOp(e){return t.max_unop_len=Math.max(e.length,t.max_unop_len),t.unary_ops[e]=1,t}static addBinaryOp(e,r,n){return t.max_binop_len=Math.max(e.length,t.max_binop_len),t.binary_ops[e]=r,n?t.right_associative.add(e):t.right_associative.delete(e),t}static addIdentifierChar(e){return t.additional_identifier_chars.add(e),t}static addLiteral(e,r){return t.literals[e]=r,t}static removeUnaryOp(e){return delete t.unary_ops[e],e.length===t.max_unop_len&&(t.max_unop_len=t.getMaxKeyLen(t.unary_ops)),t}static removeAllUnaryOps(){return t.unary_ops={},t.max_unop_len=0,t}static removeIdentifierChar(e){return t.additional_identifier_chars.delete(e),t}static removeBinaryOp(e){return delete t.binary_ops[e],e.length===t.max_binop_len&&(t.max_binop_len=t.getMaxKeyLen(t.binary_ops)),t.right_associative.delete(e),t}static removeAllBinaryOps(){return t.binary_ops={},t.max_binop_len=0,t}static removeLiteral(e){return delete t.literals[e],t}static removeAllLiterals(){return t.literals={},t}get char(){return this.expr.charAt(this.index)}get code(){return this.expr.charCodeAt(this.index)}constructor(e){this.expr=e,this.index=0}static parse(e){return new t(e).parse()}static getMaxKeyLen(e){return Math.max(0,...Object.keys(e).map((e=>e.length)))}static isDecimalDigit(e){return e>=48&&e<=57}static binaryPrecedence(e){return t.binary_ops[e]||0}static isIdentifierStart(e){return e>=65&&e<=90||e>=97&&e<=122||e>=128&&!t.binary_ops[String.fromCharCode(e)]||t.additional_identifier_chars.has(String.fromCharCode(e))}static isIdentifierPart(e){return t.isIdentifierStart(e)||t.isDecimalDigit(e)}throwError(e){const t=new Error(e+" at character "+this.index);throw t.index=this.index,t.description=e,t}runHook(e,r){if(t.hooks[e]){const n={context:this,node:r};return t.hooks.run(e,n),n.node}return r}searchHook(e){if(t.hooks[e]){const r={context:this};return t.hooks[e].find((function(e){return e.call(r.context,r),r.node})),r.node}}gobbleSpaces(){let e=this.code;for(;e===t.SPACE_CODE||e===t.TAB_CODE||e===t.LF_CODE||e===t.CR_CODE;)e=this.expr.charCodeAt(++this.index);this.runHook("gobble-spaces")}parse(){this.runHook("before-all");const e=this.gobbleExpressions(),r=1===e.length?e[0]:{type:t.COMPOUND,body:e};return this.runHook("after-all",r)}gobbleExpressions(e){let r,n,i=[];for(;this.index<this.expr.length;)if(r=this.code,r===t.SEMCOL_CODE||r===t.COMMA_CODE)this.index++;else if(n=this.gobbleExpression())i.push(n);else if(this.index<this.expr.length){if(r===e)break;this.throwError('Unexpected "'+this.char+'"')}return i}gobbleExpression(){const e=this.searchHook("gobble-expression")||this.gobbleBinaryExpression();return this.gobbleSpaces(),this.runHook("after-expression",e)}gobbleBinaryOp(){this.gobbleSpaces();let e=this.expr.substr(this.index,t.max_binop_len),r=e.length;for(;r>0;){if(t.binary_ops.hasOwnProperty(e)&&(!t.isIdentifierStart(this.code)||this.index+e.length<this.expr.length&&!t.isIdentifierPart(this.expr.charCodeAt(this.index+e.length))))return this.index+=r,e;e=e.substr(0,--r)}return!1}gobbleBinaryExpression(){let e,r,n,i,s,o,a,h,l;if(o=this.gobbleToken(),!o)return o;if(r=this.gobbleBinaryOp(),!r)return o;for(s={value:r,prec:t.binaryPrecedence(r),right_a:t.right_associative.has(r)},a=this.gobbleToken(),a||this.throwError("Expected expression after "+r),i=[o,s,a];r=this.gobbleBinaryOp();){if(n=t.binaryPrecedence(r),0===n){this.index-=r.length;break}s={value:r,prec:n,right_a:t.right_associative.has(r)},l=r;const h=e=>s.right_a&&e.right_a?n>e.prec:n<=e.prec;for(;i.length>2&&h(i[i.length-2]);)a=i.pop(),r=i.pop().value,o=i.pop(),e={type:t.BINARY_EXP,operator:r,left:o,right:a},i.push(e);e=this.gobbleToken(),e||this.throwError("Expected expression after "+l),i.push(s,e)}for(h=i.length-1,e=i[h];h>1;)e={type:t.BINARY_EXP,operator:i[h-1].value,left:i[h-2],right:e},h-=2;return e}gobbleToken(){let e,r,n,i;if(this.gobbleSpaces(),i=this.searchHook("gobble-token"),i)return this.runHook("after-token",i);if(e=this.code,t.isDecimalDigit(e)||e===t.PERIOD_CODE)return this.gobbleNumericLiteral();if(e===t.SQUOTE_CODE||e===t.DQUOTE_CODE)i=this.gobbleStringLiteral();else if(e===t.OBRACK_CODE)i=this.gobbleArray();else{for(r=this.expr.substr(this.index,t.max_unop_len),n=r.length;n>0;){if(t.unary_ops.hasOwnProperty(r)&&(!t.isIdentifierStart(this.code)||this.index+r.length<this.expr.length&&!t.isIdentifierPart(this.expr.charCodeAt(this.index+r.length)))){this.index+=n;const e=this.gobbleToken();return e||this.throwError("missing unaryOp argument"),this.runHook("after-token",{type:t.UNARY_EXP,operator:r,argument:e,prefix:!0})}r=r.substr(0,--n)}t.isIdentifierStart(e)?(i=this.gobbleIdentifier(),t.literals.hasOwnProperty(i.name)?i={type:t.LITERAL,value:t.literals[i.name],raw:i.name}:i.name===t.this_str&&(i={type:t.THIS_EXP})):e===t.OPAREN_CODE&&(i=this.gobbleGroup())}return i?(i=this.gobbleTokenProperty(i),this.runHook("after-token",i)):this.runHook("after-token",!1)}gobbleTokenProperty(e){this.gobbleSpaces();let r=this.code;for(;r===t.PERIOD_CODE||r===t.OBRACK_CODE||r===t.OPAREN_CODE||r===t.QUMARK_CODE;){let n;if(r===t.QUMARK_CODE){if(this.expr.charCodeAt(this.index+1)!==t.PERIOD_CODE)break;n=!0,this.index+=2,this.gobbleSpaces(),r=this.code}this.index++,r===t.OBRACK_CODE?((e={type:t.MEMBER_EXP,computed:!0,object:e,property:this.gobbleExpression()}).property||this.throwError('Unexpected "'+this.char+'"'),this.gobbleSpaces(),r=this.code,r!==t.CBRACK_CODE&&this.throwError("Unclosed ["),this.index++):r===t.OPAREN_CODE?e={type:t.CALL_EXP,arguments:this.gobbleArguments(t.CPAREN_CODE),callee:e}:(r===t.PERIOD_CODE||n)&&(n&&this.index--,this.gobbleSpaces(),e={type:t.MEMBER_EXP,computed:!1,object:e,property:this.gobbleIdentifier()}),n&&(e.optional=!0),this.gobbleSpaces(),r=this.code}return e}gobbleNumericLiteral(){let e,r,n="";for(;t.isDecimalDigit(this.code);)n+=this.expr.charAt(this.index++);if(this.code===t.PERIOD_CODE)for(n+=this.expr.charAt(this.index++);t.isDecimalDigit(this.code);)n+=this.expr.charAt(this.index++);if(e=this.char,"e"===e||"E"===e){for(n+=this.expr.charAt(this.index++),e=this.char,"+"!==e&&"-"!==e||(n+=this.expr.charAt(this.index++));t.isDecimalDigit(this.code);)n+=this.expr.charAt(this.index++);t.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+n+this.char+")")}return r=this.code,t.isIdentifierStart(r)?this.throwError("Variable names cannot start with a number ("+n+this.char+")"):(r===t.PERIOD_CODE||1===n.length&&n.charCodeAt(0)===t.PERIOD_CODE)&&this.throwError("Unexpected period"),{type:t.LITERAL,value:parseFloat(n),raw:n}}gobbleStringLiteral(){let e="";const r=this.index,n=this.expr.charAt(this.index++);let i=!1;for(;this.index<this.expr.length;){let t=this.expr.charAt(this.index++);if(t===n){i=!0;break}if("\\"===t)switch(t=this.expr.charAt(this.index++),t){case"n":e+="\n";break;case"r":e+="\r";break;case"t":e+="\t";break;case"b":e+="\b";break;case"f":e+="\f";break;case"v":e+="\v";break;default:e+=t}else e+=t}return i||this.throwError('Unclosed quote after "'+e+'"'),{type:t.LITERAL,value:e,raw:this.expr.substring(r,this.index)}}gobbleIdentifier(){let e=this.code,r=this.index;for(t.isIdentifierStart(e)?this.index++:this.throwError("Unexpected "+this.char);this.index<this.expr.length&&(e=this.code,t.isIdentifierPart(e));)this.index++;return{type:t.IDENTIFIER,name:this.expr.slice(r,this.index)}}gobbleArguments(e){const r=[];let n=!1,i=0;for(;this.index<this.expr.length;){this.gobbleSpaces();let s=this.code;if(s===e){n=!0,this.index++,e===t.CPAREN_CODE&&i&&i>=r.length&&this.throwError("Unexpected token "+String.fromCharCode(e));break}if(s===t.COMMA_CODE){if(this.index++,i++,i!==r.length)if(e===t.CPAREN_CODE)this.throwError("Unexpected token ,");else if(e===t.CBRACK_CODE)for(let e=r.length;e<i;e++)r.push(null)}else if(r.length!==i&&0!==i)this.throwError("Expected comma");else{const e=this.gobbleExpression();e&&e.type!==t.COMPOUND||this.throwError("Expected comma"),r.push(e)}}return n||this.throwError("Expected "+String.fromCharCode(e)),r}gobbleGroup(){this.index++;let e=this.gobbleExpressions(t.CPAREN_CODE);if(this.code===t.CPAREN_CODE)return this.index++,1===e.length?e[0]:!!e.length&&{type:t.SEQUENCE_EXP,expressions:e};this.throwError("Unclosed (")}gobbleArray(){return this.index++,{type:t.ARRAY_EXP,elements:this.gobbleArguments(t.CBRACK_CODE)}}}const r=new class{add(e,t,r){if("string"!=typeof arguments[0])for(let e in arguments[0])this.add(e,arguments[0][e],arguments[1]);else(Array.isArray(e)?e:[e]).forEach((function(e){this[e]=this[e]||[],t&&this[e][r?"unshift":"push"](t)}),this)}run(e,t){this[e]=this[e]||[],this[e].forEach((function(e){e.call(t&&t.context?t.context:t,t)}))}};Object.assign(t,{hooks:r,plugins:new class{constructor(e){this.jsep=e,this.registered={}}register(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];t.forEach((e=>{if("object"!=typeof e||!e.name||!e.init)throw new Error("Invalid JSEP plugin format");this.registered[e.name]||(e.init(this.jsep),this.registered[e.name]=e)}))}}(t),COMPOUND:"Compound",SEQUENCE_EXP:"SequenceExpression",IDENTIFIER:"Identifier",MEMBER_EXP:"MemberExpression",LITERAL:"Literal",THIS_EXP:"ThisExpression",CALL_EXP:"CallExpression",UNARY_EXP:"UnaryExpression",BINARY_EXP:"BinaryExpression",ARRAY_EXP:"ArrayExpression",TAB_CODE:9,LF_CODE:10,CR_CODE:13,SPACE_CODE:32,PERIOD_CODE:46,COMMA_CODE:44,SQUOTE_CODE:39,DQUOTE_CODE:34,OPAREN_CODE:40,CPAREN_CODE:41,OBRACK_CODE:91,CBRACK_CODE:93,QUMARK_CODE:63,SEMCOL_CODE:59,COLON_CODE:58,unary_ops:{"-":1,"!":1,"~":1,"+":1},binary_ops:{"||":1,"&&":2,"|":3,"^":4,"&":5,"==":6,"!=":6,"===":6,"!==":6,"<":7,">":7,"<=":7,">=":7,"<<":8,">>":8,">>>":8,"+":9,"-":9,"*":10,"/":10,"%":10},right_associative:new Set,additional_identifier_chars:new Set(["$","_"]),literals:{true:!0,false:!1,null:null},this_str:"this"}),t.max_unop_len=t.getMaxKeyLen(t.unary_ops),t.max_binop_len=t.getMaxKeyLen(t.binary_ops);const n=e=>new t(e).parse(),i=Object.getOwnPropertyNames(class{});Object.getOwnPropertyNames(t).filter((e=>!i.includes(e)&&void 0===n[e])).forEach((e=>{n[e]=t[e]})),n.Jsep=t;var s={name:"ternary",init(e){e.hooks.add("after-expression",(function(t){if(t.node&&this.code===e.QUMARK_CODE){this.index++;const r=t.node,n=this.gobbleExpression();if(n||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===e.COLON_CODE){this.index++;const i=this.gobbleExpression();if(i||this.throwError("Expected expression"),t.node={type:"ConditionalExpression",test:r,consequent:n,alternate:i},r.operator&&e.binary_ops[r.operator]<=.9){let n=r;for(;n.right.operator&&e.binary_ops[n.right.operator]<=.9;)n=n.right;t.node.test=n.right,n.right=t.node,t.node=r}}else this.throwError("Expected :")}}))}};n.plugins.register(s);var o={name:"regex",init(e){e.hooks.add("gobble-token",(function(t){if(47===this.code){const r=++this.index;let n=!1;for(;this.index<this.expr.length;){if(47===this.code&&!n){const n=this.expr.slice(r,this.index);let i,s="";for(;++this.index<this.expr.length;){const e=this.code;if(!(e>=97&&e<=122||e>=65&&e<=90||e>=48&&e<=57))break;s+=this.char}try{i=new RegExp(n,s)}catch(e){this.throwError(e.message)}return t.node={type:e.LITERAL,value:i,raw:this.expr.slice(r-1,this.index)},t.node=this.gobbleTokenProperty(t.node),t.node}this.code===e.OBRACK_CODE?n=!0:n&&this.code===e.CBRACK_CODE&&(n=!1),this.index+=92===this.code?2:1}this.throwError("Unclosed Regex")}}))}};const a={name:"assignment",assignmentOperators:new Set(["=","*=","**=","/=","%=","+=","-=","<<=",">>=",">>>=","&=","^=","|="]),updateOperators:[43,45],assignmentPrecedence:.9,init(e){const t=[e.IDENTIFIER,e.MEMBER_EXP];function r(e){a.assignmentOperators.has(e.operator)?(e.type="AssignmentExpression",r(e.left),r(e.right)):e.operator||Object.values(e).forEach((e=>{e&&"object"==typeof e&&r(e)}))}a.assignmentOperators.forEach((t=>e.addBinaryOp(t,a.assignmentPrecedence,!0))),e.hooks.add("gobble-token",(function(e){const r=this.code;a.updateOperators.some((e=>e===r&&e===this.expr.charCodeAt(this.index+1)))&&(this.index+=2,e.node={type:"UpdateExpression",operator:43===r?"++":"--",argument:this.gobbleTokenProperty(this.gobbleIdentifier()),prefix:!0},e.node.argument&&t.includes(e.node.argument.type)||this.throwError(`Unexpected ${e.node.operator}`))})),e.hooks.add("after-token",(function(e){if(e.node){const r=this.code;a.updateOperators.some((e=>e===r&&e===this.expr.charCodeAt(this.index+1)))&&(t.includes(e.node.type)||this.throwError(`Unexpected ${e.node.operator}`),this.index+=2,e.node={type:"UpdateExpression",operator:43===r?"++":"--",argument:e.node,prefix:!1})}})),e.hooks.add("after-expression",(function(e){e.node&&r(e.node)}))}};n.plugins.register(o,a);const h={evalAst(e,t){switch(e.type){case"BinaryExpression":case"LogicalExpression":return h.evalBinaryExpression(e,t);case"Compound":return h.evalCompound(e,t);case"ConditionalExpression":return h.evalConditionalExpression(e,t);case"Identifier":return h.evalIdentifier(e,t);case"Literal":return h.evalLiteral(e,t);case"MemberExpression":return h.evalMemberExpression(e,t);case"UnaryExpression":return h.evalUnaryExpression(e,t);case"ArrayExpression":return h.evalArrayExpression(e,t);case"CallExpression":return h.evalCallExpression(e,t);case"AssignmentExpression":return h.evalAssignmentExpression(e,t);default:throw SyntaxError("Unexpected expression",e)}},evalBinaryExpression:(e,t)=>({"||":(e,t)=>e||t(),"&&":(e,t)=>e&&t(),"|":(e,t)=>e|t(),"^":(e,t)=>e^t(),"&":(e,t)=>e&t(),"==":(e,t)=>e==t(),"!=":(e,t)=>e!=t(),"===":(e,t)=>e===t(),"!==":(e,t)=>e!==t(),"<":(e,t)=>e<t(),">":(e,t)=>e>t(),"<=":(e,t)=>e<=t(),">=":(e,t)=>e>=t(),"<<":(e,t)=>e<<t(),">>":(e,t)=>e>>t(),">>>":(e,t)=>e>>>t(),"+":(e,t)=>e+t(),"-":(e,t)=>e-t(),"*":(e,t)=>e*t(),"/":(e,t)=>e/t(),"%":(e,t)=>e%t()}[e.operator](h.evalAst(e.left,t),(()=>h.evalAst(e.right,t)))),evalCompound(e,t){let r;for(let n=0;n<e.body.length;n++){"Identifier"===e.body[n].type&&["var","let","const"].includes(e.body[n].name)&&e.body[n+1]&&"AssignmentExpression"===e.body[n+1].type&&(n+=1);const i=e.body[n];r=h.evalAst(i,t)}return r},evalConditionalExpression:(e,t)=>h.evalAst(e.test,t)?h.evalAst(e.consequent,t):h.evalAst(e.alternate,t),evalIdentifier(e,t){if(e.name in t)return t[e.name];throw ReferenceError(`${e.name} is not defined`)},evalLiteral:e=>e.value,evalMemberExpression(e,t){if("Identifier"===e.property.type&&"constructor"===e.property.name||"Identifier"===e.object.type&&"constructor"===e.object.name)throw new Error("'constructor' property is disabled");const r=e.computed?h.evalAst(e.property):e.property.name,n=h.evalAst(e.object,t),i=n[r];if("function"==typeof i){if(n===Function&&"bind"===r)throw new Error("Function.prototype.bind is disabled");if(n===Function&&("call"===r||"apply"===r))throw new Error("Function.prototype.call and Function.prototype.apply are disabled");return i===Function?i:i.bind(n)}return i},evalUnaryExpression:(e,t)=>({"-":e=>-h.evalAst(e,t),"!":e=>!h.evalAst(e,t),"~":e=>~h.evalAst(e,t),"+":e=>+h.evalAst(e,t)}[e.operator](e.argument)),evalArrayExpression:(e,t)=>e.elements.map((e=>h.evalAst(e,t))),evalCallExpression(e,t){const r=e.arguments.map((e=>h.evalAst(e,t))),n=h.evalAst(e.callee,t);if(n===Function)throw new Error("Function constructor is disabled");return n(...r)},evalAssignmentExpression(e,t){if("Identifier"!==e.left.type)throw SyntaxError("Invalid left-hand side in assignment");const r=e.left.name;if("__proto__"===r)throw new Error("Assignment to __proto__ is disabled");const n=h.evalAst(e.right,t);return t[r]=n,t[r]}};function l(e,t){return(e=e.slice()).push(t),e}function c(e,t){return(t=t.slice()).unshift(e),t}class p extends Error{constructor(e){super('JSONPath should not be called with "new" (it prevents return of (unwrapped) scalar values)'),this.avoidNew=!0,this.value=e,this.name="NewError"}}function u(e,t,r,n,i){if(!(this instanceof u))try{return new u(e,t,r,n,i)}catch(e){if(!e.avoidNew)throw e;return e.value}"string"==typeof e&&(i=n,n=r,r=t,t=e,e=null);const s=e&&"object"==typeof e;if(e=e||{},this.json=e.json||r,this.path=e.path||t,this.resultType=e.resultType||"value",this.flatten=e.flatten||!1,this.wrap=!Object.hasOwn(e,"wrap")||e.wrap,this.sandbox=e.sandbox||{},this.eval=void 0===e.eval?"safe":e.eval,this.ignoreEvalErrors=void 0!==e.ignoreEvalErrors&&e.ignoreEvalErrors,this.parent=e.parent||null,this.parentProperty=e.parentProperty||null,this.callback=e.callback||n||null,this.otherTypeCallback=e.otherTypeCallback||i||function(){throw new TypeError("You must supply an otherTypeCallback callback option with the @other() operator.")},!1!==e.autostart){const n={path:s?e.path:t};s?"json"in e&&(n.json=e.json):n.json=r;const i=this.evaluate(n);if(!i||"object"!=typeof i)throw new p(i);return i}}u.prototype.evaluate=function(e,t,r,n){let i=this.parent,s=this.parentProperty,{flatten:o,wrap:a}=this;if(this.currResultType=this.resultType,this.currEval=this.eval,this.currSandbox=this.sandbox,r=r||this.callback,this.currOtherTypeCallback=n||this.otherTypeCallback,t=t||this.json,(e=e||this.path)&&"object"==typeof e&&!Array.isArray(e)){if(!e.path&&""!==e.path)throw new TypeError('You must supply a "path" property when providing an object argument to JSONPath.evaluate().');if(!Object.hasOwn(e,"json"))throw new TypeError('You must supply a "json" property when providing an object argument to JSONPath.evaluate().');({json:t}=e),o=Object.hasOwn(e,"flatten")?e.flatten:o,this.currResultType=Object.hasOwn(e,"resultType")?e.resultType:this.currResultType,this.currSandbox=Object.hasOwn(e,"sandbox")?e.sandbox:this.currSandbox,a=Object.hasOwn(e,"wrap")?e.wrap:a,this.currEval=Object.hasOwn(e,"eval")?e.eval:this.currEval,r=Object.hasOwn(e,"callback")?e.callback:r,this.currOtherTypeCallback=Object.hasOwn(e,"otherTypeCallback")?e.otherTypeCallback:this.currOtherTypeCallback,i=Object.hasOwn(e,"parent")?e.parent:i,s=Object.hasOwn(e,"parentProperty")?e.parentProperty:s,e=e.path}if(i=i||null,s=s||null,Array.isArray(e)&&(e=u.toPathString(e)),!e&&""!==e||!t)return;const h=u.toPathArray(e);"$"===h[0]&&h.length>1&&h.shift(),this._hasParentSelector=null;const l=this._trace(h,t,["$"],i,s,r).filter((function(e){return e&&!e.isParentSelector}));return l.length?a||1!==l.length||l[0].hasArrExpr?l.reduce(((e,t)=>{const r=this._getPreferredOutput(t);return o&&Array.isArray(r)?e=e.concat(r):e.push(r),e}),[]):this._getPreferredOutput(l[0]):a?[]:void 0},u.prototype._getPreferredOutput=function(e){const t=this.currResultType;switch(t){case"all":{const t=Array.isArray(e.path)?e.path:u.toPathArray(e.path);return e.pointer=u.toPointer(t),e.path="string"==typeof e.path?e.path:u.toPathString(e.path),e}case"value":case"parent":case"parentProperty":return e[t];case"path":return u.toPathString(e[t]);case"pointer":return u.toPointer(e.path);default:throw new TypeError("Unknown result type")}},u.prototype._handleCallback=function(e,t,r){if(t){const n=this._getPreferredOutput(e);e.path="string"==typeof e.path?e.path:u.toPathString(e.path),t(n,r,e)}},u.prototype._trace=function(e,t,r,n,i,s,o,a){let h;if(!e.length)return h={path:r,value:t,parent:n,parentProperty:i,hasArrExpr:o},this._handleCallback(h,s,"value"),h;const p=e[0],u=e.slice(1),d=[];function f(e){Array.isArray(e)?e.forEach((e=>{d.push(e)})):d.push(e)}if(("string"!=typeof p||a)&&t&&Object.hasOwn(t,p))f(this._trace(u,t[p],l(r,p),t,p,s,o));else if("*"===p)this._walk(t,(e=>{f(this._trace(u,t[e],l(r,e),t,e,s,!0,!0))}));else if(".."===p)f(this._trace(u,t,r,n,i,s,o)),this._walk(t,(n=>{"object"==typeof t[n]&&f(this._trace(e.slice(),t[n],l(r,n),t,n,s,!0))}));else{if("^"===p)return this._hasParentSelector=!0,{path:r.slice(0,-1),expr:u,isParentSelector:!0};if("~"===p)return h={path:l(r,p),value:i,parent:n,parentProperty:null},this._handleCallback(h,s,"property"),h;if("$"===p)f(this._trace(u,t,r,null,null,s,o));else if(/^(-?\d*):(-?\d*):?(\d*)$/u.test(p))f(this._slice(p,u,t,r,n,i,s));else if(0===p.indexOf("?(")){if(!1===this.currEval)throw new Error("Eval [?(expr)] prevented in JSONPath expression.");const e=p.replace(/^\?\((.*?)\)$/u,"$1"),o=/@.?([^?]*)[['](\??\(.*?\))(?!.\)\])[\]']/gu.exec(e);o?this._walk(t,(e=>{const a=[o[2]],h=o[1]?t[e][o[1]]:t[e];this._trace(a,h,r,n,i,s,!0).length>0&&f(this._trace(u,t[e],l(r,e),t,e,s,!0))})):this._walk(t,(o=>{this._eval(e,t[o],o,r,n,i)&&f(this._trace(u,t[o],l(r,o),t,o,s,!0))}))}else if("("===p[0]){if(!1===this.currEval)throw new Error("Eval [(expr)] prevented in JSONPath expression.");f(this._trace(c(this._eval(p,t,r.at(-1),r.slice(0,-1),n,i),u),t,r,n,i,s,o))}else if("@"===p[0]){let e=!1;const o=p.slice(1,-2);switch(o){case"scalar":t&&["object","function"].includes(typeof t)||(e=!0);break;case"boolean":case"string":case"undefined":case"function":typeof t===o&&(e=!0);break;case"integer":!Number.isFinite(t)||t%1||(e=!0);break;case"number":Number.isFinite(t)&&(e=!0);break;case"nonFinite":"number"!=typeof t||Number.isFinite(t)||(e=!0);break;case"object":t&&typeof t===o&&(e=!0);break;case"array":Array.isArray(t)&&(e=!0);break;case"other":e=this.currOtherTypeCallback(t,r,n,i);break;case"null":null===t&&(e=!0);break;default:throw new TypeError("Unknown value type "+o)}if(e)return h={path:r,value:t,parent:n,parentProperty:i},this._handleCallback(h,s,"value"),h}else if("`"===p[0]&&t&&Object.hasOwn(t,p.slice(1))){const e=p.slice(1);f(this._trace(u,t[e],l(r,e),t,e,s,o,!0))}else if(p.includes(",")){const e=p.split(",");for(const o of e)f(this._trace(c(o,u),t,r,n,i,s,!0))}else!a&&t&&Object.hasOwn(t,p)&&f(this._trace(u,t[p],l(r,p),t,p,s,o,!0))}if(this._hasParentSelector)for(let e=0;e<d.length;e++){const r=d[e];if(r&&r.isParentSelector){const a=this._trace(r.expr,t,r.path,n,i,s,o);if(Array.isArray(a)){d[e]=a[0];const t=a.length;for(let r=1;r<t;r++)e++,d.splice(e,0,a[r])}else d[e]=a}}return d},u.prototype._walk=function(e,t){if(Array.isArray(e)){const r=e.length;for(let e=0;e<r;e++)t(e)}else e&&"object"==typeof e&&Object.keys(e).forEach((e=>{t(e)}))},u.prototype._slice=function(e,t,r,n,i,s,o){if(!Array.isArray(r))return;const a=r.length,h=e.split(":"),l=h[2]&&Number.parseInt(h[2])||1;let p=h[0]&&Number.parseInt(h[0])||0,u=h[1]&&Number.parseInt(h[1])||a;p=p<0?Math.max(0,p+a):Math.min(a,p),u=u<0?Math.max(0,u+a):Math.min(a,u);const d=[];for(let e=p;e<u;e+=l){this._trace(c(e,t),r,n,i,s,o,!0).forEach((e=>{d.push(e)}))}return d},u.prototype._eval=function(e,t,r,n,i,s){this.currSandbox._$_parentProperty=s,this.currSandbox._$_parent=i,this.currSandbox._$_property=r,this.currSandbox._$_root=this.json,this.currSandbox._$_v=t;const o=e.includes("@path");o&&(this.currSandbox._$_path=u.toPathString(n.concat([r])));const a=this.currEval+"Script:"+e;if(!u.cache[a]){let t=e.replaceAll("@parentProperty","_$_parentProperty").replaceAll("@parent","_$_parent").replaceAll("@property","_$_property").replaceAll("@root","_$_root").replaceAll(/@([.\s)[])/gu,"_$_v$1");if(o&&(t=t.replaceAll("@path","_$_path")),"safe"===this.currEval||!0===this.currEval||void 0===this.currEval)u.cache[a]=new this.safeVm.Script(t);else if("native"===this.currEval)u.cache[a]=new this.vm.Script(t);else if("function"==typeof this.currEval&&this.currEval.prototype&&Object.hasOwn(this.currEval.prototype,"runInNewContext")){const e=this.currEval;u.cache[a]=new e(t)}else{if("function"!=typeof this.currEval)throw new TypeError(`Unknown "eval" property "${this.currEval}"`);u.cache[a]={runInNewContext:e=>this.currEval(t,e)}}}try{return u.cache[a].runInNewContext(this.currSandbox)}catch(t){if(this.ignoreEvalErrors)return!1;throw new Error("jsonPath: "+t.message+": "+e)}},u.cache={},u.toPathString=function(e){const t=e,r=t.length;let n="$";for(let e=1;e<r;e++)/^(~|\^|@.*?\(\))$/u.test(t[e])||(n+=/^[0-9*]+$/u.test(t[e])?"["+t[e]+"]":"['"+t[e]+"']");return n},u.toPointer=function(e){const t=e,r=t.length;let n="";for(let e=1;e<r;e++)/^(~|\^|@.*?\(\))$/u.test(t[e])||(n+="/"+t[e].toString().replaceAll("~","~0").replaceAll("/","~1"));return n},u.toPathArray=function(e){const{cache:t}=u;if(t[e])return t[e].concat();const r=[],n=e.replaceAll(/@(?:null|boolean|number|string|integer|undefined|nonFinite|scalar|array|object|function|other)\(\)/gu,";$&;").replaceAll(/[['](\??\(.*?\))[\]'](?!.\])/gu,(function(e,t){return"[#"+(r.push(t)-1)+"]"})).replaceAll(/\[['"]([^'\]]*)['"]\]/gu,(function(e,t){return"['"+t.replaceAll(".","%@%").replaceAll("~","%%@@%%")+"']"})).replaceAll("~",";~;").replaceAll(/['"]?\.['"]?(?![^[]*\])|\[['"]?/gu,";").replaceAll("%@%",".").replaceAll("%%@@%%","~").replaceAll(/(?:;)?(\^+)(?:;)?/gu,(function(e,t){return";"+t.split("").join(";")+";"})).replaceAll(/;;;|;;/gu,";..;").replaceAll(/;$|'?\]|'$/gu,"").split(";").map((function(e){const t=e.match(/#(\d+)/u);return t&&t[1]?r[t[1]]:e}));return t[e]=n,t[e].concat()},u.prototype.safeVm={Script:class{constructor(e){this.code=e,this.ast=n(this.code)}runInNewContext(e){const t={...e};return h.evalAst(this.ast,t)}}};u.prototype.vm={Script:class{constructor(e){this.code=e}runInNewContext(e){let t=this.code;const r=Object.keys(e),n=[];!function(e,t,r){const n=e.length;for(let i=0;i<n;i++)r(e[i])&&t.push(e.splice(i--,1)[0])}(r,n,(t=>"function"==typeof e[t]));const i=r.map((t=>e[t]));t=n.reduce(((t,r)=>{let n=e[r].toString();return/function/u.test(n)||(n="function "+n),"var "+r+"="+n+";"+t}),"")+t,/(['"])use strict\1/u.test(t)||r.includes("arguments")||(t="var arguments = undefined;"+t),t=t.replace(/;\s*$/u,"");const s=t.lastIndexOf(";"),o=s>-1?t.slice(0,s+1)+" return "+t.slice(s+1):" return "+t;return new Function(...r,o)(...i)}}},e.JSONPath=u})); //# sourceMappingURL=index-browser-umd.min.cjs.map
dist/index-browser-umd.min.cjs.map+1 −1 modifieddist/index-node-cjs.cjs+3 −0 modified@@ -1292,6 +1292,9 @@ const SafeEval = { return ast.value; }, evalMemberExpression(ast, subs) { + if (ast.property.type === 'Identifier' && ast.property.name === 'constructor' || ast.object.type === 'Identifier' && ast.object.name === 'constructor') { + throw new Error("'constructor' property is disabled"); + } const prop = ast.computed ? SafeEval.evalAst(ast.property) // `object[property]` : ast.property.name; // `object.property` property is Identifier const obj = SafeEval.evalAst(ast.object, subs);
dist/index-node-esm.js+3 −0 modified@@ -1290,6 +1290,9 @@ const SafeEval = { return ast.value; }, evalMemberExpression(ast, subs) { + if (ast.property.type === 'Identifier' && ast.property.name === 'constructor' || ast.object.type === 'Identifier' && ast.object.name === 'constructor') { + throw new Error("'constructor' property is disabled"); + } const prop = ast.computed ? SafeEval.evalAst(ast.property) // `object[property]` : ast.property.name; // `object.property` property is Identifier const obj = SafeEval.evalAst(ast.object, subs);
.github/ISSUE_TEMPLATE/bug_report.md+2 −0 modified@@ -6,6 +6,8 @@ labels: Bug - unconfirmed --- <!-- **PLEASE NOTE: This project is not currently being very actively developed.** + +**ALSO: If wishing to report a security bug, please read SECURITY.md** --> ## Describe the bug
package.json+1 −1 modified@@ -1,7 +1,7 @@ { "author": "Stefan Goessner", "name": "jsonpath-plus", - "version": "10.0.6", + "version": "10.0.7", "type": "module", "bin": { "jsonpath": "./bin/jsonpath-cli.js",
SECURITY.md+20 −0 added@@ -0,0 +1,20 @@ +# Security Policy + +## Reporting a Vulnerability + +**Please do not report security vulnerabilities through public GitHub issues.** + +If you believe you’ve found a security vulnerability, please send it to us by emailing [brettz9@yahoo.com](mailto:brettz9@yahoo.com). Please include the following details with your report: + +1. Description of the location and potential impact of the vulnerability + +2. A detailed description of the steps required to reproduce the vulnerability (POC scripts, etc.). + +3. How you would like to be credited. + +We will evaluate the vulnerability and, if necessary, release a fix or unertake mitigating steps to address it. We will contact you to let you know the outcome, and will credit you in the report. + +Please **do not disclose the vulnerability publicly** until we have sufficient time to release a fix. + +Once we have either a) published a fix, b) declined to address the vulnerability for whatever reason, or c) taken more than 30 days to reply, we welcome you to publicly report the vulnerability on our tracker and disclose it publicly. If you intend to +disclose sooner regardless of our requested policy, please at least indicate to us when you plan to disclose.
src/Safe-Script.js+9 −0 modified@@ -105,6 +105,15 @@ const SafeEval = { return ast.value; }, evalMemberExpression (ast, subs) { + if ( + (ast.property.type === 'Identifier' && + ast.property.name === 'constructor') || + (ast.object.type === 'Identifier' && + ast.object.name === 'constructor') + ) { + throw new Error("'constructor' property is disabled"); + } + const prop = ast.computed ? SafeEval.evalAst(ast.property) // `object[property]` : ast.property.name; // `object.property` property is Identifier
6b2f1b4c2342fix(security): use safe vm by default in Node
14 files changed · +3461 −765
CHANGES.md+2 −1 modified@@ -1,10 +1,11 @@ # CHANGES for jsonpath-plus -## 10.0.0 (unreleased) +## 10.0.0 BREAKING CHANGES: - Require Node 18+ +- fix(security): use safe vm by default in Node - chore: bump jsep, devDeps. and lint ## 9.0.0
dist/index-browser-esm.js+243 −246 modified@@ -1520,12 +1520,222 @@ var plugin = { } }; -/* eslint-disable camelcase, unicorn/prefer-string-replace-all, - unicorn/prefer-at */ -var hasOwnProp = Object.prototype.hasOwnProperty; +// register plugins +jsep.plugins.register(index, plugin); +var SafeEval = { + /** + * @param {jsep.Expression} ast + * @param {Record<string, any>} subs + */ + evalAst: function evalAst(ast, subs) { + switch (ast.type) { + case 'BinaryExpression': + case 'LogicalExpression': + return SafeEval.evalBinaryExpression(ast, subs); + case 'Compound': + return SafeEval.evalCompound(ast, subs); + case 'ConditionalExpression': + return SafeEval.evalConditionalExpression(ast, subs); + case 'Identifier': + return SafeEval.evalIdentifier(ast, subs); + case 'Literal': + return SafeEval.evalLiteral(ast, subs); + case 'MemberExpression': + return SafeEval.evalMemberExpression(ast, subs); + case 'UnaryExpression': + return SafeEval.evalUnaryExpression(ast, subs); + case 'ArrayExpression': + return SafeEval.evalArrayExpression(ast, subs); + case 'CallExpression': + return SafeEval.evalCallExpression(ast, subs); + case 'AssignmentExpression': + return SafeEval.evalAssignmentExpression(ast, subs); + default: + throw SyntaxError('Unexpected expression', ast); + } + }, + evalBinaryExpression: function evalBinaryExpression(ast, subs) { + var result = { + '||': function _(a, b) { + return a || b(); + }, + '&&': function _(a, b) { + return a && b(); + }, + '|': function _(a, b) { + return a | b(); + }, + '^': function _(a, b) { + return a ^ b(); + }, + '&': function _(a, b) { + return a & b(); + }, + // eslint-disable-next-line eqeqeq + '==': function _(a, b) { + return a == b(); + }, + // eslint-disable-next-line eqeqeq + '!=': function _(a, b) { + return a != b(); + }, + '===': function _(a, b) { + return a === b(); + }, + '!==': function _(a, b) { + return a !== b(); + }, + '<': function _(a, b) { + return a < b(); + }, + '>': function _(a, b) { + return a > b(); + }, + '<=': function _(a, b) { + return a <= b(); + }, + '>=': function _(a, b) { + return a >= b(); + }, + '<<': function _(a, b) { + return a << b(); + }, + '>>': function _(a, b) { + return a >> b(); + }, + '>>>': function _(a, b) { + return a >>> b(); + }, + '+': function _(a, b) { + return a + b(); + }, + '-': function _(a, b) { + return a - b(); + }, + '*': function _(a, b) { + return a * b(); + }, + '/': function _(a, b) { + return a / b(); + }, + '%': function _(a, b) { + return a % b(); + } + }[ast.operator](SafeEval.evalAst(ast.left, subs), function () { + return SafeEval.evalAst(ast.right, subs); + }); + return result; + }, + evalCompound: function evalCompound(ast, subs) { + var last; + for (var i = 0; i < ast.body.length; i++) { + if (ast.body[i].type === 'Identifier' && ['var', 'let', 'const'].includes(ast.body[i].name) && ast.body[i + 1] && ast.body[i + 1].type === 'AssignmentExpression') { + // var x=2; is detected as + // [{Identifier var}, {AssignmentExpression x=2}] + // eslint-disable-next-line @stylistic/max-len -- Long + // eslint-disable-next-line sonarjs/updated-loop-counter -- Convenient + i += 1; + } + var expr = ast.body[i]; + last = SafeEval.evalAst(expr, subs); + } + return last; + }, + evalConditionalExpression: function evalConditionalExpression(ast, subs) { + if (SafeEval.evalAst(ast.test, subs)) { + return SafeEval.evalAst(ast.consequent, subs); + } + return SafeEval.evalAst(ast.alternate, subs); + }, + evalIdentifier: function evalIdentifier(ast, subs) { + if (ast.name in subs) { + return subs[ast.name]; + } + throw ReferenceError("".concat(ast.name, " is not defined")); + }, + evalLiteral: function evalLiteral(ast) { + return ast.value; + }, + evalMemberExpression: function evalMemberExpression(ast, subs) { + var prop = ast.computed ? SafeEval.evalAst(ast.property) // `object[property]` + : ast.property.name; // `object.property` property is Identifier + var obj = SafeEval.evalAst(ast.object, subs); + var result = obj[prop]; + if (typeof result === 'function') { + return result.bind(obj); // arrow functions aren't affected by bind. + } + return result; + }, + evalUnaryExpression: function evalUnaryExpression(ast, subs) { + var result = { + '-': function _(a) { + return -SafeEval.evalAst(a, subs); + }, + '!': function _(a) { + return !SafeEval.evalAst(a, subs); + }, + '~': function _(a) { + return ~SafeEval.evalAst(a, subs); + }, + // eslint-disable-next-line no-implicit-coercion + '+': function _(a) { + return +SafeEval.evalAst(a, subs); + } + }[ast.operator](ast.argument); + return result; + }, + evalArrayExpression: function evalArrayExpression(ast, subs) { + return ast.elements.map(function (el) { + return SafeEval.evalAst(el, subs); + }); + }, + evalCallExpression: function evalCallExpression(ast, subs) { + var args = ast.arguments.map(function (arg) { + return SafeEval.evalAst(arg, subs); + }); + var func = SafeEval.evalAst(ast.callee, subs); + return func.apply(void 0, _toConsumableArray(args)); + }, + evalAssignmentExpression: function evalAssignmentExpression(ast, subs) { + if (ast.left.type !== 'Identifier') { + throw SyntaxError('Invalid left-hand side in assignment'); + } + var id = ast.left.name; + var value = SafeEval.evalAst(ast.right, subs); + subs[id] = value; + return subs[id]; + } +}; /** - * @typedef {null|boolean|number|string|PlainObject|GenericArray} JSONObject + * A replacement for NodeJS' VM.Script which is also {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP | Content Security Policy} friendly. + */ +var SafeScript = /*#__PURE__*/function () { + /** + * @param {string} expr Expression to evaluate + */ + function SafeScript(expr) { + _classCallCheck(this, SafeScript); + this.code = expr; + this.ast = jsep(this.code); + } + + /** + * @param {object} context Object whose items will be added + * to evaluation + * @returns {EvaluatedResult} Result of evaluated code + */ + return _createClass(SafeScript, [{ + key: "runInNewContext", + value: function runInNewContext(context) { + var keyMap = _objectSpread2({}, context); + return SafeEval.evalAst(this.ast, keyMap); + } + }]); +}(); + +/** + * @typedef {null|boolean|number|string|object|GenericArray} JSONObject */ /** @@ -1580,15 +1790,15 @@ var NewError = /*#__PURE__*/function (_Error) { return _createClass(NewError); }(/*#__PURE__*/_wrapNativeSuper(Error)); /** -* @typedef {PlainObject} ReturnObject +* @typedef {object} ReturnObject * @property {string} path * @property {JSONObject} value -* @property {PlainObject|GenericArray} parent +* @property {object|GenericArray} parent * @property {string} parentProperty */ /** * @callback JSONPathCallback -* @param {string|PlainObject} preferredOutput +* @param {string|object} preferredOutput * @param {"value"|"property"} type * @param {ReturnObject} fullRetObj * @returns {void} @@ -1597,7 +1807,7 @@ var NewError = /*#__PURE__*/function (_Error) { * @callback OtherTypeCallback * @param {JSONObject} val * @param {string} path -* @param {PlainObject|GenericArray} parent +* @param {object|GenericArray} parent * @param {string} parentPropName * @returns {boolean} */ @@ -1614,20 +1824,20 @@ var NewError = /*#__PURE__*/function (_Error) { * @returns {EvaluatedResult} */ /** - * @typedef {typeof import('./jsonpath-browser').SafeScript} EvalClass + * @typedef {typeof SafeScript} EvalClass */ /** - * @typedef {PlainObject} JSONPathOptions + * @typedef {object} JSONPathOptions * @property {JSON} json * @property {string|string[]} path * @property {"value"|"path"|"pointer"|"parent"|"parentProperty"| * "all"} [resultType="value"] * @property {boolean} [flatten=false] * @property {boolean} [wrap=true] - * @property {PlainObject} [sandbox={}] + * @property {object} [sandbox={}] * @property {EvalCallback|EvalClass|'safe'|'native'| * boolean} [eval = 'safe'] - * @property {PlainObject|GenericArray|null} [parent=null] + * @property {object|GenericArray|null} [parent=null] * @property {string|null} [parentProperty=null] * @property {JSONPathCallback} [callback] * @property {OtherTypeCallback} [otherTypeCallback] Defaults to @@ -1674,7 +1884,7 @@ function JSONPath(opts, expr, obj, callback, otherTypeCallback) { this.path = opts.path || expr; this.resultType = opts.resultType || 'value'; this.flatten = opts.flatten || false; - this.wrap = hasOwnProp.call(opts, 'wrap') ? opts.wrap : true; + this.wrap = Object.hasOwn(opts, 'wrap') ? opts.wrap : true; this.sandbox = opts.sandbox || {}; this.eval = opts.eval === undefined ? 'safe' : opts.eval; this.ignoreEvalErrors = typeof opts.ignoreEvalErrors === 'undefined' ? false : opts.ignoreEvalErrors; @@ -1719,20 +1929,20 @@ JSONPath.prototype.evaluate = function (expr, json, callback, otherTypeCallback) if (!expr.path && expr.path !== '') { throw new TypeError('You must supply a "path" property when providing an object ' + 'argument to JSONPath.evaluate().'); } - if (!hasOwnProp.call(expr, 'json')) { + if (!Object.hasOwn(expr, 'json')) { throw new TypeError('You must supply a "json" property when providing an object ' + 'argument to JSONPath.evaluate().'); } var _expr = expr; json = _expr.json; - flatten = hasOwnProp.call(expr, 'flatten') ? expr.flatten : flatten; - this.currResultType = hasOwnProp.call(expr, 'resultType') ? expr.resultType : this.currResultType; - this.currSandbox = hasOwnProp.call(expr, 'sandbox') ? expr.sandbox : this.currSandbox; - wrap = hasOwnProp.call(expr, 'wrap') ? expr.wrap : wrap; - this.currEval = hasOwnProp.call(expr, 'eval') ? expr.eval : this.currEval; - callback = hasOwnProp.call(expr, 'callback') ? expr.callback : callback; - this.currOtherTypeCallback = hasOwnProp.call(expr, 'otherTypeCallback') ? expr.otherTypeCallback : this.currOtherTypeCallback; - currParent = hasOwnProp.call(expr, 'parent') ? expr.parent : currParent; - currParentProperty = hasOwnProp.call(expr, 'parentProperty') ? expr.parentProperty : currParentProperty; + flatten = Object.hasOwn(expr, 'flatten') ? expr.flatten : flatten; + this.currResultType = Object.hasOwn(expr, 'resultType') ? expr.resultType : this.currResultType; + this.currSandbox = Object.hasOwn(expr, 'sandbox') ? expr.sandbox : this.currSandbox; + wrap = Object.hasOwn(expr, 'wrap') ? expr.wrap : wrap; + this.currEval = Object.hasOwn(expr, 'eval') ? expr.eval : this.currEval; + callback = Object.hasOwn(expr, 'callback') ? expr.callback : callback; + this.currOtherTypeCallback = Object.hasOwn(expr, 'otherTypeCallback') ? expr.otherTypeCallback : this.currOtherTypeCallback; + currParent = Object.hasOwn(expr, 'parent') ? expr.parent : currParent; + currParentProperty = Object.hasOwn(expr, 'parentProperty') ? expr.parentProperty : currParentProperty; expr = expr.path; } currParent = currParent || null; @@ -1806,7 +2016,7 @@ JSONPath.prototype._handleCallback = function (fullRetObj, callback, type) { * @param {string} expr * @param {JSONObject} val * @param {string} path - * @param {PlainObject|GenericArray} parent + * @param {object|GenericArray} parent * @param {string} parentPropName * @param {JSONPathCallback} callback * @param {boolean} hasArrExpr @@ -1852,7 +2062,7 @@ JSONPath.prototype._trace = function (expr, val, path, parent, parentPropName, c ret.push(elems); } } - if ((typeof loc !== 'string' || literalPriority) && val && hasOwnProp.call(val, loc)) { + if ((typeof loc !== 'string' || literalPriority) && val && Object.hasOwn(val, loc)) { // simple case--directly follow property addRet(this._trace(x, val[loc], push(path, loc), val, loc, callback, hasArrExpr)); // eslint-disable-next-line unicorn/prefer-switch -- Part of larger `if` @@ -2001,7 +2211,7 @@ JSONPath.prototype._trace = function (expr, val, path, parent, parentPropName, c return retObj; } // `-escaped property - } else if (loc[0] === '`' && val && hasOwnProp.call(val, loc.slice(1))) { + } else if (loc[0] === '`' && val && Object.hasOwn(val, loc.slice(1))) { var locProp = loc.slice(1); addRet(this._trace(x, val[locProp], push(path, locProp), val, locProp, callback, hasArrExpr, true)); } else if (loc.includes(',')) { @@ -2020,7 +2230,7 @@ JSONPath.prototype._trace = function (expr, val, path, parent, parentPropName, c } finally { _iterator.f(); } - } else if (!literalPriority && val && hasOwnProp.call(val, loc)) { + } else if (!literalPriority && val && Object.hasOwn(val, loc)) { addRet(this._trace(x, val[loc], push(path, loc), val, loc, callback, hasArrExpr, true)); } @@ -2107,7 +2317,7 @@ JSONPath.prototype._eval = function (code, _v, _vname, path, parent, parentPropN JSONPath.cache[scriptCacheKey] = new this.safeVm.Script(script); } else if (this.currEval === 'native') { JSONPath.cache[scriptCacheKey] = new this.vm.Script(script); - } else if (typeof this.currEval === 'function' && this.currEval.prototype && hasOwnProp.call(this.currEval.prototype, 'runInNewContext')) { + } else if (typeof this.currEval === 'function' && this.currEval.prototype && Object.hasOwn(this.currEval.prototype, 'runInNewContext')) { var CurrEval = this.currEval; JSONPath.cache[scriptCacheKey] = new CurrEval(script); } else if (typeof this.currEval === 'function') { @@ -2212,6 +2422,9 @@ JSONPath.toPathArray = function (expr) { cache[expr] = exprList; return cache[expr].concat(); }; +JSONPath.prototype.safeVm = { + Script: SafeScript +}; /** * @typedef {any} ContextItem @@ -2247,219 +2460,6 @@ var moveToAnotherArray = function moveToAnotherArray(source, target, conditionCb } }; -// register plugins -jsep.plugins.register(index, plugin); -var SafeEval = { - /** - * @param {jsep.Expression} ast - * @param {Record<string, any>} subs - */ - evalAst: function evalAst(ast, subs) { - switch (ast.type) { - case 'BinaryExpression': - case 'LogicalExpression': - return SafeEval.evalBinaryExpression(ast, subs); - case 'Compound': - return SafeEval.evalCompound(ast, subs); - case 'ConditionalExpression': - return SafeEval.evalConditionalExpression(ast, subs); - case 'Identifier': - return SafeEval.evalIdentifier(ast, subs); - case 'Literal': - return SafeEval.evalLiteral(ast, subs); - case 'MemberExpression': - return SafeEval.evalMemberExpression(ast, subs); - case 'UnaryExpression': - return SafeEval.evalUnaryExpression(ast, subs); - case 'ArrayExpression': - return SafeEval.evalArrayExpression(ast, subs); - case 'CallExpression': - return SafeEval.evalCallExpression(ast, subs); - case 'AssignmentExpression': - return SafeEval.evalAssignmentExpression(ast, subs); - default: - throw SyntaxError('Unexpected expression', ast); - } - }, - evalBinaryExpression: function evalBinaryExpression(ast, subs) { - var result = { - '||': function _(a, b) { - return a || b(); - }, - '&&': function _(a, b) { - return a && b(); - }, - '|': function _(a, b) { - return a | b(); - }, - '^': function _(a, b) { - return a ^ b(); - }, - '&': function _(a, b) { - return a & b(); - }, - // eslint-disable-next-line eqeqeq - '==': function _(a, b) { - return a == b(); - }, - // eslint-disable-next-line eqeqeq - '!=': function _(a, b) { - return a != b(); - }, - '===': function _(a, b) { - return a === b(); - }, - '!==': function _(a, b) { - return a !== b(); - }, - '<': function _(a, b) { - return a < b(); - }, - '>': function _(a, b) { - return a > b(); - }, - '<=': function _(a, b) { - return a <= b(); - }, - '>=': function _(a, b) { - return a >= b(); - }, - '<<': function _(a, b) { - return a << b(); - }, - '>>': function _(a, b) { - return a >> b(); - }, - '>>>': function _(a, b) { - return a >>> b(); - }, - '+': function _(a, b) { - return a + b(); - }, - '-': function _(a, b) { - return a - b(); - }, - '*': function _(a, b) { - return a * b(); - }, - '/': function _(a, b) { - return a / b(); - }, - '%': function _(a, b) { - return a % b(); - } - }[ast.operator](SafeEval.evalAst(ast.left, subs), function () { - return SafeEval.evalAst(ast.right, subs); - }); - return result; - }, - evalCompound: function evalCompound(ast, subs) { - var last; - for (var i = 0; i < ast.body.length; i++) { - if (ast.body[i].type === 'Identifier' && ['var', 'let', 'const'].includes(ast.body[i].name) && ast.body[i + 1] && ast.body[i + 1].type === 'AssignmentExpression') { - // var x=2; is detected as - // [{Identifier var}, {AssignmentExpression x=2}] - // eslint-disable-next-line @stylistic/max-len -- Long - // eslint-disable-next-line sonarjs/updated-loop-counter -- Convenient - i += 1; - } - var expr = ast.body[i]; - last = SafeEval.evalAst(expr, subs); - } - return last; - }, - evalConditionalExpression: function evalConditionalExpression(ast, subs) { - if (SafeEval.evalAst(ast.test, subs)) { - return SafeEval.evalAst(ast.consequent, subs); - } - return SafeEval.evalAst(ast.alternate, subs); - }, - evalIdentifier: function evalIdentifier(ast, subs) { - if (ast.name in subs) { - return subs[ast.name]; - } - throw ReferenceError("".concat(ast.name, " is not defined")); - }, - evalLiteral: function evalLiteral(ast) { - return ast.value; - }, - evalMemberExpression: function evalMemberExpression(ast, subs) { - var prop = ast.computed ? SafeEval.evalAst(ast.property) // `object[property]` - : ast.property.name; // `object.property` property is Identifier - var obj = SafeEval.evalAst(ast.object, subs); - var result = obj[prop]; - if (typeof result === 'function') { - return result.bind(obj); // arrow functions aren't affected by bind. - } - return result; - }, - evalUnaryExpression: function evalUnaryExpression(ast, subs) { - var result = { - '-': function _(a) { - return -SafeEval.evalAst(a, subs); - }, - '!': function _(a) { - return !SafeEval.evalAst(a, subs); - }, - '~': function _(a) { - return ~SafeEval.evalAst(a, subs); - }, - // eslint-disable-next-line no-implicit-coercion - '+': function _(a) { - return +SafeEval.evalAst(a, subs); - } - }[ast.operator](ast.argument); - return result; - }, - evalArrayExpression: function evalArrayExpression(ast, subs) { - return ast.elements.map(function (el) { - return SafeEval.evalAst(el, subs); - }); - }, - evalCallExpression: function evalCallExpression(ast, subs) { - var args = ast.arguments.map(function (arg) { - return SafeEval.evalAst(arg, subs); - }); - var func = SafeEval.evalAst(ast.callee, subs); - return func.apply(void 0, _toConsumableArray(args)); - }, - evalAssignmentExpression: function evalAssignmentExpression(ast, subs) { - if (ast.left.type !== 'Identifier') { - throw SyntaxError('Invalid left-hand side in assignment'); - } - var id = ast.left.name; - var value = SafeEval.evalAst(ast.right, subs); - subs[id] = value; - return subs[id]; - } -}; - -/** - * A replacement for NodeJS' VM.Script which is also {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP | Content Security Policy} friendly. - */ -var SafeScript = /*#__PURE__*/function () { - /** - * @param {string} expr Expression to evaluate - */ - function SafeScript(expr) { - _classCallCheck(this, SafeScript); - this.code = expr; - this.ast = jsep(this.code); - } - - /** - * @param {PlainObject} context Object whose items will be added - * to evaluation - * @returns {EvaluatedResult} Result of evaluated code - */ - return _createClass(SafeScript, [{ - key: "runInNewContext", - value: function runInNewContext(context) { - var keyMap = _objectSpread2({}, context); - return SafeEval.evalAst(this.ast, keyMap); - } - }]); -}(); /** * In-browser replacement for NodeJS' VM.Script. */ @@ -2473,7 +2473,7 @@ var Script = /*#__PURE__*/function () { } /** - * @param {PlainObject} context Object whose items will be added + * @param {object} context Object whose items will be added * to evaluation * @returns {EvaluatedResult} Result of evaluated code */ @@ -2520,8 +2520,5 @@ var Script = /*#__PURE__*/function () { JSONPath.prototype.vm = { Script: Script }; -JSONPath.prototype.safeVm = { - Script: SafeScript -}; -export { JSONPath, SafeScript }; +export { JSONPath };
dist/index-browser-esm.min.js+1 −1 modified@@ -1,2 +1,2 @@ -function e(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function t(e,t,r){return t=s(t),function(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,u()?Reflect.construct(t,r||[],s(e).constructor):t.apply(e,r))}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(e,t,r){if(u())return Reflect.construct.apply(null,arguments);var n=[null];n.push.apply(n,t);var i=new(e.bind.apply(e,n));return r&&l(i,r.prototype),i}function i(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,p(n.key),n)}}function o(e,t,r){return t&&i(e.prototype,t),r&&i(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function a(e,t,r){return(t=p(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function s(e){return s=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},s(e)}function u(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(u=function(){return!!e})()}function c(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function l(e,t){return l=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},l(e,t)}function h(t){return function(t){if(Array.isArray(t))return e(t)}(t)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(t)||d(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function p(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t);if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e,"string");return"symbol"==typeof t?t:t+""}function f(e){return f="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},f(e)}function d(t,r){if(t){if("string"==typeof t)return e(t,r);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?e(t,r):void 0}}function y(e){var t="function"==typeof Map?new Map:void 0;return y=function(e){if(null===e||!function(e){try{return-1!==Function.toString.call(e).indexOf("[native code]")}catch(t){return"function"==typeof e}}(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return n(e,arguments,s(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),l(r,e)},y(e)}var b=function(){return o((function e(){r(this,e)}),[{key:"add",value:function(e,t,r){if("string"!=typeof arguments[0])for(var n in arguments[0])this.add(n,arguments[0][n],arguments[1]);else(Array.isArray(e)?e:[e]).forEach((function(e){this[e]=this[e]||[],t&&this[e][r?"unshift":"push"](t)}),this)}},{key:"run",value:function(e,t){this[e]=this[e]||[],this[e].forEach((function(e){e.call(t&&t.context?t.context:t,t)}))}}])}(),v=function(){return o((function e(t){r(this,e),this.jsep=t,this.registered={}}),[{key:"register",value:function(){for(var e=this,t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];r.forEach((function(t){if("object"!==f(t)||!t.name||!t.init)throw new Error("Invalid JSEP plugin format");e.registered[t.name]||(t.init(e.jsep),e.registered[t.name]=t)}))}}])}(),E=function(){function e(t){r(this,e),this.expr=t,this.index=0}return o(e,[{key:"char",get:function(){return this.expr.charAt(this.index)}},{key:"code",get:function(){return this.expr.charCodeAt(this.index)}},{key:"throwError",value:function(e){var t=new Error(e+" at character "+this.index);throw t.index=this.index,t.description=e,t}},{key:"runHook",value:function(t,r){if(e.hooks[t]){var n={context:this,node:r};return e.hooks.run(t,n),n.node}return r}},{key:"searchHook",value:function(t){if(e.hooks[t]){var r={context:this};return e.hooks[t].find((function(e){return e.call(r.context,r),r.node})),r.node}}},{key:"gobbleSpaces",value:function(){for(var t=this.code;t===e.SPACE_CODE||t===e.TAB_CODE||t===e.LF_CODE||t===e.CR_CODE;)t=this.expr.charCodeAt(++this.index);this.runHook("gobble-spaces")}},{key:"parse",value:function(){this.runHook("before-all");var t=this.gobbleExpressions(),r=1===t.length?t[0]:{type:e.COMPOUND,body:t};return this.runHook("after-all",r)}},{key:"gobbleExpressions",value:function(t){for(var r,n,i=[];this.index<this.expr.length;)if((r=this.code)===e.SEMCOL_CODE||r===e.COMMA_CODE)this.index++;else if(n=this.gobbleExpression())i.push(n);else if(this.index<this.expr.length){if(r===t)break;this.throwError('Unexpected "'+this.char+'"')}return i}},{key:"gobbleExpression",value:function(){var e=this.searchHook("gobble-expression")||this.gobbleBinaryExpression();return this.gobbleSpaces(),this.runHook("after-expression",e)}},{key:"gobbleBinaryOp",value:function(){this.gobbleSpaces();for(var t=this.expr.substr(this.index,e.max_binop_len),r=t.length;r>0;){if(e.binary_ops.hasOwnProperty(t)&&(!e.isIdentifierStart(this.code)||this.index+t.length<this.expr.length&&!e.isIdentifierPart(this.expr.charCodeAt(this.index+t.length))))return this.index+=r,t;t=t.substr(0,--r)}return!1}},{key:"gobbleBinaryExpression",value:function(){var t,r,n,i,o,a,s,u,c,l;if(!(a=this.gobbleToken()))return a;if(!(r=this.gobbleBinaryOp()))return a;for(o={value:r,prec:e.binaryPrecedence(r),right_a:e.right_associative.has(r)},(s=this.gobbleToken())||this.throwError("Expected expression after "+r),i=[a,o,s];r=this.gobbleBinaryOp();){if(0===(n=e.binaryPrecedence(r))){this.index-=r.length;break}o={value:r,prec:n,right_a:e.right_associative.has(r)},c=r;for(;i.length>2&&(l=i[i.length-2],o.right_a&&l.right_a?n>l.prec:n<=l.prec);)s=i.pop(),r=i.pop().value,a=i.pop(),t={type:e.BINARY_EXP,operator:r,left:a,right:s},i.push(t);(t=this.gobbleToken())||this.throwError("Expected expression after "+c),i.push(o,t)}for(t=i[u=i.length-1];u>1;)t={type:e.BINARY_EXP,operator:i[u-1].value,left:i[u-2],right:t},u-=2;return t}},{key:"gobbleToken",value:function(){var t,r,n,i;if(this.gobbleSpaces(),i=this.searchHook("gobble-token"))return this.runHook("after-token",i);if(t=this.code,e.isDecimalDigit(t)||t===e.PERIOD_CODE)return this.gobbleNumericLiteral();if(t===e.SQUOTE_CODE||t===e.DQUOTE_CODE)i=this.gobbleStringLiteral();else if(t===e.OBRACK_CODE)i=this.gobbleArray();else{for(n=(r=this.expr.substr(this.index,e.max_unop_len)).length;n>0;){if(e.unary_ops.hasOwnProperty(r)&&(!e.isIdentifierStart(this.code)||this.index+r.length<this.expr.length&&!e.isIdentifierPart(this.expr.charCodeAt(this.index+r.length)))){this.index+=n;var o=this.gobbleToken();return o||this.throwError("missing unaryOp argument"),this.runHook("after-token",{type:e.UNARY_EXP,operator:r,argument:o,prefix:!0})}r=r.substr(0,--n)}e.isIdentifierStart(t)?(i=this.gobbleIdentifier(),e.literals.hasOwnProperty(i.name)?i={type:e.LITERAL,value:e.literals[i.name],raw:i.name}:i.name===e.this_str&&(i={type:e.THIS_EXP})):t===e.OPAREN_CODE&&(i=this.gobbleGroup())}return i?(i=this.gobbleTokenProperty(i),this.runHook("after-token",i)):this.runHook("after-token",!1)}},{key:"gobbleTokenProperty",value:function(t){this.gobbleSpaces();for(var r=this.code;r===e.PERIOD_CODE||r===e.OBRACK_CODE||r===e.OPAREN_CODE||r===e.QUMARK_CODE;){var n=void 0;if(r===e.QUMARK_CODE){if(this.expr.charCodeAt(this.index+1)!==e.PERIOD_CODE)break;n=!0,this.index+=2,this.gobbleSpaces(),r=this.code}this.index++,r===e.OBRACK_CODE?((t={type:e.MEMBER_EXP,computed:!0,object:t,property:this.gobbleExpression()}).property||this.throwError('Unexpected "'+this.char+'"'),this.gobbleSpaces(),(r=this.code)!==e.CBRACK_CODE&&this.throwError("Unclosed ["),this.index++):r===e.OPAREN_CODE?t={type:e.CALL_EXP,arguments:this.gobbleArguments(e.CPAREN_CODE),callee:t}:(r===e.PERIOD_CODE||n)&&(n&&this.index--,this.gobbleSpaces(),t={type:e.MEMBER_EXP,computed:!1,object:t,property:this.gobbleIdentifier()}),n&&(t.optional=!0),this.gobbleSpaces(),r=this.code}return t}},{key:"gobbleNumericLiteral",value:function(){for(var t,r,n="";e.isDecimalDigit(this.code);)n+=this.expr.charAt(this.index++);if(this.code===e.PERIOD_CODE)for(n+=this.expr.charAt(this.index++);e.isDecimalDigit(this.code);)n+=this.expr.charAt(this.index++);if("e"===(t=this.char)||"E"===t){for(n+=this.expr.charAt(this.index++),"+"!==(t=this.char)&&"-"!==t||(n+=this.expr.charAt(this.index++));e.isDecimalDigit(this.code);)n+=this.expr.charAt(this.index++);e.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+n+this.char+")")}return r=this.code,e.isIdentifierStart(r)?this.throwError("Variable names cannot start with a number ("+n+this.char+")"):(r===e.PERIOD_CODE||1===n.length&&n.charCodeAt(0)===e.PERIOD_CODE)&&this.throwError("Unexpected period"),{type:e.LITERAL,value:parseFloat(n),raw:n}}},{key:"gobbleStringLiteral",value:function(){for(var t="",r=this.index,n=this.expr.charAt(this.index++),i=!1;this.index<this.expr.length;){var o=this.expr.charAt(this.index++);if(o===n){i=!0;break}if("\\"===o)switch(o=this.expr.charAt(this.index++)){case"n":t+="\n";break;case"r":t+="\r";break;case"t":t+="\t";break;case"b":t+="\b";break;case"f":t+="\f";break;case"v":t+="\v";break;default:t+=o}else t+=o}return i||this.throwError('Unclosed quote after "'+t+'"'),{type:e.LITERAL,value:t,raw:this.expr.substring(r,this.index)}}},{key:"gobbleIdentifier",value:function(){var t=this.code,r=this.index;for(e.isIdentifierStart(t)?this.index++:this.throwError("Unexpected "+this.char);this.index<this.expr.length&&(t=this.code,e.isIdentifierPart(t));)this.index++;return{type:e.IDENTIFIER,name:this.expr.slice(r,this.index)}}},{key:"gobbleArguments",value:function(t){for(var r=[],n=!1,i=0;this.index<this.expr.length;){this.gobbleSpaces();var o=this.code;if(o===t){n=!0,this.index++,t===e.CPAREN_CODE&&i&&i>=r.length&&this.throwError("Unexpected token "+String.fromCharCode(t));break}if(o===e.COMMA_CODE){if(this.index++,++i!==r.length)if(t===e.CPAREN_CODE)this.throwError("Unexpected token ,");else if(t===e.CBRACK_CODE)for(var a=r.length;a<i;a++)r.push(null)}else if(r.length!==i&&0!==i)this.throwError("Expected comma");else{var s=this.gobbleExpression();s&&s.type!==e.COMPOUND||this.throwError("Expected comma"),r.push(s)}}return n||this.throwError("Expected "+String.fromCharCode(t)),r}},{key:"gobbleGroup",value:function(){this.index++;var t=this.gobbleExpressions(e.CPAREN_CODE);if(this.code===e.CPAREN_CODE)return this.index++,1===t.length?t[0]:!!t.length&&{type:e.SEQUENCE_EXP,expressions:t};this.throwError("Unclosed (")}},{key:"gobbleArray",value:function(){return this.index++,{type:e.ARRAY_EXP,elements:this.gobbleArguments(e.CBRACK_CODE)}}}],[{key:"version",get:function(){return"1.3.9"}},{key:"toString",value:function(){return"JavaScript Expression Parser (JSEP) v"+e.version}},{key:"addUnaryOp",value:function(t){return e.max_unop_len=Math.max(t.length,e.max_unop_len),e.unary_ops[t]=1,e}},{key:"addBinaryOp",value:function(t,r,n){return e.max_binop_len=Math.max(t.length,e.max_binop_len),e.binary_ops[t]=r,n?e.right_associative.add(t):e.right_associative.delete(t),e}},{key:"addIdentifierChar",value:function(t){return e.additional_identifier_chars.add(t),e}},{key:"addLiteral",value:function(t,r){return e.literals[t]=r,e}},{key:"removeUnaryOp",value:function(t){return delete e.unary_ops[t],t.length===e.max_unop_len&&(e.max_unop_len=e.getMaxKeyLen(e.unary_ops)),e}},{key:"removeAllUnaryOps",value:function(){return e.unary_ops={},e.max_unop_len=0,e}},{key:"removeIdentifierChar",value:function(t){return e.additional_identifier_chars.delete(t),e}},{key:"removeBinaryOp",value:function(t){return delete e.binary_ops[t],t.length===e.max_binop_len&&(e.max_binop_len=e.getMaxKeyLen(e.binary_ops)),e.right_associative.delete(t),e}},{key:"removeAllBinaryOps",value:function(){return e.binary_ops={},e.max_binop_len=0,e}},{key:"removeLiteral",value:function(t){return delete e.literals[t],e}},{key:"removeAllLiterals",value:function(){return e.literals={},e}},{key:"parse",value:function(t){return new e(t).parse()}},{key:"getMaxKeyLen",value:function(e){return Math.max.apply(Math,[0].concat(h(Object.keys(e).map((function(e){return e.length})))))}},{key:"isDecimalDigit",value:function(e){return e>=48&&e<=57}},{key:"binaryPrecedence",value:function(t){return e.binary_ops[t]||0}},{key:"isIdentifierStart",value:function(t){return t>=65&&t<=90||t>=97&&t<=122||t>=128&&!e.binary_ops[String.fromCharCode(t)]||e.additional_identifier_chars.has(String.fromCharCode(t))}},{key:"isIdentifierPart",value:function(t){return e.isIdentifierStart(t)||e.isDecimalDigit(t)}}])}(),g=new b;Object.assign(E,{hooks:g,plugins:new v(E),COMPOUND:"Compound",SEQUENCE_EXP:"SequenceExpression",IDENTIFIER:"Identifier",MEMBER_EXP:"MemberExpression",LITERAL:"Literal",THIS_EXP:"ThisExpression",CALL_EXP:"CallExpression",UNARY_EXP:"UnaryExpression",BINARY_EXP:"BinaryExpression",ARRAY_EXP:"ArrayExpression",TAB_CODE:9,LF_CODE:10,CR_CODE:13,SPACE_CODE:32,PERIOD_CODE:46,COMMA_CODE:44,SQUOTE_CODE:39,DQUOTE_CODE:34,OPAREN_CODE:40,CPAREN_CODE:41,OBRACK_CODE:91,CBRACK_CODE:93,QUMARK_CODE:63,SEMCOL_CODE:59,COLON_CODE:58,unary_ops:{"-":1,"!":1,"~":1,"+":1},binary_ops:{"||":1,"&&":2,"|":3,"^":4,"&":5,"==":6,"!=":6,"===":6,"!==":6,"<":7,">":7,"<=":7,">=":7,"<<":8,">>":8,">>>":8,"+":9,"-":9,"*":10,"/":10,"%":10},right_associative:new Set,additional_identifier_chars:new Set(["$","_"]),literals:{true:!0,false:!1,null:null},this_str:"this"}),E.max_unop_len=E.getMaxKeyLen(E.unary_ops),E.max_binop_len=E.getMaxKeyLen(E.binary_ops);var x=function(e){return new E(e).parse()},F=Object.getOwnPropertyNames(o((function e(){r(this,e)})));Object.getOwnPropertyNames(E).filter((function(e){return!F.includes(e)&&void 0===x[e]})).forEach((function(e){x[e]=E[e]})),x.Jsep=E;var D={name:"ternary",init:function(e){e.hooks.add("after-expression",(function(t){if(t.node&&this.code===e.QUMARK_CODE){this.index++;var r=t.node,n=this.gobbleExpression();if(n||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===e.COLON_CODE){this.index++;var i=this.gobbleExpression();if(i||this.throwError("Expected expression"),t.node={type:"ConditionalExpression",test:r,consequent:n,alternate:i},r.operator&&e.binary_ops[r.operator]<=.9){for(var o=r;o.right.operator&&e.binary_ops[o.right.operator]<=.9;)o=o.right;t.node.test=o.right,o.right=t.node,t.node=r}}else this.throwError("Expected :")}}))}};x.plugins.register(D);var _={name:"regex",init:function(e){e.hooks.add("gobble-token",(function(t){if(47===this.code){for(var r=++this.index,n=!1;this.index<this.expr.length;){if(47===this.code&&!n){for(var i=this.expr.slice(r,this.index),o="";++this.index<this.expr.length;){var a=this.code;if(!(a>=97&&a<=122||a>=65&&a<=90||a>=48&&a<=57))break;o+=this.char}var s=void 0;try{s=new RegExp(i,o)}catch(e){this.throwError(e.message)}return t.node={type:e.LITERAL,value:s,raw:this.expr.slice(r-1,this.index)},t.node=this.gobbleTokenProperty(t.node),t.node}this.code===e.OBRACK_CODE?n=!0:n&&this.code===e.CBRACK_CODE&&(n=!1),this.index+=92===this.code?2:1}this.throwError("Unclosed Regex")}}))}},m={name:"assignment",assignmentOperators:new Set(["=","*=","**=","/=","%=","+=","-=","<<=",">>=",">>>=","&=","^=","|="]),updateOperators:[43,45],assignmentPrecedence:.9,init:function(e){var t=[e.IDENTIFIER,e.MEMBER_EXP];function r(e){m.assignmentOperators.has(e.operator)?(e.type="AssignmentExpression",r(e.left),r(e.right)):e.operator||Object.values(e).forEach((function(e){e&&"object"===f(e)&&r(e)}))}m.assignmentOperators.forEach((function(t){return e.addBinaryOp(t,m.assignmentPrecedence,!0)})),e.hooks.add("gobble-token",(function(e){var r=this,n=this.code;m.updateOperators.some((function(e){return e===n&&e===r.expr.charCodeAt(r.index+1)}))&&(this.index+=2,e.node={type:"UpdateExpression",operator:43===n?"++":"--",argument:this.gobbleTokenProperty(this.gobbleIdentifier()),prefix:!0},e.node.argument&&t.includes(e.node.argument.type)||this.throwError("Unexpected ".concat(e.node.operator)))})),e.hooks.add("after-token",(function(e){var r=this;if(e.node){var n=this.code;m.updateOperators.some((function(e){return e===n&&e===r.expr.charCodeAt(r.index+1)}))&&(t.includes(e.node.type)||this.throwError("Unexpected ".concat(e.node.operator)),this.index+=2,e.node={type:"UpdateExpression",operator:43===n?"++":"--",argument:e.node,prefix:!1})}})),e.hooks.add("after-expression",(function(e){e.node&&r(e.node)}))}},C=Object.prototype.hasOwnProperty;function O(e,t){return(e=e.slice()).push(t),e}function A(e,t){return(t=t.slice()).unshift(e),t}var w=function(){function e(n){var i;return r(this,e),(i=t(this,e,['JSONPath should not be called with "new" (it prevents return of (unwrapped) scalar values)'])).avoidNew=!0,i.value=n,i.name="NewError",i}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&l(e,t)}(e,y(Error)),o(e)}();function k(e,t,r,n,i){if(!(this instanceof k))try{return new k(e,t,r,n,i)}catch(e){if(!e.avoidNew)throw e;return e.value}"string"==typeof e&&(i=n,n=r,r=t,t=e,e=null);var o=e&&"object"===f(e);if(e=e||{},this.json=e.json||r,this.path=e.path||t,this.resultType=e.resultType||"value",this.flatten=e.flatten||!1,this.wrap=!C.call(e,"wrap")||e.wrap,this.sandbox=e.sandbox||{},this.eval=void 0===e.eval?"safe":e.eval,this.ignoreEvalErrors=void 0!==e.ignoreEvalErrors&&e.ignoreEvalErrors,this.parent=e.parent||null,this.parentProperty=e.parentProperty||null,this.callback=e.callback||n||null,this.otherTypeCallback=e.otherTypeCallback||i||function(){throw new TypeError("You must supply an otherTypeCallback callback option with the @other() operator.")},!1!==e.autostart){var a={path:o?e.path:t};o?"json"in e&&(a.json=e.json):a.json=r;var s=this.evaluate(a);if(!s||"object"!==f(s))throw new w(s);return s}}k.prototype.evaluate=function(e,t,r,n){var i=this,o=this.parent,a=this.parentProperty,s=this.flatten,u=this.wrap;if(this.currResultType=this.resultType,this.currEval=this.eval,this.currSandbox=this.sandbox,r=r||this.callback,this.currOtherTypeCallback=n||this.otherTypeCallback,t=t||this.json,(e=e||this.path)&&"object"===f(e)&&!Array.isArray(e)){if(!e.path&&""!==e.path)throw new TypeError('You must supply a "path" property when providing an object argument to JSONPath.evaluate().');if(!C.call(e,"json"))throw new TypeError('You must supply a "json" property when providing an object argument to JSONPath.evaluate().');t=e.json,s=C.call(e,"flatten")?e.flatten:s,this.currResultType=C.call(e,"resultType")?e.resultType:this.currResultType,this.currSandbox=C.call(e,"sandbox")?e.sandbox:this.currSandbox,u=C.call(e,"wrap")?e.wrap:u,this.currEval=C.call(e,"eval")?e.eval:this.currEval,r=C.call(e,"callback")?e.callback:r,this.currOtherTypeCallback=C.call(e,"otherTypeCallback")?e.otherTypeCallback:this.currOtherTypeCallback,o=C.call(e,"parent")?e.parent:o,a=C.call(e,"parentProperty")?e.parentProperty:a,e=e.path}if(o=o||null,a=a||null,Array.isArray(e)&&(e=k.toPathString(e)),(e||""===e)&&t){var c=k.toPathArray(e);"$"===c[0]&&c.length>1&&c.shift(),this._hasParentSelector=null;var l=this._trace(c,t,["$"],o,a,r).filter((function(e){return e&&!e.isParentSelector}));return l.length?u||1!==l.length||l[0].hasArrExpr?l.reduce((function(e,t){var r=i._getPreferredOutput(t);return s&&Array.isArray(r)?e=e.concat(r):e.push(r),e}),[]):this._getPreferredOutput(l[0]):u?[]:void 0}},k.prototype._getPreferredOutput=function(e){var t=this.currResultType;switch(t){case"all":var r=Array.isArray(e.path)?e.path:k.toPathArray(e.path);return e.pointer=k.toPointer(r),e.path="string"==typeof e.path?e.path:k.toPathString(e.path),e;case"value":case"parent":case"parentProperty":return e[t];case"path":return k.toPathString(e[t]);case"pointer":return k.toPointer(e.path);default:throw new TypeError("Unknown result type")}},k.prototype._handleCallback=function(e,t,r){if(t){var n=this._getPreferredOutput(e);e.path="string"==typeof e.path?e.path:k.toPathString(e.path),t(n,r,e)}},k.prototype._trace=function(e,t,r,n,i,o,a,s){var u,c=this;if(!e.length)return u={path:r,value:t,parent:n,parentProperty:i,hasArrExpr:a},this._handleCallback(u,o,"value"),u;var l=e[0],h=e.slice(1),p=[];function y(e){Array.isArray(e)?e.forEach((function(e){p.push(e)})):p.push(e)}if(("string"!=typeof l||s)&&t&&C.call(t,l))y(this._trace(h,t[l],O(r,l),t,l,o,a));else if("*"===l)this._walk(t,(function(e){y(c._trace(h,t[e],O(r,e),t,e,o,!0,!0))}));else if(".."===l)y(this._trace(h,t,r,n,i,o,a)),this._walk(t,(function(n){"object"===f(t[n])&&y(c._trace(e.slice(),t[n],O(r,n),t,n,o,!0))}));else{if("^"===l)return this._hasParentSelector=!0,{path:r.slice(0,-1),expr:h,isParentSelector:!0};if("~"===l)return u={path:O(r,l),value:i,parent:n,parentProperty:null},this._handleCallback(u,o,"property"),u;if("$"===l)y(this._trace(h,t,r,null,null,o,a));else if(/^(-?[0-9]*):(-?[0-9]*):?([0-9]*)$/.test(l))y(this._slice(l,h,t,r,n,i,o));else if(0===l.indexOf("?(")){if(!1===this.currEval)throw new Error("Eval [?(expr)] prevented in JSONPath expression.");var b=l.replace(/^\?\(((?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*?)\)$/,"$1"),v=/@(?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])?((?:[\0->@-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*)['\[](\??\((?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*?\))(?!(?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])\)\])['\]]/g.exec(b);v?this._walk(t,(function(e){var a=[v[2]],s=v[1]?t[e][v[1]]:t[e];c._trace(a,s,r,n,i,o,!0).length>0&&y(c._trace(h,t[e],O(r,e),t,e,o,!0))})):this._walk(t,(function(e){c._eval(b,t[e],e,r,n,i)&&y(c._trace(h,t[e],O(r,e),t,e,o,!0))}))}else if("("===l[0]){if(!1===this.currEval)throw new Error("Eval [(expr)] prevented in JSONPath expression.");y(this._trace(A(this._eval(l,t,r[r.length-1],r.slice(0,-1),n,i),h),t,r,n,i,o,a))}else if("@"===l[0]){var E=!1,g=l.slice(1,-2);switch(g){case"scalar":t&&["object","function"].includes(f(t))||(E=!0);break;case"boolean":case"string":case"undefined":case"function":f(t)===g&&(E=!0);break;case"integer":!Number.isFinite(t)||t%1||(E=!0);break;case"number":Number.isFinite(t)&&(E=!0);break;case"nonFinite":"number"!=typeof t||Number.isFinite(t)||(E=!0);break;case"object":t&&f(t)===g&&(E=!0);break;case"array":Array.isArray(t)&&(E=!0);break;case"other":E=this.currOtherTypeCallback(t,r,n,i);break;case"null":null===t&&(E=!0);break;default:throw new TypeError("Unknown value type "+g)}if(E)return u={path:r,value:t,parent:n,parentProperty:i},this._handleCallback(u,o,"value"),u}else if("`"===l[0]&&t&&C.call(t,l.slice(1))){var x=l.slice(1);y(this._trace(h,t[x],O(r,x),t,x,o,a,!0))}else if(l.includes(",")){var F,D=function(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=d(e))||t){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}(l.split(","));try{for(D.s();!(F=D.n()).done;){var _=F.value;y(this._trace(A(_,h),t,r,n,i,o,!0))}}catch(e){D.e(e)}finally{D.f()}}else!s&&t&&C.call(t,l)&&y(this._trace(h,t[l],O(r,l),t,l,o,a,!0))}if(this._hasParentSelector)for(var m=0;m<p.length;m++){var w=p[m];if(w&&w.isParentSelector){var k=this._trace(w.expr,t,w.path,n,i,o,a);if(Array.isArray(k)){p[m]=k[0];for(var P=k.length,S=1;S<P;S++)m++,p.splice(m,0,k[S])}else p[m]=k}}return p},k.prototype._walk=function(e,t){if(Array.isArray(e))for(var r=e.length,n=0;n<r;n++)t(n);else e&&"object"===f(e)&&Object.keys(e).forEach((function(e){t(e)}))},k.prototype._slice=function(e,t,r,n,i,o,a){if(Array.isArray(r)){var s=r.length,u=e.split(":"),c=u[2]&&Number.parseInt(u[2])||1,l=u[0]&&Number.parseInt(u[0])||0,h=u[1]&&Number.parseInt(u[1])||s;l=l<0?Math.max(0,l+s):Math.min(s,l),h=h<0?Math.max(0,h+s):Math.min(s,h);for(var p=[],f=l;f<h;f+=c){this._trace(A(f,t),r,n,i,o,a,!0).forEach((function(e){p.push(e)}))}return p}},k.prototype._eval=function(e,t,r,n,i,o){var a=this;this.currSandbox._$_parentProperty=o,this.currSandbox._$_parent=i,this.currSandbox._$_property=r,this.currSandbox._$_root=this.json,this.currSandbox._$_v=t;var s=e.includes("@path");s&&(this.currSandbox._$_path=k.toPathString(n.concat([r])));var u=this.currEval+"Script:"+e;if(!k.cache[u]){var c=e.replace(/@parentProperty/g,"_$_parentProperty").replace(/@parent/g,"_$_parent").replace(/@property/g,"_$_property").replace(/@root/g,"_$_root").replace(/@([\t-\r \)\.\[\xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF])/g,"_$_v$1");if(s&&(c=c.replace(/@path/g,"_$_path")),"safe"===this.currEval||!0===this.currEval||void 0===this.currEval)k.cache[u]=new this.safeVm.Script(c);else if("native"===this.currEval)k.cache[u]=new this.vm.Script(c);else if("function"==typeof this.currEval&&this.currEval.prototype&&C.call(this.currEval.prototype,"runInNewContext")){var l=this.currEval;k.cache[u]=new l(c)}else{if("function"!=typeof this.currEval)throw new TypeError('Unknown "eval" property "'.concat(this.currEval,'"'));k.cache[u]={runInNewContext:function(e){return a.currEval(c,e)}}}}try{return k.cache[u].runInNewContext(this.currSandbox)}catch(t){if(this.ignoreEvalErrors)return!1;throw new Error("jsonPath: "+t.message+": "+e)}},k.cache={},k.toPathString=function(e){for(var t=e,r=t.length,n="$",i=1;i<r;i++)/^(~|\^|@(?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*?\(\))$/.test(t[i])||(n+=/^[\*0-9]+$/.test(t[i])?"["+t[i]+"]":"['"+t[i]+"']");return n},k.toPointer=function(e){for(var t=e,r=t.length,n="",i=1;i<r;i++)/^(~|\^|@(?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*?\(\))$/.test(t[i])||(n+="/"+t[i].toString().replace(/~/g,"~0").replace(/\//g,"~1"));return n},k.toPathArray=function(e){var t=k.cache;if(t[e])return t[e].concat();var r=[],n=e.replace(/@(?:null|boolean|number|string|integer|undefined|nonFinite|scalar|array|object|function|other)\(\)/g,";$&;").replace(/['\[](\??\((?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*?\))['\]](?!(?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])\])/g,(function(e,t){return"[#"+(r.push(t)-1)+"]"})).replace(/\[["']((?:[\0-&\(-\\\^-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*)["']\]/g,(function(e,t){return"['"+t.replace(/\./g,"%@%").replace(/~/g,"%%@@%%")+"']"})).replace(/~/g,";~;").replace(/["']?\.["']?(?!(?:[\0-Z\\-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*\])|\[["']?/g,";").replace(/%@%/g,".").replace(/%%@@%%/g,"~").replace(/(?:;)?(\^+)(?:;)?/g,(function(e,t){return";"+t.split("").join(";")+";"})).replace(/;;;|;;/g,";..;").replace(/;$|'?\]|'$/g,"").split(";").map((function(e){var t=e.match(/#([0-9]+)/);return t&&t[1]?r[t[1]]:e}));return t[e]=n,t[e].concat()};x.plugins.register(_,m);var P={evalAst:function(e,t){switch(e.type){case"BinaryExpression":case"LogicalExpression":return P.evalBinaryExpression(e,t);case"Compound":return P.evalCompound(e,t);case"ConditionalExpression":return P.evalConditionalExpression(e,t);case"Identifier":return P.evalIdentifier(e,t);case"Literal":return P.evalLiteral(e,t);case"MemberExpression":return P.evalMemberExpression(e,t);case"UnaryExpression":return P.evalUnaryExpression(e,t);case"ArrayExpression":return P.evalArrayExpression(e,t);case"CallExpression":return P.evalCallExpression(e,t);case"AssignmentExpression":return P.evalAssignmentExpression(e,t);default:throw SyntaxError("Unexpected expression",e)}},evalBinaryExpression:function(e,t){return{"||":function(e,t){return e||t()},"&&":function(e,t){return e&&t()},"|":function(e,t){return e|t()},"^":function(e,t){return e^t()},"&":function(e,t){return e&t()},"==":function(e,t){return e==t()},"!=":function(e,t){return e!=t()},"===":function(e,t){return e===t()},"!==":function(e,t){return e!==t()},"<":function(e,t){return e<t()},">":function(e,t){return e>t()},"<=":function(e,t){return e<=t()},">=":function(e,t){return e>=t()},"<<":function(e,t){return e<<t()},">>":function(e,t){return e>>t()},">>>":function(e,t){return e>>>t()},"+":function(e,t){return e+t()},"-":function(e,t){return e-t()},"*":function(e,t){return e*t()},"/":function(e,t){return e/t()},"%":function(e,t){return e%t()}}[e.operator](P.evalAst(e.left,t),(function(){return P.evalAst(e.right,t)}))},evalCompound:function(e,t){for(var r,n=0;n<e.body.length;n++){"Identifier"===e.body[n].type&&["var","let","const"].includes(e.body[n].name)&&e.body[n+1]&&"AssignmentExpression"===e.body[n+1].type&&(n+=1);var i=e.body[n];r=P.evalAst(i,t)}return r},evalConditionalExpression:function(e,t){return P.evalAst(e.test,t)?P.evalAst(e.consequent,t):P.evalAst(e.alternate,t)},evalIdentifier:function(e,t){if(e.name in t)return t[e.name];throw ReferenceError("".concat(e.name," is not defined"))},evalLiteral:function(e){return e.value},evalMemberExpression:function(e,t){var r=e.computed?P.evalAst(e.property):e.property.name,n=P.evalAst(e.object,t),i=n[r];return"function"==typeof i?i.bind(n):i},evalUnaryExpression:function(e,t){return{"-":function(e){return-P.evalAst(e,t)},"!":function(e){return!P.evalAst(e,t)},"~":function(e){return~P.evalAst(e,t)},"+":function(e){return+P.evalAst(e,t)}}[e.operator](e.argument)},evalArrayExpression:function(e,t){return e.elements.map((function(e){return P.evalAst(e,t)}))},evalCallExpression:function(e,t){var r=e.arguments.map((function(e){return P.evalAst(e,t)}));return P.evalAst(e.callee,t).apply(void 0,h(r))},evalAssignmentExpression:function(e,t){if("Identifier"!==e.left.type)throw SyntaxError("Invalid left-hand side in assignment");var r=e.left.name,n=P.evalAst(e.right,t);return t[r]=n,t[r]}},S=function(){return o((function e(t){r(this,e),this.code=t,this.ast=x(this.code)}),[{key:"runInNewContext",value:function(e){var t=function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?c(Object(r),!0).forEach((function(t){a(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):c(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}({},e);return P.evalAst(this.ast,t)}}])}(),B=function(){return o((function e(t){r(this,e),this.code=t}),[{key:"runInNewContext",value:function(e){var t=this.code,r=Object.keys(e),i=[];!function(e,t,r){for(var n=e.length,i=0;i<n;i++)r(e[i])&&t.push(e.splice(i--,1)[0])}(r,i,(function(t){return"function"==typeof e[t]}));var o=r.map((function(t){return e[t]})),a=i.reduce((function(t,r){var n=e[r].toString();return/function/.test(n)||(n="function "+n),"var "+r+"="+n+";"+t}),"");/(["'])use strict\1/.test(t=a+t)||r.includes("arguments")||(t="var arguments = undefined;"+t);var s=(t=t.replace(/;[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]*$/,"")).lastIndexOf(";"),u=s>-1?t.slice(0,s+1)+" return "+t.slice(s+1):" return "+t;return n(Function,r.concat([u])).apply(void 0,h(o))}}])}();k.prototype.vm={Script:B},k.prototype.safeVm={Script:S};export{k as JSONPath,S as SafeScript}; +function e(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function t(e,t,r){return t=s(t),function(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,u()?Reflect.construct(t,r||[],s(e).constructor):t.apply(e,r))}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(e,t,r){if(u())return Reflect.construct.apply(null,arguments);var n=[null];n.push.apply(n,t);var i=new(e.bind.apply(e,n));return r&&h(i,r.prototype),i}function i(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,p(n.key),n)}}function o(e,t,r){return t&&i(e.prototype,t),r&&i(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function a(e,t,r){return(t=p(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function s(e){return s=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},s(e)}function u(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(u=function(){return!!e})()}function c(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function h(e,t){return h=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},h(e,t)}function l(t){return function(t){if(Array.isArray(t))return e(t)}(t)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(t)||d(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function p(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t);if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e,"string");return"symbol"==typeof t?t:t+""}function f(e){return f="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},f(e)}function d(t,r){if(t){if("string"==typeof t)return e(t,r);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?e(t,r):void 0}}function y(e){var t="function"==typeof Map?new Map:void 0;return y=function(e){if(null===e||!function(e){try{return-1!==Function.toString.call(e).indexOf("[native code]")}catch(t){return"function"==typeof e}}(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return n(e,arguments,s(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),h(r,e)},y(e)}var b=function(){return o((function e(){r(this,e)}),[{key:"add",value:function(e,t,r){if("string"!=typeof arguments[0])for(var n in arguments[0])this.add(n,arguments[0][n],arguments[1]);else(Array.isArray(e)?e:[e]).forEach((function(e){this[e]=this[e]||[],t&&this[e][r?"unshift":"push"](t)}),this)}},{key:"run",value:function(e,t){this[e]=this[e]||[],this[e].forEach((function(e){e.call(t&&t.context?t.context:t,t)}))}}])}(),v=function(){return o((function e(t){r(this,e),this.jsep=t,this.registered={}}),[{key:"register",value:function(){for(var e=this,t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];r.forEach((function(t){if("object"!==f(t)||!t.name||!t.init)throw new Error("Invalid JSEP plugin format");e.registered[t.name]||(t.init(e.jsep),e.registered[t.name]=t)}))}}])}(),E=function(){function e(t){r(this,e),this.expr=t,this.index=0}return o(e,[{key:"char",get:function(){return this.expr.charAt(this.index)}},{key:"code",get:function(){return this.expr.charCodeAt(this.index)}},{key:"throwError",value:function(e){var t=new Error(e+" at character "+this.index);throw t.index=this.index,t.description=e,t}},{key:"runHook",value:function(t,r){if(e.hooks[t]){var n={context:this,node:r};return e.hooks.run(t,n),n.node}return r}},{key:"searchHook",value:function(t){if(e.hooks[t]){var r={context:this};return e.hooks[t].find((function(e){return e.call(r.context,r),r.node})),r.node}}},{key:"gobbleSpaces",value:function(){for(var t=this.code;t===e.SPACE_CODE||t===e.TAB_CODE||t===e.LF_CODE||t===e.CR_CODE;)t=this.expr.charCodeAt(++this.index);this.runHook("gobble-spaces")}},{key:"parse",value:function(){this.runHook("before-all");var t=this.gobbleExpressions(),r=1===t.length?t[0]:{type:e.COMPOUND,body:t};return this.runHook("after-all",r)}},{key:"gobbleExpressions",value:function(t){for(var r,n,i=[];this.index<this.expr.length;)if((r=this.code)===e.SEMCOL_CODE||r===e.COMMA_CODE)this.index++;else if(n=this.gobbleExpression())i.push(n);else if(this.index<this.expr.length){if(r===t)break;this.throwError('Unexpected "'+this.char+'"')}return i}},{key:"gobbleExpression",value:function(){var e=this.searchHook("gobble-expression")||this.gobbleBinaryExpression();return this.gobbleSpaces(),this.runHook("after-expression",e)}},{key:"gobbleBinaryOp",value:function(){this.gobbleSpaces();for(var t=this.expr.substr(this.index,e.max_binop_len),r=t.length;r>0;){if(e.binary_ops.hasOwnProperty(t)&&(!e.isIdentifierStart(this.code)||this.index+t.length<this.expr.length&&!e.isIdentifierPart(this.expr.charCodeAt(this.index+t.length))))return this.index+=r,t;t=t.substr(0,--r)}return!1}},{key:"gobbleBinaryExpression",value:function(){var t,r,n,i,o,a,s,u,c,h;if(!(a=this.gobbleToken()))return a;if(!(r=this.gobbleBinaryOp()))return a;for(o={value:r,prec:e.binaryPrecedence(r),right_a:e.right_associative.has(r)},(s=this.gobbleToken())||this.throwError("Expected expression after "+r),i=[a,o,s];r=this.gobbleBinaryOp();){if(0===(n=e.binaryPrecedence(r))){this.index-=r.length;break}o={value:r,prec:n,right_a:e.right_associative.has(r)},c=r;for(;i.length>2&&(h=i[i.length-2],o.right_a&&h.right_a?n>h.prec:n<=h.prec);)s=i.pop(),r=i.pop().value,a=i.pop(),t={type:e.BINARY_EXP,operator:r,left:a,right:s},i.push(t);(t=this.gobbleToken())||this.throwError("Expected expression after "+c),i.push(o,t)}for(t=i[u=i.length-1];u>1;)t={type:e.BINARY_EXP,operator:i[u-1].value,left:i[u-2],right:t},u-=2;return t}},{key:"gobbleToken",value:function(){var t,r,n,i;if(this.gobbleSpaces(),i=this.searchHook("gobble-token"))return this.runHook("after-token",i);if(t=this.code,e.isDecimalDigit(t)||t===e.PERIOD_CODE)return this.gobbleNumericLiteral();if(t===e.SQUOTE_CODE||t===e.DQUOTE_CODE)i=this.gobbleStringLiteral();else if(t===e.OBRACK_CODE)i=this.gobbleArray();else{for(n=(r=this.expr.substr(this.index,e.max_unop_len)).length;n>0;){if(e.unary_ops.hasOwnProperty(r)&&(!e.isIdentifierStart(this.code)||this.index+r.length<this.expr.length&&!e.isIdentifierPart(this.expr.charCodeAt(this.index+r.length)))){this.index+=n;var o=this.gobbleToken();return o||this.throwError("missing unaryOp argument"),this.runHook("after-token",{type:e.UNARY_EXP,operator:r,argument:o,prefix:!0})}r=r.substr(0,--n)}e.isIdentifierStart(t)?(i=this.gobbleIdentifier(),e.literals.hasOwnProperty(i.name)?i={type:e.LITERAL,value:e.literals[i.name],raw:i.name}:i.name===e.this_str&&(i={type:e.THIS_EXP})):t===e.OPAREN_CODE&&(i=this.gobbleGroup())}return i?(i=this.gobbleTokenProperty(i),this.runHook("after-token",i)):this.runHook("after-token",!1)}},{key:"gobbleTokenProperty",value:function(t){this.gobbleSpaces();for(var r=this.code;r===e.PERIOD_CODE||r===e.OBRACK_CODE||r===e.OPAREN_CODE||r===e.QUMARK_CODE;){var n=void 0;if(r===e.QUMARK_CODE){if(this.expr.charCodeAt(this.index+1)!==e.PERIOD_CODE)break;n=!0,this.index+=2,this.gobbleSpaces(),r=this.code}this.index++,r===e.OBRACK_CODE?((t={type:e.MEMBER_EXP,computed:!0,object:t,property:this.gobbleExpression()}).property||this.throwError('Unexpected "'+this.char+'"'),this.gobbleSpaces(),(r=this.code)!==e.CBRACK_CODE&&this.throwError("Unclosed ["),this.index++):r===e.OPAREN_CODE?t={type:e.CALL_EXP,arguments:this.gobbleArguments(e.CPAREN_CODE),callee:t}:(r===e.PERIOD_CODE||n)&&(n&&this.index--,this.gobbleSpaces(),t={type:e.MEMBER_EXP,computed:!1,object:t,property:this.gobbleIdentifier()}),n&&(t.optional=!0),this.gobbleSpaces(),r=this.code}return t}},{key:"gobbleNumericLiteral",value:function(){for(var t,r,n="";e.isDecimalDigit(this.code);)n+=this.expr.charAt(this.index++);if(this.code===e.PERIOD_CODE)for(n+=this.expr.charAt(this.index++);e.isDecimalDigit(this.code);)n+=this.expr.charAt(this.index++);if("e"===(t=this.char)||"E"===t){for(n+=this.expr.charAt(this.index++),"+"!==(t=this.char)&&"-"!==t||(n+=this.expr.charAt(this.index++));e.isDecimalDigit(this.code);)n+=this.expr.charAt(this.index++);e.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+n+this.char+")")}return r=this.code,e.isIdentifierStart(r)?this.throwError("Variable names cannot start with a number ("+n+this.char+")"):(r===e.PERIOD_CODE||1===n.length&&n.charCodeAt(0)===e.PERIOD_CODE)&&this.throwError("Unexpected period"),{type:e.LITERAL,value:parseFloat(n),raw:n}}},{key:"gobbleStringLiteral",value:function(){for(var t="",r=this.index,n=this.expr.charAt(this.index++),i=!1;this.index<this.expr.length;){var o=this.expr.charAt(this.index++);if(o===n){i=!0;break}if("\\"===o)switch(o=this.expr.charAt(this.index++)){case"n":t+="\n";break;case"r":t+="\r";break;case"t":t+="\t";break;case"b":t+="\b";break;case"f":t+="\f";break;case"v":t+="\v";break;default:t+=o}else t+=o}return i||this.throwError('Unclosed quote after "'+t+'"'),{type:e.LITERAL,value:t,raw:this.expr.substring(r,this.index)}}},{key:"gobbleIdentifier",value:function(){var t=this.code,r=this.index;for(e.isIdentifierStart(t)?this.index++:this.throwError("Unexpected "+this.char);this.index<this.expr.length&&(t=this.code,e.isIdentifierPart(t));)this.index++;return{type:e.IDENTIFIER,name:this.expr.slice(r,this.index)}}},{key:"gobbleArguments",value:function(t){for(var r=[],n=!1,i=0;this.index<this.expr.length;){this.gobbleSpaces();var o=this.code;if(o===t){n=!0,this.index++,t===e.CPAREN_CODE&&i&&i>=r.length&&this.throwError("Unexpected token "+String.fromCharCode(t));break}if(o===e.COMMA_CODE){if(this.index++,++i!==r.length)if(t===e.CPAREN_CODE)this.throwError("Unexpected token ,");else if(t===e.CBRACK_CODE)for(var a=r.length;a<i;a++)r.push(null)}else if(r.length!==i&&0!==i)this.throwError("Expected comma");else{var s=this.gobbleExpression();s&&s.type!==e.COMPOUND||this.throwError("Expected comma"),r.push(s)}}return n||this.throwError("Expected "+String.fromCharCode(t)),r}},{key:"gobbleGroup",value:function(){this.index++;var t=this.gobbleExpressions(e.CPAREN_CODE);if(this.code===e.CPAREN_CODE)return this.index++,1===t.length?t[0]:!!t.length&&{type:e.SEQUENCE_EXP,expressions:t};this.throwError("Unclosed (")}},{key:"gobbleArray",value:function(){return this.index++,{type:e.ARRAY_EXP,elements:this.gobbleArguments(e.CBRACK_CODE)}}}],[{key:"version",get:function(){return"1.3.9"}},{key:"toString",value:function(){return"JavaScript Expression Parser (JSEP) v"+e.version}},{key:"addUnaryOp",value:function(t){return e.max_unop_len=Math.max(t.length,e.max_unop_len),e.unary_ops[t]=1,e}},{key:"addBinaryOp",value:function(t,r,n){return e.max_binop_len=Math.max(t.length,e.max_binop_len),e.binary_ops[t]=r,n?e.right_associative.add(t):e.right_associative.delete(t),e}},{key:"addIdentifierChar",value:function(t){return e.additional_identifier_chars.add(t),e}},{key:"addLiteral",value:function(t,r){return e.literals[t]=r,e}},{key:"removeUnaryOp",value:function(t){return delete e.unary_ops[t],t.length===e.max_unop_len&&(e.max_unop_len=e.getMaxKeyLen(e.unary_ops)),e}},{key:"removeAllUnaryOps",value:function(){return e.unary_ops={},e.max_unop_len=0,e}},{key:"removeIdentifierChar",value:function(t){return e.additional_identifier_chars.delete(t),e}},{key:"removeBinaryOp",value:function(t){return delete e.binary_ops[t],t.length===e.max_binop_len&&(e.max_binop_len=e.getMaxKeyLen(e.binary_ops)),e.right_associative.delete(t),e}},{key:"removeAllBinaryOps",value:function(){return e.binary_ops={},e.max_binop_len=0,e}},{key:"removeLiteral",value:function(t){return delete e.literals[t],e}},{key:"removeAllLiterals",value:function(){return e.literals={},e}},{key:"parse",value:function(t){return new e(t).parse()}},{key:"getMaxKeyLen",value:function(e){return Math.max.apply(Math,[0].concat(l(Object.keys(e).map((function(e){return e.length})))))}},{key:"isDecimalDigit",value:function(e){return e>=48&&e<=57}},{key:"binaryPrecedence",value:function(t){return e.binary_ops[t]||0}},{key:"isIdentifierStart",value:function(t){return t>=65&&t<=90||t>=97&&t<=122||t>=128&&!e.binary_ops[String.fromCharCode(t)]||e.additional_identifier_chars.has(String.fromCharCode(t))}},{key:"isIdentifierPart",value:function(t){return e.isIdentifierStart(t)||e.isDecimalDigit(t)}}])}(),g=new b;Object.assign(E,{hooks:g,plugins:new v(E),COMPOUND:"Compound",SEQUENCE_EXP:"SequenceExpression",IDENTIFIER:"Identifier",MEMBER_EXP:"MemberExpression",LITERAL:"Literal",THIS_EXP:"ThisExpression",CALL_EXP:"CallExpression",UNARY_EXP:"UnaryExpression",BINARY_EXP:"BinaryExpression",ARRAY_EXP:"ArrayExpression",TAB_CODE:9,LF_CODE:10,CR_CODE:13,SPACE_CODE:32,PERIOD_CODE:46,COMMA_CODE:44,SQUOTE_CODE:39,DQUOTE_CODE:34,OPAREN_CODE:40,CPAREN_CODE:41,OBRACK_CODE:91,CBRACK_CODE:93,QUMARK_CODE:63,SEMCOL_CODE:59,COLON_CODE:58,unary_ops:{"-":1,"!":1,"~":1,"+":1},binary_ops:{"||":1,"&&":2,"|":3,"^":4,"&":5,"==":6,"!=":6,"===":6,"!==":6,"<":7,">":7,"<=":7,">=":7,"<<":8,">>":8,">>>":8,"+":9,"-":9,"*":10,"/":10,"%":10},right_associative:new Set,additional_identifier_chars:new Set(["$","_"]),literals:{true:!0,false:!1,null:null},this_str:"this"}),E.max_unop_len=E.getMaxKeyLen(E.unary_ops),E.max_binop_len=E.getMaxKeyLen(E.binary_ops);var x=function(e){return new E(e).parse()},F=Object.getOwnPropertyNames(o((function e(){r(this,e)})));Object.getOwnPropertyNames(E).filter((function(e){return!F.includes(e)&&void 0===x[e]})).forEach((function(e){x[e]=E[e]})),x.Jsep=E;var D={name:"ternary",init:function(e){e.hooks.add("after-expression",(function(t){if(t.node&&this.code===e.QUMARK_CODE){this.index++;var r=t.node,n=this.gobbleExpression();if(n||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===e.COLON_CODE){this.index++;var i=this.gobbleExpression();if(i||this.throwError("Expected expression"),t.node={type:"ConditionalExpression",test:r,consequent:n,alternate:i},r.operator&&e.binary_ops[r.operator]<=.9){for(var o=r;o.right.operator&&e.binary_ops[o.right.operator]<=.9;)o=o.right;t.node.test=o.right,o.right=t.node,t.node=r}}else this.throwError("Expected :")}}))}};x.plugins.register(D);var _={name:"regex",init:function(e){e.hooks.add("gobble-token",(function(t){if(47===this.code){for(var r=++this.index,n=!1;this.index<this.expr.length;){if(47===this.code&&!n){for(var i=this.expr.slice(r,this.index),o="";++this.index<this.expr.length;){var a=this.code;if(!(a>=97&&a<=122||a>=65&&a<=90||a>=48&&a<=57))break;o+=this.char}var s=void 0;try{s=new RegExp(i,o)}catch(e){this.throwError(e.message)}return t.node={type:e.LITERAL,value:s,raw:this.expr.slice(r-1,this.index)},t.node=this.gobbleTokenProperty(t.node),t.node}this.code===e.OBRACK_CODE?n=!0:n&&this.code===e.CBRACK_CODE&&(n=!1),this.index+=92===this.code?2:1}this.throwError("Unclosed Regex")}}))}},O={name:"assignment",assignmentOperators:new Set(["=","*=","**=","/=","%=","+=","-=","<<=",">>=",">>>=","&=","^=","|="]),updateOperators:[43,45],assignmentPrecedence:.9,init:function(e){var t=[e.IDENTIFIER,e.MEMBER_EXP];function r(e){O.assignmentOperators.has(e.operator)?(e.type="AssignmentExpression",r(e.left),r(e.right)):e.operator||Object.values(e).forEach((function(e){e&&"object"===f(e)&&r(e)}))}O.assignmentOperators.forEach((function(t){return e.addBinaryOp(t,O.assignmentPrecedence,!0)})),e.hooks.add("gobble-token",(function(e){var r=this,n=this.code;O.updateOperators.some((function(e){return e===n&&e===r.expr.charCodeAt(r.index+1)}))&&(this.index+=2,e.node={type:"UpdateExpression",operator:43===n?"++":"--",argument:this.gobbleTokenProperty(this.gobbleIdentifier()),prefix:!0},e.node.argument&&t.includes(e.node.argument.type)||this.throwError("Unexpected ".concat(e.node.operator)))})),e.hooks.add("after-token",(function(e){var r=this;if(e.node){var n=this.code;O.updateOperators.some((function(e){return e===n&&e===r.expr.charCodeAt(r.index+1)}))&&(t.includes(e.node.type)||this.throwError("Unexpected ".concat(e.node.operator)),this.index+=2,e.node={type:"UpdateExpression",operator:43===n?"++":"--",argument:e.node,prefix:!1})}})),e.hooks.add("after-expression",(function(e){e.node&&r(e.node)}))}};x.plugins.register(_,O);var m={evalAst:function(e,t){switch(e.type){case"BinaryExpression":case"LogicalExpression":return m.evalBinaryExpression(e,t);case"Compound":return m.evalCompound(e,t);case"ConditionalExpression":return m.evalConditionalExpression(e,t);case"Identifier":return m.evalIdentifier(e,t);case"Literal":return m.evalLiteral(e,t);case"MemberExpression":return m.evalMemberExpression(e,t);case"UnaryExpression":return m.evalUnaryExpression(e,t);case"ArrayExpression":return m.evalArrayExpression(e,t);case"CallExpression":return m.evalCallExpression(e,t);case"AssignmentExpression":return m.evalAssignmentExpression(e,t);default:throw SyntaxError("Unexpected expression",e)}},evalBinaryExpression:function(e,t){return{"||":function(e,t){return e||t()},"&&":function(e,t){return e&&t()},"|":function(e,t){return e|t()},"^":function(e,t){return e^t()},"&":function(e,t){return e&t()},"==":function(e,t){return e==t()},"!=":function(e,t){return e!=t()},"===":function(e,t){return e===t()},"!==":function(e,t){return e!==t()},"<":function(e,t){return e<t()},">":function(e,t){return e>t()},"<=":function(e,t){return e<=t()},">=":function(e,t){return e>=t()},"<<":function(e,t){return e<<t()},">>":function(e,t){return e>>t()},">>>":function(e,t){return e>>>t()},"+":function(e,t){return e+t()},"-":function(e,t){return e-t()},"*":function(e,t){return e*t()},"/":function(e,t){return e/t()},"%":function(e,t){return e%t()}}[e.operator](m.evalAst(e.left,t),(function(){return m.evalAst(e.right,t)}))},evalCompound:function(e,t){for(var r,n=0;n<e.body.length;n++){"Identifier"===e.body[n].type&&["var","let","const"].includes(e.body[n].name)&&e.body[n+1]&&"AssignmentExpression"===e.body[n+1].type&&(n+=1);var i=e.body[n];r=m.evalAst(i,t)}return r},evalConditionalExpression:function(e,t){return m.evalAst(e.test,t)?m.evalAst(e.consequent,t):m.evalAst(e.alternate,t)},evalIdentifier:function(e,t){if(e.name in t)return t[e.name];throw ReferenceError("".concat(e.name," is not defined"))},evalLiteral:function(e){return e.value},evalMemberExpression:function(e,t){var r=e.computed?m.evalAst(e.property):e.property.name,n=m.evalAst(e.object,t),i=n[r];return"function"==typeof i?i.bind(n):i},evalUnaryExpression:function(e,t){return{"-":function(e){return-m.evalAst(e,t)},"!":function(e){return!m.evalAst(e,t)},"~":function(e){return~m.evalAst(e,t)},"+":function(e){return+m.evalAst(e,t)}}[e.operator](e.argument)},evalArrayExpression:function(e,t){return e.elements.map((function(e){return m.evalAst(e,t)}))},evalCallExpression:function(e,t){var r=e.arguments.map((function(e){return m.evalAst(e,t)}));return m.evalAst(e.callee,t).apply(void 0,l(r))},evalAssignmentExpression:function(e,t){if("Identifier"!==e.left.type)throw SyntaxError("Invalid left-hand side in assignment");var r=e.left.name,n=m.evalAst(e.right,t);return t[r]=n,t[r]}},C=function(){return o((function e(t){r(this,e),this.code=t,this.ast=x(this.code)}),[{key:"runInNewContext",value:function(e){var t=function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?c(Object(r),!0).forEach((function(t){a(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):c(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}({},e);return m.evalAst(this.ast,t)}}])}();function w(e,t){return(e=e.slice()).push(t),e}function A(e,t){return(t=t.slice()).unshift(e),t}var k=function(){function e(n){var i;return r(this,e),(i=t(this,e,['JSONPath should not be called with "new" (it prevents return of (unwrapped) scalar values)'])).avoidNew=!0,i.value=n,i.name="NewError",i}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&h(e,t)}(e,y(Error)),o(e)}();function P(e,t,r,n,i){if(!(this instanceof P))try{return new P(e,t,r,n,i)}catch(e){if(!e.avoidNew)throw e;return e.value}"string"==typeof e&&(i=n,n=r,r=t,t=e,e=null);var o=e&&"object"===f(e);if(e=e||{},this.json=e.json||r,this.path=e.path||t,this.resultType=e.resultType||"value",this.flatten=e.flatten||!1,this.wrap=!Object.hasOwn(e,"wrap")||e.wrap,this.sandbox=e.sandbox||{},this.eval=void 0===e.eval?"safe":e.eval,this.ignoreEvalErrors=void 0!==e.ignoreEvalErrors&&e.ignoreEvalErrors,this.parent=e.parent||null,this.parentProperty=e.parentProperty||null,this.callback=e.callback||n||null,this.otherTypeCallback=e.otherTypeCallback||i||function(){throw new TypeError("You must supply an otherTypeCallback callback option with the @other() operator.")},!1!==e.autostart){var a={path:o?e.path:t};o?"json"in e&&(a.json=e.json):a.json=r;var s=this.evaluate(a);if(!s||"object"!==f(s))throw new k(s);return s}}P.prototype.evaluate=function(e,t,r,n){var i=this,o=this.parent,a=this.parentProperty,s=this.flatten,u=this.wrap;if(this.currResultType=this.resultType,this.currEval=this.eval,this.currSandbox=this.sandbox,r=r||this.callback,this.currOtherTypeCallback=n||this.otherTypeCallback,t=t||this.json,(e=e||this.path)&&"object"===f(e)&&!Array.isArray(e)){if(!e.path&&""!==e.path)throw new TypeError('You must supply a "path" property when providing an object argument to JSONPath.evaluate().');if(!Object.hasOwn(e,"json"))throw new TypeError('You must supply a "json" property when providing an object argument to JSONPath.evaluate().');t=e.json,s=Object.hasOwn(e,"flatten")?e.flatten:s,this.currResultType=Object.hasOwn(e,"resultType")?e.resultType:this.currResultType,this.currSandbox=Object.hasOwn(e,"sandbox")?e.sandbox:this.currSandbox,u=Object.hasOwn(e,"wrap")?e.wrap:u,this.currEval=Object.hasOwn(e,"eval")?e.eval:this.currEval,r=Object.hasOwn(e,"callback")?e.callback:r,this.currOtherTypeCallback=Object.hasOwn(e,"otherTypeCallback")?e.otherTypeCallback:this.currOtherTypeCallback,o=Object.hasOwn(e,"parent")?e.parent:o,a=Object.hasOwn(e,"parentProperty")?e.parentProperty:a,e=e.path}if(o=o||null,a=a||null,Array.isArray(e)&&(e=P.toPathString(e)),(e||""===e)&&t){var c=P.toPathArray(e);"$"===c[0]&&c.length>1&&c.shift(),this._hasParentSelector=null;var h=this._trace(c,t,["$"],o,a,r).filter((function(e){return e&&!e.isParentSelector}));return h.length?u||1!==h.length||h[0].hasArrExpr?h.reduce((function(e,t){var r=i._getPreferredOutput(t);return s&&Array.isArray(r)?e=e.concat(r):e.push(r),e}),[]):this._getPreferredOutput(h[0]):u?[]:void 0}},P.prototype._getPreferredOutput=function(e){var t=this.currResultType;switch(t){case"all":var r=Array.isArray(e.path)?e.path:P.toPathArray(e.path);return e.pointer=P.toPointer(r),e.path="string"==typeof e.path?e.path:P.toPathString(e.path),e;case"value":case"parent":case"parentProperty":return e[t];case"path":return P.toPathString(e[t]);case"pointer":return P.toPointer(e.path);default:throw new TypeError("Unknown result type")}},P.prototype._handleCallback=function(e,t,r){if(t){var n=this._getPreferredOutput(e);e.path="string"==typeof e.path?e.path:P.toPathString(e.path),t(n,r,e)}},P.prototype._trace=function(e,t,r,n,i,o,a,s){var u,c=this;if(!e.length)return u={path:r,value:t,parent:n,parentProperty:i,hasArrExpr:a},this._handleCallback(u,o,"value"),u;var h=e[0],l=e.slice(1),p=[];function y(e){Array.isArray(e)?e.forEach((function(e){p.push(e)})):p.push(e)}if(("string"!=typeof h||s)&&t&&Object.hasOwn(t,h))y(this._trace(l,t[h],w(r,h),t,h,o,a));else if("*"===h)this._walk(t,(function(e){y(c._trace(l,t[e],w(r,e),t,e,o,!0,!0))}));else if(".."===h)y(this._trace(l,t,r,n,i,o,a)),this._walk(t,(function(n){"object"===f(t[n])&&y(c._trace(e.slice(),t[n],w(r,n),t,n,o,!0))}));else{if("^"===h)return this._hasParentSelector=!0,{path:r.slice(0,-1),expr:l,isParentSelector:!0};if("~"===h)return u={path:w(r,h),value:i,parent:n,parentProperty:null},this._handleCallback(u,o,"property"),u;if("$"===h)y(this._trace(l,t,r,null,null,o,a));else if(/^(-?[0-9]*):(-?[0-9]*):?([0-9]*)$/.test(h))y(this._slice(h,l,t,r,n,i,o));else if(0===h.indexOf("?(")){if(!1===this.currEval)throw new Error("Eval [?(expr)] prevented in JSONPath expression.");var b=h.replace(/^\?\(((?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*?)\)$/,"$1"),v=/@(?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])?((?:[\0->@-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*)['\[](\??\((?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*?\))(?!(?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])\)\])['\]]/g.exec(b);v?this._walk(t,(function(e){var a=[v[2]],s=v[1]?t[e][v[1]]:t[e];c._trace(a,s,r,n,i,o,!0).length>0&&y(c._trace(l,t[e],w(r,e),t,e,o,!0))})):this._walk(t,(function(e){c._eval(b,t[e],e,r,n,i)&&y(c._trace(l,t[e],w(r,e),t,e,o,!0))}))}else if("("===h[0]){if(!1===this.currEval)throw new Error("Eval [(expr)] prevented in JSONPath expression.");y(this._trace(A(this._eval(h,t,r[r.length-1],r.slice(0,-1),n,i),l),t,r,n,i,o,a))}else if("@"===h[0]){var E=!1,g=h.slice(1,-2);switch(g){case"scalar":t&&["object","function"].includes(f(t))||(E=!0);break;case"boolean":case"string":case"undefined":case"function":f(t)===g&&(E=!0);break;case"integer":!Number.isFinite(t)||t%1||(E=!0);break;case"number":Number.isFinite(t)&&(E=!0);break;case"nonFinite":"number"!=typeof t||Number.isFinite(t)||(E=!0);break;case"object":t&&f(t)===g&&(E=!0);break;case"array":Array.isArray(t)&&(E=!0);break;case"other":E=this.currOtherTypeCallback(t,r,n,i);break;case"null":null===t&&(E=!0);break;default:throw new TypeError("Unknown value type "+g)}if(E)return u={path:r,value:t,parent:n,parentProperty:i},this._handleCallback(u,o,"value"),u}else if("`"===h[0]&&t&&Object.hasOwn(t,h.slice(1))){var x=h.slice(1);y(this._trace(l,t[x],w(r,x),t,x,o,a,!0))}else if(h.includes(",")){var F,D=function(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=d(e))||t){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}(h.split(","));try{for(D.s();!(F=D.n()).done;){var _=F.value;y(this._trace(A(_,l),t,r,n,i,o,!0))}}catch(e){D.e(e)}finally{D.f()}}else!s&&t&&Object.hasOwn(t,h)&&y(this._trace(l,t[h],w(r,h),t,h,o,a,!0))}if(this._hasParentSelector)for(var O=0;O<p.length;O++){var m=p[O];if(m&&m.isParentSelector){var C=this._trace(m.expr,t,m.path,n,i,o,a);if(Array.isArray(C)){p[O]=C[0];for(var k=C.length,P=1;P<k;P++)O++,p.splice(O,0,C[P])}else p[O]=C}}return p},P.prototype._walk=function(e,t){if(Array.isArray(e))for(var r=e.length,n=0;n<r;n++)t(n);else e&&"object"===f(e)&&Object.keys(e).forEach((function(e){t(e)}))},P.prototype._slice=function(e,t,r,n,i,o,a){if(Array.isArray(r)){var s=r.length,u=e.split(":"),c=u[2]&&Number.parseInt(u[2])||1,h=u[0]&&Number.parseInt(u[0])||0,l=u[1]&&Number.parseInt(u[1])||s;h=h<0?Math.max(0,h+s):Math.min(s,h),l=l<0?Math.max(0,l+s):Math.min(s,l);for(var p=[],f=h;f<l;f+=c){this._trace(A(f,t),r,n,i,o,a,!0).forEach((function(e){p.push(e)}))}return p}},P.prototype._eval=function(e,t,r,n,i,o){var a=this;this.currSandbox._$_parentProperty=o,this.currSandbox._$_parent=i,this.currSandbox._$_property=r,this.currSandbox._$_root=this.json,this.currSandbox._$_v=t;var s=e.includes("@path");s&&(this.currSandbox._$_path=P.toPathString(n.concat([r])));var u=this.currEval+"Script:"+e;if(!P.cache[u]){var c=e.replace(/@parentProperty/g,"_$_parentProperty").replace(/@parent/g,"_$_parent").replace(/@property/g,"_$_property").replace(/@root/g,"_$_root").replace(/@([\t-\r \)\.\[\xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF])/g,"_$_v$1");if(s&&(c=c.replace(/@path/g,"_$_path")),"safe"===this.currEval||!0===this.currEval||void 0===this.currEval)P.cache[u]=new this.safeVm.Script(c);else if("native"===this.currEval)P.cache[u]=new this.vm.Script(c);else if("function"==typeof this.currEval&&this.currEval.prototype&&Object.hasOwn(this.currEval.prototype,"runInNewContext")){var h=this.currEval;P.cache[u]=new h(c)}else{if("function"!=typeof this.currEval)throw new TypeError('Unknown "eval" property "'.concat(this.currEval,'"'));P.cache[u]={runInNewContext:function(e){return a.currEval(c,e)}}}}try{return P.cache[u].runInNewContext(this.currSandbox)}catch(t){if(this.ignoreEvalErrors)return!1;throw new Error("jsonPath: "+t.message+": "+e)}},P.cache={},P.toPathString=function(e){for(var t=e,r=t.length,n="$",i=1;i<r;i++)/^(~|\^|@(?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*?\(\))$/.test(t[i])||(n+=/^[\*0-9]+$/.test(t[i])?"["+t[i]+"]":"['"+t[i]+"']");return n},P.toPointer=function(e){for(var t=e,r=t.length,n="",i=1;i<r;i++)/^(~|\^|@(?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*?\(\))$/.test(t[i])||(n+="/"+t[i].toString().replace(/~/g,"~0").replace(/\//g,"~1"));return n},P.toPathArray=function(e){var t=P.cache;if(t[e])return t[e].concat();var r=[],n=e.replace(/@(?:null|boolean|number|string|integer|undefined|nonFinite|scalar|array|object|function|other)\(\)/g,";$&;").replace(/['\[](\??\((?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*?\))['\]](?!(?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])\])/g,(function(e,t){return"[#"+(r.push(t)-1)+"]"})).replace(/\[["']((?:[\0-&\(-\\\^-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*)["']\]/g,(function(e,t){return"['"+t.replace(/\./g,"%@%").replace(/~/g,"%%@@%%")+"']"})).replace(/~/g,";~;").replace(/["']?\.["']?(?!(?:[\0-Z\\-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*\])|\[["']?/g,";").replace(/%@%/g,".").replace(/%%@@%%/g,"~").replace(/(?:;)?(\^+)(?:;)?/g,(function(e,t){return";"+t.split("").join(";")+";"})).replace(/;;;|;;/g,";..;").r ... [truncated]
dist/index-browser-esm.min.js.map+1 −1 modifieddist/index-browser-umd.cjs+242 −246 modified@@ -1526,12 +1526,222 @@ } }; - /* eslint-disable camelcase, unicorn/prefer-string-replace-all, - unicorn/prefer-at */ - var hasOwnProp = Object.prototype.hasOwnProperty; + // register plugins + jsep.plugins.register(index, plugin); + var SafeEval = { + /** + * @param {jsep.Expression} ast + * @param {Record<string, any>} subs + */ + evalAst: function evalAst(ast, subs) { + switch (ast.type) { + case 'BinaryExpression': + case 'LogicalExpression': + return SafeEval.evalBinaryExpression(ast, subs); + case 'Compound': + return SafeEval.evalCompound(ast, subs); + case 'ConditionalExpression': + return SafeEval.evalConditionalExpression(ast, subs); + case 'Identifier': + return SafeEval.evalIdentifier(ast, subs); + case 'Literal': + return SafeEval.evalLiteral(ast, subs); + case 'MemberExpression': + return SafeEval.evalMemberExpression(ast, subs); + case 'UnaryExpression': + return SafeEval.evalUnaryExpression(ast, subs); + case 'ArrayExpression': + return SafeEval.evalArrayExpression(ast, subs); + case 'CallExpression': + return SafeEval.evalCallExpression(ast, subs); + case 'AssignmentExpression': + return SafeEval.evalAssignmentExpression(ast, subs); + default: + throw SyntaxError('Unexpected expression', ast); + } + }, + evalBinaryExpression: function evalBinaryExpression(ast, subs) { + var result = { + '||': function _(a, b) { + return a || b(); + }, + '&&': function _(a, b) { + return a && b(); + }, + '|': function _(a, b) { + return a | b(); + }, + '^': function _(a, b) { + return a ^ b(); + }, + '&': function _(a, b) { + return a & b(); + }, + // eslint-disable-next-line eqeqeq + '==': function _(a, b) { + return a == b(); + }, + // eslint-disable-next-line eqeqeq + '!=': function _(a, b) { + return a != b(); + }, + '===': function _(a, b) { + return a === b(); + }, + '!==': function _(a, b) { + return a !== b(); + }, + '<': function _(a, b) { + return a < b(); + }, + '>': function _(a, b) { + return a > b(); + }, + '<=': function _(a, b) { + return a <= b(); + }, + '>=': function _(a, b) { + return a >= b(); + }, + '<<': function _(a, b) { + return a << b(); + }, + '>>': function _(a, b) { + return a >> b(); + }, + '>>>': function _(a, b) { + return a >>> b(); + }, + '+': function _(a, b) { + return a + b(); + }, + '-': function _(a, b) { + return a - b(); + }, + '*': function _(a, b) { + return a * b(); + }, + '/': function _(a, b) { + return a / b(); + }, + '%': function _(a, b) { + return a % b(); + } + }[ast.operator](SafeEval.evalAst(ast.left, subs), function () { + return SafeEval.evalAst(ast.right, subs); + }); + return result; + }, + evalCompound: function evalCompound(ast, subs) { + var last; + for (var i = 0; i < ast.body.length; i++) { + if (ast.body[i].type === 'Identifier' && ['var', 'let', 'const'].includes(ast.body[i].name) && ast.body[i + 1] && ast.body[i + 1].type === 'AssignmentExpression') { + // var x=2; is detected as + // [{Identifier var}, {AssignmentExpression x=2}] + // eslint-disable-next-line @stylistic/max-len -- Long + // eslint-disable-next-line sonarjs/updated-loop-counter -- Convenient + i += 1; + } + var expr = ast.body[i]; + last = SafeEval.evalAst(expr, subs); + } + return last; + }, + evalConditionalExpression: function evalConditionalExpression(ast, subs) { + if (SafeEval.evalAst(ast.test, subs)) { + return SafeEval.evalAst(ast.consequent, subs); + } + return SafeEval.evalAst(ast.alternate, subs); + }, + evalIdentifier: function evalIdentifier(ast, subs) { + if (ast.name in subs) { + return subs[ast.name]; + } + throw ReferenceError("".concat(ast.name, " is not defined")); + }, + evalLiteral: function evalLiteral(ast) { + return ast.value; + }, + evalMemberExpression: function evalMemberExpression(ast, subs) { + var prop = ast.computed ? SafeEval.evalAst(ast.property) // `object[property]` + : ast.property.name; // `object.property` property is Identifier + var obj = SafeEval.evalAst(ast.object, subs); + var result = obj[prop]; + if (typeof result === 'function') { + return result.bind(obj); // arrow functions aren't affected by bind. + } + return result; + }, + evalUnaryExpression: function evalUnaryExpression(ast, subs) { + var result = { + '-': function _(a) { + return -SafeEval.evalAst(a, subs); + }, + '!': function _(a) { + return !SafeEval.evalAst(a, subs); + }, + '~': function _(a) { + return ~SafeEval.evalAst(a, subs); + }, + // eslint-disable-next-line no-implicit-coercion + '+': function _(a) { + return +SafeEval.evalAst(a, subs); + } + }[ast.operator](ast.argument); + return result; + }, + evalArrayExpression: function evalArrayExpression(ast, subs) { + return ast.elements.map(function (el) { + return SafeEval.evalAst(el, subs); + }); + }, + evalCallExpression: function evalCallExpression(ast, subs) { + var args = ast.arguments.map(function (arg) { + return SafeEval.evalAst(arg, subs); + }); + var func = SafeEval.evalAst(ast.callee, subs); + return func.apply(void 0, _toConsumableArray(args)); + }, + evalAssignmentExpression: function evalAssignmentExpression(ast, subs) { + if (ast.left.type !== 'Identifier') { + throw SyntaxError('Invalid left-hand side in assignment'); + } + var id = ast.left.name; + var value = SafeEval.evalAst(ast.right, subs); + subs[id] = value; + return subs[id]; + } + }; /** - * @typedef {null|boolean|number|string|PlainObject|GenericArray} JSONObject + * A replacement for NodeJS' VM.Script which is also {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP | Content Security Policy} friendly. + */ + var SafeScript = /*#__PURE__*/function () { + /** + * @param {string} expr Expression to evaluate + */ + function SafeScript(expr) { + _classCallCheck(this, SafeScript); + this.code = expr; + this.ast = jsep(this.code); + } + + /** + * @param {object} context Object whose items will be added + * to evaluation + * @returns {EvaluatedResult} Result of evaluated code + */ + return _createClass(SafeScript, [{ + key: "runInNewContext", + value: function runInNewContext(context) { + var keyMap = _objectSpread2({}, context); + return SafeEval.evalAst(this.ast, keyMap); + } + }]); + }(); + + /** + * @typedef {null|boolean|number|string|object|GenericArray} JSONObject */ /** @@ -1586,15 +1796,15 @@ return _createClass(NewError); }(/*#__PURE__*/_wrapNativeSuper(Error)); /** - * @typedef {PlainObject} ReturnObject + * @typedef {object} ReturnObject * @property {string} path * @property {JSONObject} value - * @property {PlainObject|GenericArray} parent + * @property {object|GenericArray} parent * @property {string} parentProperty */ /** * @callback JSONPathCallback - * @param {string|PlainObject} preferredOutput + * @param {string|object} preferredOutput * @param {"value"|"property"} type * @param {ReturnObject} fullRetObj * @returns {void} @@ -1603,7 +1813,7 @@ * @callback OtherTypeCallback * @param {JSONObject} val * @param {string} path - * @param {PlainObject|GenericArray} parent + * @param {object|GenericArray} parent * @param {string} parentPropName * @returns {boolean} */ @@ -1620,20 +1830,20 @@ * @returns {EvaluatedResult} */ /** - * @typedef {typeof import('./jsonpath-browser').SafeScript} EvalClass + * @typedef {typeof SafeScript} EvalClass */ /** - * @typedef {PlainObject} JSONPathOptions + * @typedef {object} JSONPathOptions * @property {JSON} json * @property {string|string[]} path * @property {"value"|"path"|"pointer"|"parent"|"parentProperty"| * "all"} [resultType="value"] * @property {boolean} [flatten=false] * @property {boolean} [wrap=true] - * @property {PlainObject} [sandbox={}] + * @property {object} [sandbox={}] * @property {EvalCallback|EvalClass|'safe'|'native'| * boolean} [eval = 'safe'] - * @property {PlainObject|GenericArray|null} [parent=null] + * @property {object|GenericArray|null} [parent=null] * @property {string|null} [parentProperty=null] * @property {JSONPathCallback} [callback] * @property {OtherTypeCallback} [otherTypeCallback] Defaults to @@ -1680,7 +1890,7 @@ this.path = opts.path || expr; this.resultType = opts.resultType || 'value'; this.flatten = opts.flatten || false; - this.wrap = hasOwnProp.call(opts, 'wrap') ? opts.wrap : true; + this.wrap = Object.hasOwn(opts, 'wrap') ? opts.wrap : true; this.sandbox = opts.sandbox || {}; this.eval = opts.eval === undefined ? 'safe' : opts.eval; this.ignoreEvalErrors = typeof opts.ignoreEvalErrors === 'undefined' ? false : opts.ignoreEvalErrors; @@ -1725,20 +1935,20 @@ if (!expr.path && expr.path !== '') { throw new TypeError('You must supply a "path" property when providing an object ' + 'argument to JSONPath.evaluate().'); } - if (!hasOwnProp.call(expr, 'json')) { + if (!Object.hasOwn(expr, 'json')) { throw new TypeError('You must supply a "json" property when providing an object ' + 'argument to JSONPath.evaluate().'); } var _expr = expr; json = _expr.json; - flatten = hasOwnProp.call(expr, 'flatten') ? expr.flatten : flatten; - this.currResultType = hasOwnProp.call(expr, 'resultType') ? expr.resultType : this.currResultType; - this.currSandbox = hasOwnProp.call(expr, 'sandbox') ? expr.sandbox : this.currSandbox; - wrap = hasOwnProp.call(expr, 'wrap') ? expr.wrap : wrap; - this.currEval = hasOwnProp.call(expr, 'eval') ? expr.eval : this.currEval; - callback = hasOwnProp.call(expr, 'callback') ? expr.callback : callback; - this.currOtherTypeCallback = hasOwnProp.call(expr, 'otherTypeCallback') ? expr.otherTypeCallback : this.currOtherTypeCallback; - currParent = hasOwnProp.call(expr, 'parent') ? expr.parent : currParent; - currParentProperty = hasOwnProp.call(expr, 'parentProperty') ? expr.parentProperty : currParentProperty; + flatten = Object.hasOwn(expr, 'flatten') ? expr.flatten : flatten; + this.currResultType = Object.hasOwn(expr, 'resultType') ? expr.resultType : this.currResultType; + this.currSandbox = Object.hasOwn(expr, 'sandbox') ? expr.sandbox : this.currSandbox; + wrap = Object.hasOwn(expr, 'wrap') ? expr.wrap : wrap; + this.currEval = Object.hasOwn(expr, 'eval') ? expr.eval : this.currEval; + callback = Object.hasOwn(expr, 'callback') ? expr.callback : callback; + this.currOtherTypeCallback = Object.hasOwn(expr, 'otherTypeCallback') ? expr.otherTypeCallback : this.currOtherTypeCallback; + currParent = Object.hasOwn(expr, 'parent') ? expr.parent : currParent; + currParentProperty = Object.hasOwn(expr, 'parentProperty') ? expr.parentProperty : currParentProperty; expr = expr.path; } currParent = currParent || null; @@ -1812,7 +2022,7 @@ * @param {string} expr * @param {JSONObject} val * @param {string} path - * @param {PlainObject|GenericArray} parent + * @param {object|GenericArray} parent * @param {string} parentPropName * @param {JSONPathCallback} callback * @param {boolean} hasArrExpr @@ -1858,7 +2068,7 @@ ret.push(elems); } } - if ((typeof loc !== 'string' || literalPriority) && val && hasOwnProp.call(val, loc)) { + if ((typeof loc !== 'string' || literalPriority) && val && Object.hasOwn(val, loc)) { // simple case--directly follow property addRet(this._trace(x, val[loc], push(path, loc), val, loc, callback, hasArrExpr)); // eslint-disable-next-line unicorn/prefer-switch -- Part of larger `if` @@ -2007,7 +2217,7 @@ return retObj; } // `-escaped property - } else if (loc[0] === '`' && val && hasOwnProp.call(val, loc.slice(1))) { + } else if (loc[0] === '`' && val && Object.hasOwn(val, loc.slice(1))) { var locProp = loc.slice(1); addRet(this._trace(x, val[locProp], push(path, locProp), val, locProp, callback, hasArrExpr, true)); } else if (loc.includes(',')) { @@ -2026,7 +2236,7 @@ } finally { _iterator.f(); } - } else if (!literalPriority && val && hasOwnProp.call(val, loc)) { + } else if (!literalPriority && val && Object.hasOwn(val, loc)) { addRet(this._trace(x, val[loc], push(path, loc), val, loc, callback, hasArrExpr, true)); } @@ -2113,7 +2323,7 @@ JSONPath.cache[scriptCacheKey] = new this.safeVm.Script(script); } else if (this.currEval === 'native') { JSONPath.cache[scriptCacheKey] = new this.vm.Script(script); - } else if (typeof this.currEval === 'function' && this.currEval.prototype && hasOwnProp.call(this.currEval.prototype, 'runInNewContext')) { + } else if (typeof this.currEval === 'function' && this.currEval.prototype && Object.hasOwn(this.currEval.prototype, 'runInNewContext')) { var CurrEval = this.currEval; JSONPath.cache[scriptCacheKey] = new CurrEval(script); } else if (typeof this.currEval === 'function') { @@ -2218,6 +2428,9 @@ cache[expr] = exprList; return cache[expr].concat(); }; + JSONPath.prototype.safeVm = { + Script: SafeScript + }; /** * @typedef {any} ContextItem @@ -2253,219 +2466,6 @@ } }; - // register plugins - jsep.plugins.register(index, plugin); - var SafeEval = { - /** - * @param {jsep.Expression} ast - * @param {Record<string, any>} subs - */ - evalAst: function evalAst(ast, subs) { - switch (ast.type) { - case 'BinaryExpression': - case 'LogicalExpression': - return SafeEval.evalBinaryExpression(ast, subs); - case 'Compound': - return SafeEval.evalCompound(ast, subs); - case 'ConditionalExpression': - return SafeEval.evalConditionalExpression(ast, subs); - case 'Identifier': - return SafeEval.evalIdentifier(ast, subs); - case 'Literal': - return SafeEval.evalLiteral(ast, subs); - case 'MemberExpression': - return SafeEval.evalMemberExpression(ast, subs); - case 'UnaryExpression': - return SafeEval.evalUnaryExpression(ast, subs); - case 'ArrayExpression': - return SafeEval.evalArrayExpression(ast, subs); - case 'CallExpression': - return SafeEval.evalCallExpression(ast, subs); - case 'AssignmentExpression': - return SafeEval.evalAssignmentExpression(ast, subs); - default: - throw SyntaxError('Unexpected expression', ast); - } - }, - evalBinaryExpression: function evalBinaryExpression(ast, subs) { - var result = { - '||': function _(a, b) { - return a || b(); - }, - '&&': function _(a, b) { - return a && b(); - }, - '|': function _(a, b) { - return a | b(); - }, - '^': function _(a, b) { - return a ^ b(); - }, - '&': function _(a, b) { - return a & b(); - }, - // eslint-disable-next-line eqeqeq - '==': function _(a, b) { - return a == b(); - }, - // eslint-disable-next-line eqeqeq - '!=': function _(a, b) { - return a != b(); - }, - '===': function _(a, b) { - return a === b(); - }, - '!==': function _(a, b) { - return a !== b(); - }, - '<': function _(a, b) { - return a < b(); - }, - '>': function _(a, b) { - return a > b(); - }, - '<=': function _(a, b) { - return a <= b(); - }, - '>=': function _(a, b) { - return a >= b(); - }, - '<<': function _(a, b) { - return a << b(); - }, - '>>': function _(a, b) { - return a >> b(); - }, - '>>>': function _(a, b) { - return a >>> b(); - }, - '+': function _(a, b) { - return a + b(); - }, - '-': function _(a, b) { - return a - b(); - }, - '*': function _(a, b) { - return a * b(); - }, - '/': function _(a, b) { - return a / b(); - }, - '%': function _(a, b) { - return a % b(); - } - }[ast.operator](SafeEval.evalAst(ast.left, subs), function () { - return SafeEval.evalAst(ast.right, subs); - }); - return result; - }, - evalCompound: function evalCompound(ast, subs) { - var last; - for (var i = 0; i < ast.body.length; i++) { - if (ast.body[i].type === 'Identifier' && ['var', 'let', 'const'].includes(ast.body[i].name) && ast.body[i + 1] && ast.body[i + 1].type === 'AssignmentExpression') { - // var x=2; is detected as - // [{Identifier var}, {AssignmentExpression x=2}] - // eslint-disable-next-line @stylistic/max-len -- Long - // eslint-disable-next-line sonarjs/updated-loop-counter -- Convenient - i += 1; - } - var expr = ast.body[i]; - last = SafeEval.evalAst(expr, subs); - } - return last; - }, - evalConditionalExpression: function evalConditionalExpression(ast, subs) { - if (SafeEval.evalAst(ast.test, subs)) { - return SafeEval.evalAst(ast.consequent, subs); - } - return SafeEval.evalAst(ast.alternate, subs); - }, - evalIdentifier: function evalIdentifier(ast, subs) { - if (ast.name in subs) { - return subs[ast.name]; - } - throw ReferenceError("".concat(ast.name, " is not defined")); - }, - evalLiteral: function evalLiteral(ast) { - return ast.value; - }, - evalMemberExpression: function evalMemberExpression(ast, subs) { - var prop = ast.computed ? SafeEval.evalAst(ast.property) // `object[property]` - : ast.property.name; // `object.property` property is Identifier - var obj = SafeEval.evalAst(ast.object, subs); - var result = obj[prop]; - if (typeof result === 'function') { - return result.bind(obj); // arrow functions aren't affected by bind. - } - return result; - }, - evalUnaryExpression: function evalUnaryExpression(ast, subs) { - var result = { - '-': function _(a) { - return -SafeEval.evalAst(a, subs); - }, - '!': function _(a) { - return !SafeEval.evalAst(a, subs); - }, - '~': function _(a) { - return ~SafeEval.evalAst(a, subs); - }, - // eslint-disable-next-line no-implicit-coercion - '+': function _(a) { - return +SafeEval.evalAst(a, subs); - } - }[ast.operator](ast.argument); - return result; - }, - evalArrayExpression: function evalArrayExpression(ast, subs) { - return ast.elements.map(function (el) { - return SafeEval.evalAst(el, subs); - }); - }, - evalCallExpression: function evalCallExpression(ast, subs) { - var args = ast.arguments.map(function (arg) { - return SafeEval.evalAst(arg, subs); - }); - var func = SafeEval.evalAst(ast.callee, subs); - return func.apply(void 0, _toConsumableArray(args)); - }, - evalAssignmentExpression: function evalAssignmentExpression(ast, subs) { - if (ast.left.type !== 'Identifier') { - throw SyntaxError('Invalid left-hand side in assignment'); - } - var id = ast.left.name; - var value = SafeEval.evalAst(ast.right, subs); - subs[id] = value; - return subs[id]; - } - }; - - /** - * A replacement for NodeJS' VM.Script which is also {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP | Content Security Policy} friendly. - */ - var SafeScript = /*#__PURE__*/function () { - /** - * @param {string} expr Expression to evaluate - */ - function SafeScript(expr) { - _classCallCheck(this, SafeScript); - this.code = expr; - this.ast = jsep(this.code); - } - - /** - * @param {PlainObject} context Object whose items will be added - * to evaluation - * @returns {EvaluatedResult} Result of evaluated code - */ - return _createClass(SafeScript, [{ - key: "runInNewContext", - value: function runInNewContext(context) { - var keyMap = _objectSpread2({}, context); - return SafeEval.evalAst(this.ast, keyMap); - } - }]); - }(); /** * In-browser replacement for NodeJS' VM.Script. */ @@ -2479,7 +2479,7 @@ } /** - * @param {PlainObject} context Object whose items will be added + * @param {object} context Object whose items will be added * to evaluation * @returns {EvaluatedResult} Result of evaluated code */ @@ -2526,11 +2526,7 @@ JSONPath.prototype.vm = { Script: Script }; - JSONPath.prototype.safeVm = { - Script: SafeScript - }; exports.JSONPath = JSONPath; - exports.SafeScript = SafeScript; }));
dist/index-browser-umd.min.cjs+1 −1 modified@@ -1,2 +1,2 @@ -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).JSONPath={})}(this,(function(e){"use strict";function t(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function r(e,t,r){return t=u(t),function(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,c()?Reflect.construct(t,r||[],u(e).constructor):t.apply(e,r))}function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t,r){if(c())return Reflect.construct.apply(null,arguments);var n=[null];n.push.apply(n,t);var i=new(e.bind.apply(e,n));return r&&h(i,r.prototype),i}function o(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,f(n.key),n)}}function a(e,t,r){return t&&o(e.prototype,t),r&&o(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function s(e,t,r){return(t=f(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function u(e){return u=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},u(e)}function c(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(c=function(){return!!e})()}function l(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function h(e,t){return h=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},h(e,t)}function p(e){return function(e){if(Array.isArray(e))return t(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||y(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function f(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t);if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e,"string");return"symbol"==typeof t?t:t+""}function d(e){return d="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},d(e)}function y(e,r){if(e){if("string"==typeof e)return t(e,r);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?t(e,r):void 0}}function b(e){var t="function"==typeof Map?new Map:void 0;return b=function(e){if(null===e||!function(e){try{return-1!==Function.toString.call(e).indexOf("[native code]")}catch(t){return"function"==typeof e}}(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return i(e,arguments,u(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),h(r,e)},b(e)}var v=function(){return a((function e(){n(this,e)}),[{key:"add",value:function(e,t,r){if("string"!=typeof arguments[0])for(var n in arguments[0])this.add(n,arguments[0][n],arguments[1]);else(Array.isArray(e)?e:[e]).forEach((function(e){this[e]=this[e]||[],t&&this[e][r?"unshift":"push"](t)}),this)}},{key:"run",value:function(e,t){this[e]=this[e]||[],this[e].forEach((function(e){e.call(t&&t.context?t.context:t,t)}))}}])}(),E=function(){return a((function e(t){n(this,e),this.jsep=t,this.registered={}}),[{key:"register",value:function(){for(var e=this,t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];r.forEach((function(t){if("object"!==d(t)||!t.name||!t.init)throw new Error("Invalid JSEP plugin format");e.registered[t.name]||(t.init(e.jsep),e.registered[t.name]=t)}))}}])}(),g=function(){function e(t){n(this,e),this.expr=t,this.index=0}return a(e,[{key:"char",get:function(){return this.expr.charAt(this.index)}},{key:"code",get:function(){return this.expr.charCodeAt(this.index)}},{key:"throwError",value:function(e){var t=new Error(e+" at character "+this.index);throw t.index=this.index,t.description=e,t}},{key:"runHook",value:function(t,r){if(e.hooks[t]){var n={context:this,node:r};return e.hooks.run(t,n),n.node}return r}},{key:"searchHook",value:function(t){if(e.hooks[t]){var r={context:this};return e.hooks[t].find((function(e){return e.call(r.context,r),r.node})),r.node}}},{key:"gobbleSpaces",value:function(){for(var t=this.code;t===e.SPACE_CODE||t===e.TAB_CODE||t===e.LF_CODE||t===e.CR_CODE;)t=this.expr.charCodeAt(++this.index);this.runHook("gobble-spaces")}},{key:"parse",value:function(){this.runHook("before-all");var t=this.gobbleExpressions(),r=1===t.length?t[0]:{type:e.COMPOUND,body:t};return this.runHook("after-all",r)}},{key:"gobbleExpressions",value:function(t){for(var r,n,i=[];this.index<this.expr.length;)if((r=this.code)===e.SEMCOL_CODE||r===e.COMMA_CODE)this.index++;else if(n=this.gobbleExpression())i.push(n);else if(this.index<this.expr.length){if(r===t)break;this.throwError('Unexpected "'+this.char+'"')}return i}},{key:"gobbleExpression",value:function(){var e=this.searchHook("gobble-expression")||this.gobbleBinaryExpression();return this.gobbleSpaces(),this.runHook("after-expression",e)}},{key:"gobbleBinaryOp",value:function(){this.gobbleSpaces();for(var t=this.expr.substr(this.index,e.max_binop_len),r=t.length;r>0;){if(e.binary_ops.hasOwnProperty(t)&&(!e.isIdentifierStart(this.code)||this.index+t.length<this.expr.length&&!e.isIdentifierPart(this.expr.charCodeAt(this.index+t.length))))return this.index+=r,t;t=t.substr(0,--r)}return!1}},{key:"gobbleBinaryExpression",value:function(){var t,r,n,i,o,a,s,u,c,l;if(!(a=this.gobbleToken()))return a;if(!(r=this.gobbleBinaryOp()))return a;for(o={value:r,prec:e.binaryPrecedence(r),right_a:e.right_associative.has(r)},(s=this.gobbleToken())||this.throwError("Expected expression after "+r),i=[a,o,s];r=this.gobbleBinaryOp();){if(0===(n=e.binaryPrecedence(r))){this.index-=r.length;break}o={value:r,prec:n,right_a:e.right_associative.has(r)},c=r;for(;i.length>2&&(l=i[i.length-2],o.right_a&&l.right_a?n>l.prec:n<=l.prec);)s=i.pop(),r=i.pop().value,a=i.pop(),t={type:e.BINARY_EXP,operator:r,left:a,right:s},i.push(t);(t=this.gobbleToken())||this.throwError("Expected expression after "+c),i.push(o,t)}for(t=i[u=i.length-1];u>1;)t={type:e.BINARY_EXP,operator:i[u-1].value,left:i[u-2],right:t},u-=2;return t}},{key:"gobbleToken",value:function(){var t,r,n,i;if(this.gobbleSpaces(),i=this.searchHook("gobble-token"))return this.runHook("after-token",i);if(t=this.code,e.isDecimalDigit(t)||t===e.PERIOD_CODE)return this.gobbleNumericLiteral();if(t===e.SQUOTE_CODE||t===e.DQUOTE_CODE)i=this.gobbleStringLiteral();else if(t===e.OBRACK_CODE)i=this.gobbleArray();else{for(n=(r=this.expr.substr(this.index,e.max_unop_len)).length;n>0;){if(e.unary_ops.hasOwnProperty(r)&&(!e.isIdentifierStart(this.code)||this.index+r.length<this.expr.length&&!e.isIdentifierPart(this.expr.charCodeAt(this.index+r.length)))){this.index+=n;var o=this.gobbleToken();return o||this.throwError("missing unaryOp argument"),this.runHook("after-token",{type:e.UNARY_EXP,operator:r,argument:o,prefix:!0})}r=r.substr(0,--n)}e.isIdentifierStart(t)?(i=this.gobbleIdentifier(),e.literals.hasOwnProperty(i.name)?i={type:e.LITERAL,value:e.literals[i.name],raw:i.name}:i.name===e.this_str&&(i={type:e.THIS_EXP})):t===e.OPAREN_CODE&&(i=this.gobbleGroup())}return i?(i=this.gobbleTokenProperty(i),this.runHook("after-token",i)):this.runHook("after-token",!1)}},{key:"gobbleTokenProperty",value:function(t){this.gobbleSpaces();for(var r=this.code;r===e.PERIOD_CODE||r===e.OBRACK_CODE||r===e.OPAREN_CODE||r===e.QUMARK_CODE;){var n=void 0;if(r===e.QUMARK_CODE){if(this.expr.charCodeAt(this.index+1)!==e.PERIOD_CODE)break;n=!0,this.index+=2,this.gobbleSpaces(),r=this.code}this.index++,r===e.OBRACK_CODE?((t={type:e.MEMBER_EXP,computed:!0,object:t,property:this.gobbleExpression()}).property||this.throwError('Unexpected "'+this.char+'"'),this.gobbleSpaces(),(r=this.code)!==e.CBRACK_CODE&&this.throwError("Unclosed ["),this.index++):r===e.OPAREN_CODE?t={type:e.CALL_EXP,arguments:this.gobbleArguments(e.CPAREN_CODE),callee:t}:(r===e.PERIOD_CODE||n)&&(n&&this.index--,this.gobbleSpaces(),t={type:e.MEMBER_EXP,computed:!1,object:t,property:this.gobbleIdentifier()}),n&&(t.optional=!0),this.gobbleSpaces(),r=this.code}return t}},{key:"gobbleNumericLiteral",value:function(){for(var t,r,n="";e.isDecimalDigit(this.code);)n+=this.expr.charAt(this.index++);if(this.code===e.PERIOD_CODE)for(n+=this.expr.charAt(this.index++);e.isDecimalDigit(this.code);)n+=this.expr.charAt(this.index++);if("e"===(t=this.char)||"E"===t){for(n+=this.expr.charAt(this.index++),"+"!==(t=this.char)&&"-"!==t||(n+=this.expr.charAt(this.index++));e.isDecimalDigit(this.code);)n+=this.expr.charAt(this.index++);e.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+n+this.char+")")}return r=this.code,e.isIdentifierStart(r)?this.throwError("Variable names cannot start with a number ("+n+this.char+")"):(r===e.PERIOD_CODE||1===n.length&&n.charCodeAt(0)===e.PERIOD_CODE)&&this.throwError("Unexpected period"),{type:e.LITERAL,value:parseFloat(n),raw:n}}},{key:"gobbleStringLiteral",value:function(){for(var t="",r=this.index,n=this.expr.charAt(this.index++),i=!1;this.index<this.expr.length;){var o=this.expr.charAt(this.index++);if(o===n){i=!0;break}if("\\"===o)switch(o=this.expr.charAt(this.index++)){case"n":t+="\n";break;case"r":t+="\r";break;case"t":t+="\t";break;case"b":t+="\b";break;case"f":t+="\f";break;case"v":t+="\v";break;default:t+=o}else t+=o}return i||this.throwError('Unclosed quote after "'+t+'"'),{type:e.LITERAL,value:t,raw:this.expr.substring(r,this.index)}}},{key:"gobbleIdentifier",value:function(){var t=this.code,r=this.index;for(e.isIdentifierStart(t)?this.index++:this.throwError("Unexpected "+this.char);this.index<this.expr.length&&(t=this.code,e.isIdentifierPart(t));)this.index++;return{type:e.IDENTIFIER,name:this.expr.slice(r,this.index)}}},{key:"gobbleArguments",value:function(t){for(var r=[],n=!1,i=0;this.index<this.expr.length;){this.gobbleSpaces();var o=this.code;if(o===t){n=!0,this.index++,t===e.CPAREN_CODE&&i&&i>=r.length&&this.throwError("Unexpected token "+String.fromCharCode(t));break}if(o===e.COMMA_CODE){if(this.index++,++i!==r.length)if(t===e.CPAREN_CODE)this.throwError("Unexpected token ,");else if(t===e.CBRACK_CODE)for(var a=r.length;a<i;a++)r.push(null)}else if(r.length!==i&&0!==i)this.throwError("Expected comma");else{var s=this.gobbleExpression();s&&s.type!==e.COMPOUND||this.throwError("Expected comma"),r.push(s)}}return n||this.throwError("Expected "+String.fromCharCode(t)),r}},{key:"gobbleGroup",value:function(){this.index++;var t=this.gobbleExpressions(e.CPAREN_CODE);if(this.code===e.CPAREN_CODE)return this.index++,1===t.length?t[0]:!!t.length&&{type:e.SEQUENCE_EXP,expressions:t};this.throwError("Unclosed (")}},{key:"gobbleArray",value:function(){return this.index++,{type:e.ARRAY_EXP,elements:this.gobbleArguments(e.CBRACK_CODE)}}}],[{key:"version",get:function(){return"1.3.9"}},{key:"toString",value:function(){return"JavaScript Expression Parser (JSEP) v"+e.version}},{key:"addUnaryOp",value:function(t){return e.max_unop_len=Math.max(t.length,e.max_unop_len),e.unary_ops[t]=1,e}},{key:"addBinaryOp",value:function(t,r,n){return e.max_binop_len=Math.max(t.length,e.max_binop_len),e.binary_ops[t]=r,n?e.right_associative.add(t):e.right_associative.delete(t),e}},{key:"addIdentifierChar",value:function(t){return e.additional_identifier_chars.add(t),e}},{key:"addLiteral",value:function(t,r){return e.literals[t]=r,e}},{key:"removeUnaryOp",value:function(t){return delete e.unary_ops[t],t.length===e.max_unop_len&&(e.max_unop_len=e.getMaxKeyLen(e.unary_ops)),e}},{key:"removeAllUnaryOps",value:function(){return e.unary_ops={},e.max_unop_len=0,e}},{key:"removeIdentifierChar",value:function(t){return e.additional_identifier_chars.delete(t),e}},{key:"removeBinaryOp",value:function(t){return delete e.binary_ops[t],t.length===e.max_binop_len&&(e.max_binop_len=e.getMaxKeyLen(e.binary_ops)),e.right_associative.delete(t),e}},{key:"removeAllBinaryOps",value:function(){return e.binary_ops={},e.max_binop_len=0,e}},{key:"removeLiteral",value:function(t){return delete e.literals[t],e}},{key:"removeAllLiterals",value:function(){return e.literals={},e}},{key:"parse",value:function(t){return new e(t).parse()}},{key:"getMaxKeyLen",value:function(e){return Math.max.apply(Math,[0].concat(p(Object.keys(e).map((function(e){return e.length})))))}},{key:"isDecimalDigit",value:function(e){return e>=48&&e<=57}},{key:"binaryPrecedence",value:function(t){return e.binary_ops[t]||0}},{key:"isIdentifierStart",value:function(t){return t>=65&&t<=90||t>=97&&t<=122||t>=128&&!e.binary_ops[String.fromCharCode(t)]||e.additional_identifier_chars.has(String.fromCharCode(t))}},{key:"isIdentifierPart",value:function(t){return e.isIdentifierStart(t)||e.isDecimalDigit(t)}}])}(),x=new v;Object.assign(g,{hooks:x,plugins:new E(g),COMPOUND:"Compound",SEQUENCE_EXP:"SequenceExpression",IDENTIFIER:"Identifier",MEMBER_EXP:"MemberExpression",LITERAL:"Literal",THIS_EXP:"ThisExpression",CALL_EXP:"CallExpression",UNARY_EXP:"UnaryExpression",BINARY_EXP:"BinaryExpression",ARRAY_EXP:"ArrayExpression",TAB_CODE:9,LF_CODE:10,CR_CODE:13,SPACE_CODE:32,PERIOD_CODE:46,COMMA_CODE:44,SQUOTE_CODE:39,DQUOTE_CODE:34,OPAREN_CODE:40,CPAREN_CODE:41,OBRACK_CODE:91,CBRACK_CODE:93,QUMARK_CODE:63,SEMCOL_CODE:59,COLON_CODE:58,unary_ops:{"-":1,"!":1,"~":1,"+":1},binary_ops:{"||":1,"&&":2,"|":3,"^":4,"&":5,"==":6,"!=":6,"===":6,"!==":6,"<":7,">":7,"<=":7,">=":7,"<<":8,">>":8,">>>":8,"+":9,"-":9,"*":10,"/":10,"%":10},right_associative:new Set,additional_identifier_chars:new Set(["$","_"]),literals:{true:!0,false:!1,null:null},this_str:"this"}),g.max_unop_len=g.getMaxKeyLen(g.unary_ops),g.max_binop_len=g.getMaxKeyLen(g.binary_ops);var F=function(e){return new g(e).parse()},D=Object.getOwnPropertyNames(a((function e(){n(this,e)})));Object.getOwnPropertyNames(g).filter((function(e){return!D.includes(e)&&void 0===F[e]})).forEach((function(e){F[e]=g[e]})),F.Jsep=g;var _={name:"ternary",init:function(e){e.hooks.add("after-expression",(function(t){if(t.node&&this.code===e.QUMARK_CODE){this.index++;var r=t.node,n=this.gobbleExpression();if(n||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===e.COLON_CODE){this.index++;var i=this.gobbleExpression();if(i||this.throwError("Expected expression"),t.node={type:"ConditionalExpression",test:r,consequent:n,alternate:i},r.operator&&e.binary_ops[r.operator]<=.9){for(var o=r;o.right.operator&&e.binary_ops[o.right.operator]<=.9;)o=o.right;t.node.test=o.right,o.right=t.node,t.node=r}}else this.throwError("Expected :")}}))}};F.plugins.register(_);var m={name:"regex",init:function(e){e.hooks.add("gobble-token",(function(t){if(47===this.code){for(var r=++this.index,n=!1;this.index<this.expr.length;){if(47===this.code&&!n){for(var i=this.expr.slice(r,this.index),o="";++this.index<this.expr.length;){var a=this.code;if(!(a>=97&&a<=122||a>=65&&a<=90||a>=48&&a<=57))break;o+=this.char}var s=void 0;try{s=new RegExp(i,o)}catch(e){this.throwError(e.message)}return t.node={type:e.LITERAL,value:s,raw:this.expr.slice(r-1,this.index)},t.node=this.gobbleTokenProperty(t.node),t.node}this.code===e.OBRACK_CODE?n=!0:n&&this.code===e.CBRACK_CODE&&(n=!1),this.index+=92===this.code?2:1}this.throwError("Unclosed Regex")}}))}},C={name:"assignment",assignmentOperators:new Set(["=","*=","**=","/=","%=","+=","-=","<<=",">>=",">>>=","&=","^=","|="]),updateOperators:[43,45],assignmentPrecedence:.9,init:function(e){var t=[e.IDENTIFIER,e.MEMBER_EXP];function r(e){C.assignmentOperators.has(e.operator)?(e.type="AssignmentExpression",r(e.left),r(e.right)):e.operator||Object.values(e).forEach((function(e){e&&"object"===d(e)&&r(e)}))}C.assignmentOperators.forEach((function(t){return e.addBinaryOp(t,C.assignmentPrecedence,!0)})),e.hooks.add("gobble-token",(function(e){var r=this,n=this.code;C.updateOperators.some((function(e){return e===n&&e===r.expr.charCodeAt(r.index+1)}))&&(this.index+=2,e.node={type:"UpdateExpression",operator:43===n?"++":"--",argument:this.gobbleTokenProperty(this.gobbleIdentifier()),prefix:!0},e.node.argument&&t.includes(e.node.argument.type)||this.throwError("Unexpected ".concat(e.node.operator)))})),e.hooks.add("after-token",(function(e){var r=this;if(e.node){var n=this.code;C.updateOperators.some((function(e){return e===n&&e===r.expr.charCodeAt(r.index+1)}))&&(t.includes(e.node.type)||this.throwError("Unexpected ".concat(e.node.operator)),this.index+=2,e.node={type:"UpdateExpression",operator:43===n?"++":"--",argument:e.node,prefix:!1})}})),e.hooks.add("after-expression",(function(e){e.node&&r(e.node)}))}},O=Object.prototype.hasOwnProperty;function A(e,t){return(e=e.slice()).push(t),e}function w(e,t){return(t=t.slice()).unshift(e),t}var k=function(e){function t(e){var i;return n(this,t),(i=r(this,t,['JSONPath should not be called with "new" (it prevents return of (unwrapped) scalar values)'])).avoidNew=!0,i.value=e,i.name="NewError",i}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&h(e,t)}(t,e),a(t)}(b(Error));function P(e,t,r,n,i){if(!(this instanceof P))try{return new P(e,t,r,n,i)}catch(e){if(!e.avoidNew)throw e;return e.value}"string"==typeof e&&(i=n,n=r,r=t,t=e,e=null);var o=e&&"object"===d(e);if(e=e||{},this.json=e.json||r,this.path=e.path||t,this.resultType=e.resultType||"value",this.flatten=e.flatten||!1,this.wrap=!O.call(e,"wrap")||e.wrap,this.sandbox=e.sandbox||{},this.eval=void 0===e.eval?"safe":e.eval,this.ignoreEvalErrors=void 0!==e.ignoreEvalErrors&&e.ignoreEvalErrors,this.parent=e.parent||null,this.parentProperty=e.parentProperty||null,this.callback=e.callback||n||null,this.otherTypeCallback=e.otherTypeCallback||i||function(){throw new TypeError("You must supply an otherTypeCallback callback option with the @other() operator.")},!1!==e.autostart){var a={path:o?e.path:t};o?"json"in e&&(a.json=e.json):a.json=r;var s=this.evaluate(a);if(!s||"object"!==d(s))throw new k(s);return s}}P.prototype.evaluate=function(e,t,r,n){var i=this,o=this.parent,a=this.parentProperty,s=this.flatten,u=this.wrap;if(this.currResultType=this.resultType,this.currEval=this.eval,this.currSandbox=this.sandbox,r=r||this.callback,this.currOtherTypeCallback=n||this.otherTypeCallback,t=t||this.json,(e=e||this.path)&&"object"===d(e)&&!Array.isArray(e)){if(!e.path&&""!==e.path)throw new TypeError('You must supply a "path" property when providing an object argument to JSONPath.evaluate().');if(!O.call(e,"json"))throw new TypeError('You must supply a "json" property when providing an object argument to JSONPath.evaluate().');t=e.json,s=O.call(e,"flatten")?e.flatten:s,this.currResultType=O.call(e,"resultType")?e.resultType:this.currResultType,this.currSandbox=O.call(e,"sandbox")?e.sandbox:this.currSandbox,u=O.call(e,"wrap")?e.wrap:u,this.currEval=O.call(e,"eval")?e.eval:this.currEval,r=O.call(e,"callback")?e.callback:r,this.currOtherTypeCallback=O.call(e,"otherTypeCallback")?e.otherTypeCallback:this.currOtherTypeCallback,o=O.call(e,"parent")?e.parent:o,a=O.call(e,"parentProperty")?e.parentProperty:a,e=e.path}if(o=o||null,a=a||null,Array.isArray(e)&&(e=P.toPathString(e)),(e||""===e)&&t){var c=P.toPathArray(e);"$"===c[0]&&c.length>1&&c.shift(),this._hasParentSelector=null;var l=this._trace(c,t,["$"],o,a,r).filter((function(e){return e&&!e.isParentSelector}));return l.length?u||1!==l.length||l[0].hasArrExpr?l.reduce((function(e,t){var r=i._getPreferredOutput(t);return s&&Array.isArray(r)?e=e.concat(r):e.push(r),e}),[]):this._getPreferredOutput(l[0]):u?[]:void 0}},P.prototype._getPreferredOutput=function(e){var t=this.currResultType;switch(t){case"all":var r=Array.isArray(e.path)?e.path:P.toPathArray(e.path);return e.pointer=P.toPointer(r),e.path="string"==typeof e.path?e.path:P.toPathString(e.path),e;case"value":case"parent":case"parentProperty":return e[t];case"path":return P.toPathString(e[t]);case"pointer":return P.toPointer(e.path);default:throw new TypeError("Unknown result type")}},P.prototype._handleCallback=function(e,t,r){if(t){var n=this._getPreferredOutput(e);e.path="string"==typeof e.path?e.path:P.toPathString(e.path),t(n,r,e)}},P.prototype._trace=function(e,t,r,n,i,o,a,s){var u,c=this;if(!e.length)return u={path:r,value:t,parent:n,parentProperty:i,hasArrExpr:a},this._handleCallback(u,o,"value"),u;var l=e[0],h=e.slice(1),p=[];function f(e){Array.isArray(e)?e.forEach((function(e){p.push(e)})):p.push(e)}if(("string"!=typeof l||s)&&t&&O.call(t,l))f(this._trace(h,t[l],A(r,l),t,l,o,a));else if("*"===l)this._walk(t,(function(e){f(c._trace(h,t[e],A(r,e),t,e,o,!0,!0))}));else if(".."===l)f(this._trace(h,t,r,n,i,o,a)),this._walk(t,(function(n){"object"===d(t[n])&&f(c._trace(e.slice(),t[n],A(r,n),t,n,o,!0))}));else{if("^"===l)return this._hasParentSelector=!0,{path:r.slice(0,-1),expr:h,isParentSelector:!0};if("~"===l)return u={path:A(r,l),value:i,parent:n,parentProperty:null},this._handleCallback(u,o,"property"),u;if("$"===l)f(this._trace(h,t,r,null,null,o,a));else if(/^(-?[0-9]*):(-?[0-9]*):?([0-9]*)$/.test(l))f(this._slice(l,h,t,r,n,i,o));else if(0===l.indexOf("?(")){if(!1===this.currEval)throw new Error("Eval [?(expr)] prevented in JSONPath expression.");var b=l.replace(/^\?\(((?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*?)\)$/,"$1"),v=/@(?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])?((?:[\0->@-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*)['\[](\??\((?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*?\))(?!(?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])\)\])['\]]/g.exec(b);v?this._walk(t,(function(e){var a=[v[2]],s=v[1]?t[e][v[1]]:t[e];c._trace(a,s,r,n,i,o,!0).length>0&&f(c._trace(h,t[e],A(r,e),t,e,o,!0))})):this._walk(t,(function(e){c._eval(b,t[e],e,r,n,i)&&f(c._trace(h,t[e],A(r,e),t,e,o,!0))}))}else if("("===l[0]){if(!1===this.currEval)throw new Error("Eval [(expr)] prevented in JSONPath expression.");f(this._trace(w(this._eval(l,t,r[r.length-1],r.slice(0,-1),n,i),h),t,r,n,i,o,a))}else if("@"===l[0]){var E=!1,g=l.slice(1,-2);switch(g){case"scalar":t&&["object","function"].includes(d(t))||(E=!0);break;case"boolean":case"string":case"undefined":case"function":d(t)===g&&(E=!0);break;case"integer":!Number.isFinite(t)||t%1||(E=!0);break;case"number":Number.isFinite(t)&&(E=!0);break;case"nonFinite":"number"!=typeof t||Number.isFinite(t)||(E=!0);break;case"object":t&&d(t)===g&&(E=!0);break;case"array":Array.isArray(t)&&(E=!0);break;case"other":E=this.currOtherTypeCallback(t,r,n,i);break;case"null":null===t&&(E=!0);break;default:throw new TypeError("Unknown value type "+g)}if(E)return u={path:r,value:t,parent:n,parentProperty:i},this._handleCallback(u,o,"value"),u}else if("`"===l[0]&&t&&O.call(t,l.slice(1))){var x=l.slice(1);f(this._trace(h,t[x],A(r,x),t,x,o,a,!0))}else if(l.includes(",")){var F,D=function(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=y(e))||t){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}(l.split(","));try{for(D.s();!(F=D.n()).done;){var _=F.value;f(this._trace(w(_,h),t,r,n,i,o,!0))}}catch(e){D.e(e)}finally{D.f()}}else!s&&t&&O.call(t,l)&&f(this._trace(h,t[l],A(r,l),t,l,o,a,!0))}if(this._hasParentSelector)for(var m=0;m<p.length;m++){var C=p[m];if(C&&C.isParentSelector){var k=this._trace(C.expr,t,C.path,n,i,o,a);if(Array.isArray(k)){p[m]=k[0];for(var P=k.length,S=1;S<P;S++)m++,p.splice(m,0,k[S])}else p[m]=k}}return p},P.prototype._walk=function(e,t){if(Array.isArray(e))for(var r=e.length,n=0;n<r;n++)t(n);else e&&"object"===d(e)&&Object.keys(e).forEach((function(e){t(e)}))},P.prototype._slice=function(e,t,r,n,i,o,a){if(Array.isArray(r)){var s=r.length,u=e.split(":"),c=u[2]&&Number.parseInt(u[2])||1,l=u[0]&&Number.parseInt(u[0])||0,h=u[1]&&Number.parseInt(u[1])||s;l=l<0?Math.max(0,l+s):Math.min(s,l),h=h<0?Math.max(0,h+s):Math.min(s,h);for(var p=[],f=l;f<h;f+=c){this._trace(w(f,t),r,n,i,o,a,!0).forEach((function(e){p.push(e)}))}return p}},P.prototype._eval=function(e,t,r,n,i,o){var a=this;this.currSandbox._$_parentProperty=o,this.currSandbox._$_parent=i,this.currSandbox._$_property=r,this.currSandbox._$_root=this.json,this.currSandbox._$_v=t;var s=e.includes("@path");s&&(this.currSandbox._$_path=P.toPathString(n.concat([r])));var u=this.currEval+"Script:"+e;if(!P.cache[u]){var c=e.replace(/@parentProperty/g,"_$_parentProperty").replace(/@parent/g,"_$_parent").replace(/@property/g,"_$_property").replace(/@root/g,"_$_root").replace(/@([\t-\r \)\.\[\xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF])/g,"_$_v$1");if(s&&(c=c.replace(/@path/g,"_$_path")),"safe"===this.currEval||!0===this.currEval||void 0===this.currEval)P.cache[u]=new this.safeVm.Script(c);else if("native"===this.currEval)P.cache[u]=new this.vm.Script(c);else if("function"==typeof this.currEval&&this.currEval.prototype&&O.call(this.currEval.prototype,"runInNewContext")){var l=this.currEval;P.cache[u]=new l(c)}else{if("function"!=typeof this.currEval)throw new TypeError('Unknown "eval" property "'.concat(this.currEval,'"'));P.cache[u]={runInNewContext:function(e){return a.currEval(c,e)}}}}try{return P.cache[u].runInNewContext(this.currSandbox)}catch(t){if(this.ignoreEvalErrors)return!1;throw new Error("jsonPath: "+t.message+": "+e)}},P.cache={},P.toPathString=function(e){for(var t=e,r=t.length,n="$",i=1;i<r;i++)/^(~|\^|@(?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*?\(\))$/.test(t[i])||(n+=/^[\*0-9]+$/.test(t[i])?"["+t[i]+"]":"['"+t[i]+"']");return n},P.toPointer=function(e){for(var t=e,r=t.length,n="",i=1;i<r;i++)/^(~|\^|@(?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*?\(\))$/.test(t[i])||(n+="/"+t[i].toString().replace(/~/g,"~0").replace(/\//g,"~1"));return n},P.toPathArray=function(e){var t=P.cache;if(t[e])return t[e].concat();var r=[],n=e.replace(/@(?:null|boolean|number|string|integer|undefined|nonFinite|scalar|array|object|function|other)\(\)/g,";$&;").replace(/['\[](\??\((?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*?\))['\]](?!(?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])\])/g,(function(e,t){return"[#"+(r.push(t)-1)+"]"})).replace(/\[["']((?:[\0-&\(-\\\^-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*)["']\]/g,(function(e,t){return"['"+t.replace(/\./g,"%@%").replace(/~/g,"%%@@%%")+"']"})).replace(/~/g,";~;").replace(/["']?\.["']?(?!(?:[\0-Z\\-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*\])|\[["']?/g,";").replace(/%@%/g,".").replace(/%%@@%%/g,"~").replace(/(?:;)?(\^+)(?:;)?/g,(function(e,t){return";"+t.split("").join(";")+";"})).replace(/;;;|;;/g,";..;").replace(/;$|'?\]|'$/g,"").split(";").map((function(e){var t=e.match(/#([0-9]+)/);return t&&t[1]?r[t[1]]:e}));return t[e]=n,t[e].concat()};F.plugins.register(m,C);var S={evalAst:function(e,t){switch(e.type){case"BinaryExpression":case"LogicalExpression":return S.evalBinaryExpression(e,t);case"Compound":return S.evalCompound(e,t);case"ConditionalExpression":return S.evalConditionalExpression(e,t);case"Identifier":return S.evalIdentifier(e,t);case"Literal":return S.evalLiteral(e,t);case"MemberExpression":return S.evalMemberExpression(e,t);case"UnaryExpression":return S.evalUnaryExpression(e,t);case"ArrayExpression":return S.evalArrayExpression(e,t);case"CallExpression":return S.evalCallExpression(e,t);case"AssignmentExpression":return S.evalAssignmentExpression(e,t);default:throw SyntaxError("Unexpected expression",e)}},evalBinaryExpression:function(e,t){return{"||":function(e,t){return e||t()},"&&":function(e,t){return e&&t()},"|":function(e,t){return e|t()},"^":function(e,t){return e^t()},"&":function(e,t){return e&t()},"==":function(e,t){return e==t()},"!=":function(e,t){return e!=t()},"===":function(e,t){return e===t()},"!==":function(e,t){return e!==t()},"<":function(e,t){return e<t()},">":function(e,t){return e>t()},"<=":function(e,t){return e<=t()},">=":function(e,t){return e>=t()},"<<":function(e,t){return e<<t()},">>":function(e,t){return e>>t()},">>>":function(e,t){return e>>>t()},"+":function(e,t){return e+t()},"-":function(e,t){return e-t()},"*":function(e,t){return e*t()},"/":function(e,t){return e/t()},"%":function(e,t){return e%t()}}[e.operator](S.evalAst(e.left,t),(function(){return S.evalAst(e.right,t)}))},evalCompound:function(e,t){for(var r,n=0;n<e.body.length;n++){"Identifier"===e.body[n].type&&["var","let","const"].includes(e.body[n].name)&&e.body[n+1]&&"AssignmentExpression"===e.body[n+1].type&&(n+=1);var i=e.body[n];r=S.evalAst(i,t)}return r},evalConditionalExpression:function(e,t){return S.evalAst(e.test,t)?S.evalAst(e.consequent,t):S.evalAst(e.alternate,t)},evalIdentifier:function(e,t){if(e.name in t)return t[e.name];throw ReferenceError("".concat(e.name," is not defined"))},evalLiteral:function(e){return e.value},evalMemberExpression:function(e,t){var r=e.computed?S.evalAst(e.property):e.property.name,n=S.evalAst(e.object,t),i=n[r];return"function"==typeof i?i.bind(n):i},evalUnaryExpression:function(e,t){return{"-":function(e){return-S.evalAst(e,t)},"!":function(e){return!S.evalAst(e,t)},"~":function(e){return~S.evalAst(e,t)},"+":function(e){return+S.evalAst(e,t)}}[e.operator](e.argument)},evalArrayExpression:function(e,t){return e.elements.map((function(e){return S.evalAst(e,t)}))},evalCallExpression:function(e,t){var r=e.arguments.map((function(e){return S.evalAst(e,t)}));return S.evalAst(e.callee,t).apply(void 0,p(r))},evalAssignmentExpression:function(e,t){if("Identifier"!==e.left.type)throw SyntaxError("Invalid left-hand side in assignment");var r=e.left.name,n=S.evalAst(e.right,t);return t[r]=n,t[r]}},B=function(){return a((function e(t){n(this,e),this.code=t,this.ast=F(this.code)}),[{key:"runInNewContext",value:function(e){var t=function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?l(Object(r),!0).forEach((function(t){s(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):l(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}({},e);return S.evalAst(this.ast,t)}}])}(),j=function(){return a((function e(t){n(this,e),this.code=t}),[{key:"runInNewContext",value:function(e){var t=this.code,r=Object.keys(e),n=[];!function(e,t,r){for(var n=e.length,i=0;i<n;i++)r(e[i])&&t.push(e.splice(i--,1)[0])}(r,n,(function(t){return"function"==typeof e[t]}));var o=r.map((function(t){return e[t]})),a=n.reduce((function(t,r){var n=e[r].toString();return/function/.test(n)||(n="function "+n),"var "+r+"="+n+";"+t}),"");/(["'])use strict\1/.test(t=a+t)||r.includes("arguments")||(t="var arguments = undefined;"+t);var s=(t=t.replace(/;[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]*$/,"")).lastIndexOf(";"),u=s>-1?t.slice(0,s+1)+" return "+t.slice(s+1):" return "+t;return i(Function,r.concat([u])).apply(void 0,p(o))}}])}();P.prototype.vm={Script:j},P.prototype.safeVm={Script:B},e.JSONPath=P,e.SafeScript=B})); +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).JSONPath={})}(this,(function(e){"use strict";function t(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function r(e,t,r){return t=u(t),function(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,c()?Reflect.construct(t,r||[],u(e).constructor):t.apply(e,r))}function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t,r){if(c())return Reflect.construct.apply(null,arguments);var n=[null];n.push.apply(n,t);var i=new(e.bind.apply(e,n));return r&&l(i,r.prototype),i}function o(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,f(n.key),n)}}function a(e,t,r){return t&&o(e.prototype,t),r&&o(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function s(e,t,r){return(t=f(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function u(e){return u=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},u(e)}function c(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(c=function(){return!!e})()}function h(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function l(e,t){return l=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},l(e,t)}function p(e){return function(e){if(Array.isArray(e))return t(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||y(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function f(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t);if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e,"string");return"symbol"==typeof t?t:t+""}function d(e){return d="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},d(e)}function y(e,r){if(e){if("string"==typeof e)return t(e,r);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?t(e,r):void 0}}function b(e){var t="function"==typeof Map?new Map:void 0;return b=function(e){if(null===e||!function(e){try{return-1!==Function.toString.call(e).indexOf("[native code]")}catch(t){return"function"==typeof e}}(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return i(e,arguments,u(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),l(r,e)},b(e)}var v=function(){return a((function e(){n(this,e)}),[{key:"add",value:function(e,t,r){if("string"!=typeof arguments[0])for(var n in arguments[0])this.add(n,arguments[0][n],arguments[1]);else(Array.isArray(e)?e:[e]).forEach((function(e){this[e]=this[e]||[],t&&this[e][r?"unshift":"push"](t)}),this)}},{key:"run",value:function(e,t){this[e]=this[e]||[],this[e].forEach((function(e){e.call(t&&t.context?t.context:t,t)}))}}])}(),E=function(){return a((function e(t){n(this,e),this.jsep=t,this.registered={}}),[{key:"register",value:function(){for(var e=this,t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];r.forEach((function(t){if("object"!==d(t)||!t.name||!t.init)throw new Error("Invalid JSEP plugin format");e.registered[t.name]||(t.init(e.jsep),e.registered[t.name]=t)}))}}])}(),g=function(){function e(t){n(this,e),this.expr=t,this.index=0}return a(e,[{key:"char",get:function(){return this.expr.charAt(this.index)}},{key:"code",get:function(){return this.expr.charCodeAt(this.index)}},{key:"throwError",value:function(e){var t=new Error(e+" at character "+this.index);throw t.index=this.index,t.description=e,t}},{key:"runHook",value:function(t,r){if(e.hooks[t]){var n={context:this,node:r};return e.hooks.run(t,n),n.node}return r}},{key:"searchHook",value:function(t){if(e.hooks[t]){var r={context:this};return e.hooks[t].find((function(e){return e.call(r.context,r),r.node})),r.node}}},{key:"gobbleSpaces",value:function(){for(var t=this.code;t===e.SPACE_CODE||t===e.TAB_CODE||t===e.LF_CODE||t===e.CR_CODE;)t=this.expr.charCodeAt(++this.index);this.runHook("gobble-spaces")}},{key:"parse",value:function(){this.runHook("before-all");var t=this.gobbleExpressions(),r=1===t.length?t[0]:{type:e.COMPOUND,body:t};return this.runHook("after-all",r)}},{key:"gobbleExpressions",value:function(t){for(var r,n,i=[];this.index<this.expr.length;)if((r=this.code)===e.SEMCOL_CODE||r===e.COMMA_CODE)this.index++;else if(n=this.gobbleExpression())i.push(n);else if(this.index<this.expr.length){if(r===t)break;this.throwError('Unexpected "'+this.char+'"')}return i}},{key:"gobbleExpression",value:function(){var e=this.searchHook("gobble-expression")||this.gobbleBinaryExpression();return this.gobbleSpaces(),this.runHook("after-expression",e)}},{key:"gobbleBinaryOp",value:function(){this.gobbleSpaces();for(var t=this.expr.substr(this.index,e.max_binop_len),r=t.length;r>0;){if(e.binary_ops.hasOwnProperty(t)&&(!e.isIdentifierStart(this.code)||this.index+t.length<this.expr.length&&!e.isIdentifierPart(this.expr.charCodeAt(this.index+t.length))))return this.index+=r,t;t=t.substr(0,--r)}return!1}},{key:"gobbleBinaryExpression",value:function(){var t,r,n,i,o,a,s,u,c,h;if(!(a=this.gobbleToken()))return a;if(!(r=this.gobbleBinaryOp()))return a;for(o={value:r,prec:e.binaryPrecedence(r),right_a:e.right_associative.has(r)},(s=this.gobbleToken())||this.throwError("Expected expression after "+r),i=[a,o,s];r=this.gobbleBinaryOp();){if(0===(n=e.binaryPrecedence(r))){this.index-=r.length;break}o={value:r,prec:n,right_a:e.right_associative.has(r)},c=r;for(;i.length>2&&(h=i[i.length-2],o.right_a&&h.right_a?n>h.prec:n<=h.prec);)s=i.pop(),r=i.pop().value,a=i.pop(),t={type:e.BINARY_EXP,operator:r,left:a,right:s},i.push(t);(t=this.gobbleToken())||this.throwError("Expected expression after "+c),i.push(o,t)}for(t=i[u=i.length-1];u>1;)t={type:e.BINARY_EXP,operator:i[u-1].value,left:i[u-2],right:t},u-=2;return t}},{key:"gobbleToken",value:function(){var t,r,n,i;if(this.gobbleSpaces(),i=this.searchHook("gobble-token"))return this.runHook("after-token",i);if(t=this.code,e.isDecimalDigit(t)||t===e.PERIOD_CODE)return this.gobbleNumericLiteral();if(t===e.SQUOTE_CODE||t===e.DQUOTE_CODE)i=this.gobbleStringLiteral();else if(t===e.OBRACK_CODE)i=this.gobbleArray();else{for(n=(r=this.expr.substr(this.index,e.max_unop_len)).length;n>0;){if(e.unary_ops.hasOwnProperty(r)&&(!e.isIdentifierStart(this.code)||this.index+r.length<this.expr.length&&!e.isIdentifierPart(this.expr.charCodeAt(this.index+r.length)))){this.index+=n;var o=this.gobbleToken();return o||this.throwError("missing unaryOp argument"),this.runHook("after-token",{type:e.UNARY_EXP,operator:r,argument:o,prefix:!0})}r=r.substr(0,--n)}e.isIdentifierStart(t)?(i=this.gobbleIdentifier(),e.literals.hasOwnProperty(i.name)?i={type:e.LITERAL,value:e.literals[i.name],raw:i.name}:i.name===e.this_str&&(i={type:e.THIS_EXP})):t===e.OPAREN_CODE&&(i=this.gobbleGroup())}return i?(i=this.gobbleTokenProperty(i),this.runHook("after-token",i)):this.runHook("after-token",!1)}},{key:"gobbleTokenProperty",value:function(t){this.gobbleSpaces();for(var r=this.code;r===e.PERIOD_CODE||r===e.OBRACK_CODE||r===e.OPAREN_CODE||r===e.QUMARK_CODE;){var n=void 0;if(r===e.QUMARK_CODE){if(this.expr.charCodeAt(this.index+1)!==e.PERIOD_CODE)break;n=!0,this.index+=2,this.gobbleSpaces(),r=this.code}this.index++,r===e.OBRACK_CODE?((t={type:e.MEMBER_EXP,computed:!0,object:t,property:this.gobbleExpression()}).property||this.throwError('Unexpected "'+this.char+'"'),this.gobbleSpaces(),(r=this.code)!==e.CBRACK_CODE&&this.throwError("Unclosed ["),this.index++):r===e.OPAREN_CODE?t={type:e.CALL_EXP,arguments:this.gobbleArguments(e.CPAREN_CODE),callee:t}:(r===e.PERIOD_CODE||n)&&(n&&this.index--,this.gobbleSpaces(),t={type:e.MEMBER_EXP,computed:!1,object:t,property:this.gobbleIdentifier()}),n&&(t.optional=!0),this.gobbleSpaces(),r=this.code}return t}},{key:"gobbleNumericLiteral",value:function(){for(var t,r,n="";e.isDecimalDigit(this.code);)n+=this.expr.charAt(this.index++);if(this.code===e.PERIOD_CODE)for(n+=this.expr.charAt(this.index++);e.isDecimalDigit(this.code);)n+=this.expr.charAt(this.index++);if("e"===(t=this.char)||"E"===t){for(n+=this.expr.charAt(this.index++),"+"!==(t=this.char)&&"-"!==t||(n+=this.expr.charAt(this.index++));e.isDecimalDigit(this.code);)n+=this.expr.charAt(this.index++);e.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+n+this.char+")")}return r=this.code,e.isIdentifierStart(r)?this.throwError("Variable names cannot start with a number ("+n+this.char+")"):(r===e.PERIOD_CODE||1===n.length&&n.charCodeAt(0)===e.PERIOD_CODE)&&this.throwError("Unexpected period"),{type:e.LITERAL,value:parseFloat(n),raw:n}}},{key:"gobbleStringLiteral",value:function(){for(var t="",r=this.index,n=this.expr.charAt(this.index++),i=!1;this.index<this.expr.length;){var o=this.expr.charAt(this.index++);if(o===n){i=!0;break}if("\\"===o)switch(o=this.expr.charAt(this.index++)){case"n":t+="\n";break;case"r":t+="\r";break;case"t":t+="\t";break;case"b":t+="\b";break;case"f":t+="\f";break;case"v":t+="\v";break;default:t+=o}else t+=o}return i||this.throwError('Unclosed quote after "'+t+'"'),{type:e.LITERAL,value:t,raw:this.expr.substring(r,this.index)}}},{key:"gobbleIdentifier",value:function(){var t=this.code,r=this.index;for(e.isIdentifierStart(t)?this.index++:this.throwError("Unexpected "+this.char);this.index<this.expr.length&&(t=this.code,e.isIdentifierPart(t));)this.index++;return{type:e.IDENTIFIER,name:this.expr.slice(r,this.index)}}},{key:"gobbleArguments",value:function(t){for(var r=[],n=!1,i=0;this.index<this.expr.length;){this.gobbleSpaces();var o=this.code;if(o===t){n=!0,this.index++,t===e.CPAREN_CODE&&i&&i>=r.length&&this.throwError("Unexpected token "+String.fromCharCode(t));break}if(o===e.COMMA_CODE){if(this.index++,++i!==r.length)if(t===e.CPAREN_CODE)this.throwError("Unexpected token ,");else if(t===e.CBRACK_CODE)for(var a=r.length;a<i;a++)r.push(null)}else if(r.length!==i&&0!==i)this.throwError("Expected comma");else{var s=this.gobbleExpression();s&&s.type!==e.COMPOUND||this.throwError("Expected comma"),r.push(s)}}return n||this.throwError("Expected "+String.fromCharCode(t)),r}},{key:"gobbleGroup",value:function(){this.index++;var t=this.gobbleExpressions(e.CPAREN_CODE);if(this.code===e.CPAREN_CODE)return this.index++,1===t.length?t[0]:!!t.length&&{type:e.SEQUENCE_EXP,expressions:t};this.throwError("Unclosed (")}},{key:"gobbleArray",value:function(){return this.index++,{type:e.ARRAY_EXP,elements:this.gobbleArguments(e.CBRACK_CODE)}}}],[{key:"version",get:function(){return"1.3.9"}},{key:"toString",value:function(){return"JavaScript Expression Parser (JSEP) v"+e.version}},{key:"addUnaryOp",value:function(t){return e.max_unop_len=Math.max(t.length,e.max_unop_len),e.unary_ops[t]=1,e}},{key:"addBinaryOp",value:function(t,r,n){return e.max_binop_len=Math.max(t.length,e.max_binop_len),e.binary_ops[t]=r,n?e.right_associative.add(t):e.right_associative.delete(t),e}},{key:"addIdentifierChar",value:function(t){return e.additional_identifier_chars.add(t),e}},{key:"addLiteral",value:function(t,r){return e.literals[t]=r,e}},{key:"removeUnaryOp",value:function(t){return delete e.unary_ops[t],t.length===e.max_unop_len&&(e.max_unop_len=e.getMaxKeyLen(e.unary_ops)),e}},{key:"removeAllUnaryOps",value:function(){return e.unary_ops={},e.max_unop_len=0,e}},{key:"removeIdentifierChar",value:function(t){return e.additional_identifier_chars.delete(t),e}},{key:"removeBinaryOp",value:function(t){return delete e.binary_ops[t],t.length===e.max_binop_len&&(e.max_binop_len=e.getMaxKeyLen(e.binary_ops)),e.right_associative.delete(t),e}},{key:"removeAllBinaryOps",value:function(){return e.binary_ops={},e.max_binop_len=0,e}},{key:"removeLiteral",value:function(t){return delete e.literals[t],e}},{key:"removeAllLiterals",value:function(){return e.literals={},e}},{key:"parse",value:function(t){return new e(t).parse()}},{key:"getMaxKeyLen",value:function(e){return Math.max.apply(Math,[0].concat(p(Object.keys(e).map((function(e){return e.length})))))}},{key:"isDecimalDigit",value:function(e){return e>=48&&e<=57}},{key:"binaryPrecedence",value:function(t){return e.binary_ops[t]||0}},{key:"isIdentifierStart",value:function(t){return t>=65&&t<=90||t>=97&&t<=122||t>=128&&!e.binary_ops[String.fromCharCode(t)]||e.additional_identifier_chars.has(String.fromCharCode(t))}},{key:"isIdentifierPart",value:function(t){return e.isIdentifierStart(t)||e.isDecimalDigit(t)}}])}(),x=new v;Object.assign(g,{hooks:x,plugins:new E(g),COMPOUND:"Compound",SEQUENCE_EXP:"SequenceExpression",IDENTIFIER:"Identifier",MEMBER_EXP:"MemberExpression",LITERAL:"Literal",THIS_EXP:"ThisExpression",CALL_EXP:"CallExpression",UNARY_EXP:"UnaryExpression",BINARY_EXP:"BinaryExpression",ARRAY_EXP:"ArrayExpression",TAB_CODE:9,LF_CODE:10,CR_CODE:13,SPACE_CODE:32,PERIOD_CODE:46,COMMA_CODE:44,SQUOTE_CODE:39,DQUOTE_CODE:34,OPAREN_CODE:40,CPAREN_CODE:41,OBRACK_CODE:91,CBRACK_CODE:93,QUMARK_CODE:63,SEMCOL_CODE:59,COLON_CODE:58,unary_ops:{"-":1,"!":1,"~":1,"+":1},binary_ops:{"||":1,"&&":2,"|":3,"^":4,"&":5,"==":6,"!=":6,"===":6,"!==":6,"<":7,">":7,"<=":7,">=":7,"<<":8,">>":8,">>>":8,"+":9,"-":9,"*":10,"/":10,"%":10},right_associative:new Set,additional_identifier_chars:new Set(["$","_"]),literals:{true:!0,false:!1,null:null},this_str:"this"}),g.max_unop_len=g.getMaxKeyLen(g.unary_ops),g.max_binop_len=g.getMaxKeyLen(g.binary_ops);var F=function(e){return new g(e).parse()},D=Object.getOwnPropertyNames(a((function e(){n(this,e)})));Object.getOwnPropertyNames(g).filter((function(e){return!D.includes(e)&&void 0===F[e]})).forEach((function(e){F[e]=g[e]})),F.Jsep=g;var _={name:"ternary",init:function(e){e.hooks.add("after-expression",(function(t){if(t.node&&this.code===e.QUMARK_CODE){this.index++;var r=t.node,n=this.gobbleExpression();if(n||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===e.COLON_CODE){this.index++;var i=this.gobbleExpression();if(i||this.throwError("Expected expression"),t.node={type:"ConditionalExpression",test:r,consequent:n,alternate:i},r.operator&&e.binary_ops[r.operator]<=.9){for(var o=r;o.right.operator&&e.binary_ops[o.right.operator]<=.9;)o=o.right;t.node.test=o.right,o.right=t.node,t.node=r}}else this.throwError("Expected :")}}))}};F.plugins.register(_);var O={name:"regex",init:function(e){e.hooks.add("gobble-token",(function(t){if(47===this.code){for(var r=++this.index,n=!1;this.index<this.expr.length;){if(47===this.code&&!n){for(var i=this.expr.slice(r,this.index),o="";++this.index<this.expr.length;){var a=this.code;if(!(a>=97&&a<=122||a>=65&&a<=90||a>=48&&a<=57))break;o+=this.char}var s=void 0;try{s=new RegExp(i,o)}catch(e){this.throwError(e.message)}return t.node={type:e.LITERAL,value:s,raw:this.expr.slice(r-1,this.index)},t.node=this.gobbleTokenProperty(t.node),t.node}this.code===e.OBRACK_CODE?n=!0:n&&this.code===e.CBRACK_CODE&&(n=!1),this.index+=92===this.code?2:1}this.throwError("Unclosed Regex")}}))}},m={name:"assignment",assignmentOperators:new Set(["=","*=","**=","/=","%=","+=","-=","<<=",">>=",">>>=","&=","^=","|="]),updateOperators:[43,45],assignmentPrecedence:.9,init:function(e){var t=[e.IDENTIFIER,e.MEMBER_EXP];function r(e){m.assignmentOperators.has(e.operator)?(e.type="AssignmentExpression",r(e.left),r(e.right)):e.operator||Object.values(e).forEach((function(e){e&&"object"===d(e)&&r(e)}))}m.assignmentOperators.forEach((function(t){return e.addBinaryOp(t,m.assignmentPrecedence,!0)})),e.hooks.add("gobble-token",(function(e){var r=this,n=this.code;m.updateOperators.some((function(e){return e===n&&e===r.expr.charCodeAt(r.index+1)}))&&(this.index+=2,e.node={type:"UpdateExpression",operator:43===n?"++":"--",argument:this.gobbleTokenProperty(this.gobbleIdentifier()),prefix:!0},e.node.argument&&t.includes(e.node.argument.type)||this.throwError("Unexpected ".concat(e.node.operator)))})),e.hooks.add("after-token",(function(e){var r=this;if(e.node){var n=this.code;m.updateOperators.some((function(e){return e===n&&e===r.expr.charCodeAt(r.index+1)}))&&(t.includes(e.node.type)||this.throwError("Unexpected ".concat(e.node.operator)),this.index+=2,e.node={type:"UpdateExpression",operator:43===n?"++":"--",argument:e.node,prefix:!1})}})),e.hooks.add("after-expression",(function(e){e.node&&r(e.node)}))}};F.plugins.register(O,m);var C={evalAst:function(e,t){switch(e.type){case"BinaryExpression":case"LogicalExpression":return C.evalBinaryExpression(e,t);case"Compound":return C.evalCompound(e,t);case"ConditionalExpression":return C.evalConditionalExpression(e,t);case"Identifier":return C.evalIdentifier(e,t);case"Literal":return C.evalLiteral(e,t);case"MemberExpression":return C.evalMemberExpression(e,t);case"UnaryExpression":return C.evalUnaryExpression(e,t);case"ArrayExpression":return C.evalArrayExpression(e,t);case"CallExpression":return C.evalCallExpression(e,t);case"AssignmentExpression":return C.evalAssignmentExpression(e,t);default:throw SyntaxError("Unexpected expression",e)}},evalBinaryExpression:function(e,t){return{"||":function(e,t){return e||t()},"&&":function(e,t){return e&&t()},"|":function(e,t){return e|t()},"^":function(e,t){return e^t()},"&":function(e,t){return e&t()},"==":function(e,t){return e==t()},"!=":function(e,t){return e!=t()},"===":function(e,t){return e===t()},"!==":function(e,t){return e!==t()},"<":function(e,t){return e<t()},">":function(e,t){return e>t()},"<=":function(e,t){return e<=t()},">=":function(e,t){return e>=t()},"<<":function(e,t){return e<<t()},">>":function(e,t){return e>>t()},">>>":function(e,t){return e>>>t()},"+":function(e,t){return e+t()},"-":function(e,t){return e-t()},"*":function(e,t){return e*t()},"/":function(e,t){return e/t()},"%":function(e,t){return e%t()}}[e.operator](C.evalAst(e.left,t),(function(){return C.evalAst(e.right,t)}))},evalCompound:function(e,t){for(var r,n=0;n<e.body.length;n++){"Identifier"===e.body[n].type&&["var","let","const"].includes(e.body[n].name)&&e.body[n+1]&&"AssignmentExpression"===e.body[n+1].type&&(n+=1);var i=e.body[n];r=C.evalAst(i,t)}return r},evalConditionalExpression:function(e,t){return C.evalAst(e.test,t)?C.evalAst(e.consequent,t):C.evalAst(e.alternate,t)},evalIdentifier:function(e,t){if(e.name in t)return t[e.name];throw ReferenceError("".concat(e.name," is not defined"))},evalLiteral:function(e){return e.value},evalMemberExpression:function(e,t){var r=e.computed?C.evalAst(e.property):e.property.name,n=C.evalAst(e.object,t),i=n[r];return"function"==typeof i?i.bind(n):i},evalUnaryExpression:function(e,t){return{"-":function(e){return-C.evalAst(e,t)},"!":function(e){return!C.evalAst(e,t)},"~":function(e){return~C.evalAst(e,t)},"+":function(e){return+C.evalAst(e,t)}}[e.operator](e.argument)},evalArrayExpression:function(e,t){return e.elements.map((function(e){return C.evalAst(e,t)}))},evalCallExpression:function(e,t){var r=e.arguments.map((function(e){return C.evalAst(e,t)}));return C.evalAst(e.callee,t).apply(void 0,p(r))},evalAssignmentExpression:function(e,t){if("Identifier"!==e.left.type)throw SyntaxError("Invalid left-hand side in assignment");var r=e.left.name,n=C.evalAst(e.right,t);return t[r]=n,t[r]}},w=function(){return a((function e(t){n(this,e),this.code=t,this.ast=F(this.code)}),[{key:"runInNewContext",value:function(e){var t=function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?h(Object(r),!0).forEach((function(t){s(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):h(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}({},e);return C.evalAst(this.ast,t)}}])}();function A(e,t){return(e=e.slice()).push(t),e}function k(e,t){return(t=t.slice()).unshift(e),t}var P=function(e){function t(e){var i;return n(this,t),(i=r(this,t,['JSONPath should not be called with "new" (it prevents return of (unwrapped) scalar values)'])).avoidNew=!0,i.value=e,i.name="NewError",i}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&l(e,t)}(t,e),a(t)}(b(Error));function S(e,t,r,n,i){if(!(this instanceof S))try{return new S(e,t,r,n,i)}catch(e){if(!e.avoidNew)throw e;return e.value}"string"==typeof e&&(i=n,n=r,r=t,t=e,e=null);var o=e&&"object"===d(e);if(e=e||{},this.json=e.json||r,this.path=e.path||t,this.resultType=e.resultType||"value",this.flatten=e.flatten||!1,this.wrap=!Object.hasOwn(e,"wrap")||e.wrap,this.sandbox=e.sandbox||{},this.eval=void 0===e.eval?"safe":e.eval,this.ignoreEvalErrors=void 0!==e.ignoreEvalErrors&&e.ignoreEvalErrors,this.parent=e.parent||null,this.parentProperty=e.parentProperty||null,this.callback=e.callback||n||null,this.otherTypeCallback=e.otherTypeCallback||i||function(){throw new TypeError("You must supply an otherTypeCallback callback option with the @other() operator.")},!1!==e.autostart){var a={path:o?e.path:t};o?"json"in e&&(a.json=e.json):a.json=r;var s=this.evaluate(a);if(!s||"object"!==d(s))throw new P(s);return s}}S.prototype.evaluate=function(e,t,r,n){var i=this,o=this.parent,a=this.parentProperty,s=this.flatten,u=this.wrap;if(this.currResultType=this.resultType,this.currEval=this.eval,this.currSandbox=this.sandbox,r=r||this.callback,this.currOtherTypeCallback=n||this.otherTypeCallback,t=t||this.json,(e=e||this.path)&&"object"===d(e)&&!Array.isArray(e)){if(!e.path&&""!==e.path)throw new TypeError('You must supply a "path" property when providing an object argument to JSONPath.evaluate().');if(!Object.hasOwn(e,"json"))throw new TypeError('You must supply a "json" property when providing an object argument to JSONPath.evaluate().');t=e.json,s=Object.hasOwn(e,"flatten")?e.flatten:s,this.currResultType=Object.hasOwn(e,"resultType")?e.resultType:this.currResultType,this.currSandbox=Object.hasOwn(e,"sandbox")?e.sandbox:this.currSandbox,u=Object.hasOwn(e,"wrap")?e.wrap:u,this.currEval=Object.hasOwn(e,"eval")?e.eval:this.currEval,r=Object.hasOwn(e,"callback")?e.callback:r,this.currOtherTypeCallback=Object.hasOwn(e,"otherTypeCallback")?e.otherTypeCallback:this.currOtherTypeCallback,o=Object.hasOwn(e,"parent")?e.parent:o,a=Object.hasOwn(e,"parentProperty")?e.parentProperty:a,e=e.path}if(o=o||null,a=a||null,Array.isArray(e)&&(e=S.toPathString(e)),(e||""===e)&&t){var c=S.toPathArray(e);"$"===c[0]&&c.length>1&&c.shift(),this._hasParentSelector=null;var h=this._trace(c,t,["$"],o,a,r).filter((function(e){return e&&!e.isParentSelector}));return h.length?u||1!==h.length||h[0].hasArrExpr?h.reduce((function(e,t){var r=i._getPreferredOutput(t);return s&&Array.isArray(r)?e=e.concat(r):e.push(r),e}),[]):this._getPreferredOutput(h[0]):u?[]:void 0}},S.prototype._getPreferredOutput=function(e){var t=this.currResultType;switch(t){case"all":var r=Array.isArray(e.path)?e.path:S.toPathArray(e.path);return e.pointer=S.toPointer(r),e.path="string"==typeof e.path?e.path:S.toPathString(e.path),e;case"value":case"parent":case"parentProperty":return e[t];case"path":return S.toPathString(e[t]);case"pointer":return S.toPointer(e.path);default:throw new TypeError("Unknown result type")}},S.prototype._handleCallback=function(e,t,r){if(t){var n=this._getPreferredOutput(e);e.path="string"==typeof e.path?e.path:S.toPathString(e.path),t(n,r,e)}},S.prototype._trace=function(e,t,r,n,i,o,a,s){var u,c=this;if(!e.length)return u={path:r,value:t,parent:n,parentProperty:i,hasArrExpr:a},this._handleCallback(u,o,"value"),u;var h=e[0],l=e.slice(1),p=[];function f(e){Array.isArray(e)?e.forEach((function(e){p.push(e)})):p.push(e)}if(("string"!=typeof h||s)&&t&&Object.hasOwn(t,h))f(this._trace(l,t[h],A(r,h),t,h,o,a));else if("*"===h)this._walk(t,(function(e){f(c._trace(l,t[e],A(r,e),t,e,o,!0,!0))}));else if(".."===h)f(this._trace(l,t,r,n,i,o,a)),this._walk(t,(function(n){"object"===d(t[n])&&f(c._trace(e.slice(),t[n],A(r,n),t,n,o,!0))}));else{if("^"===h)return this._hasParentSelector=!0,{path:r.slice(0,-1),expr:l,isParentSelector:!0};if("~"===h)return u={path:A(r,h),value:i,parent:n,parentProperty:null},this._handleCallback(u,o,"property"),u;if("$"===h)f(this._trace(l,t,r,null,null,o,a));else if(/^(-?[0-9]*):(-?[0-9]*):?([0-9]*)$/.test(h))f(this._slice(h,l,t,r,n,i,o));else if(0===h.indexOf("?(")){if(!1===this.currEval)throw new Error("Eval [?(expr)] prevented in JSONPath expression.");var b=h.replace(/^\?\(((?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*?)\)$/,"$1"),v=/@(?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])?((?:[\0->@-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*)['\[](\??\((?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*?\))(?!(?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])\)\])['\]]/g.exec(b);v?this._walk(t,(function(e){var a=[v[2]],s=v[1]?t[e][v[1]]:t[e];c._trace(a,s,r,n,i,o,!0).length>0&&f(c._trace(l,t[e],A(r,e),t,e,o,!0))})):this._walk(t,(function(e){c._eval(b,t[e],e,r,n,i)&&f(c._trace(l,t[e],A(r,e),t,e,o,!0))}))}else if("("===h[0]){if(!1===this.currEval)throw new Error("Eval [(expr)] prevented in JSONPath expression.");f(this._trace(k(this._eval(h,t,r[r.length-1],r.slice(0,-1),n,i),l),t,r,n,i,o,a))}else if("@"===h[0]){var E=!1,g=h.slice(1,-2);switch(g){case"scalar":t&&["object","function"].includes(d(t))||(E=!0);break;case"boolean":case"string":case"undefined":case"function":d(t)===g&&(E=!0);break;case"integer":!Number.isFinite(t)||t%1||(E=!0);break;case"number":Number.isFinite(t)&&(E=!0);break;case"nonFinite":"number"!=typeof t||Number.isFinite(t)||(E=!0);break;case"object":t&&d(t)===g&&(E=!0);break;case"array":Array.isArray(t)&&(E=!0);break;case"other":E=this.currOtherTypeCallback(t,r,n,i);break;case"null":null===t&&(E=!0);break;default:throw new TypeError("Unknown value type "+g)}if(E)return u={path:r,value:t,parent:n,parentProperty:i},this._handleCallback(u,o,"value"),u}else if("`"===h[0]&&t&&Object.hasOwn(t,h.slice(1))){var x=h.slice(1);f(this._trace(l,t[x],A(r,x),t,x,o,a,!0))}else if(h.includes(",")){var F,D=function(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=y(e))||t){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}(h.split(","));try{for(D.s();!(F=D.n()).done;){var _=F.value;f(this._trace(k(_,l),t,r,n,i,o,!0))}}catch(e){D.e(e)}finally{D.f()}}else!s&&t&&Object.hasOwn(t,h)&&f(this._trace(l,t[h],A(r,h),t,h,o,a,!0))}if(this._hasParentSelector)for(var O=0;O<p.length;O++){var m=p[O];if(m&&m.isParentSelector){var C=this._trace(m.expr,t,m.path,n,i,o,a);if(Array.isArray(C)){p[O]=C[0];for(var w=C.length,P=1;P<w;P++)O++,p.splice(O,0,C[P])}else p[O]=C}}return p},S.prototype._walk=function(e,t){if(Array.isArray(e))for(var r=e.length,n=0;n<r;n++)t(n);else e&&"object"===d(e)&&Object.keys(e).forEach((function(e){t(e)}))},S.prototype._slice=function(e,t,r,n,i,o,a){if(Array.isArray(r)){var s=r.length,u=e.split(":"),c=u[2]&&Number.parseInt(u[2])||1,h=u[0]&&Number.parseInt(u[0])||0,l=u[1]&&Number.parseInt(u[1])||s;h=h<0?Math.max(0,h+s):Math.min(s,h),l=l<0?Math.max(0,l+s):Math.min(s,l);for(var p=[],f=h;f<l;f+=c){this._trace(k(f,t),r,n,i,o,a,!0).forEach((function(e){p.push(e)}))}return p}},S.prototype._eval=function(e,t,r,n,i,o){var a=this;this.currSandbox._$_parentProperty=o,this.currSandbox._$_parent=i,this.currSandbox._$_property=r,this.currSandbox._$_root=this.json,this.currSandbox._$_v=t;var s=e.includes("@path");s&&(this.currSandbox._$_path=S.toPathString(n.concat([r])));var u=this.currEval+"Script:"+e;if(!S.cache[u]){var c=e.replace(/@parentProperty/g,"_$_parentProperty").replace(/@parent/g,"_$_parent").replace(/@property/g,"_$_property").replace(/@root/g,"_$_root").replace(/@([\t-\r \)\.\[\xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF])/g,"_$_v$1");if(s&&(c=c.replace(/@path/g,"_$_path")),"safe"===this.currEval||!0===this.currEval||void 0===this.currEval)S.cache[u]=new this.safeVm.Script(c);else if("native"===this.currEval)S.cache[u]=new this.vm.Script(c);else if("function"==typeof this.currEval&&this.currEval.prototype&&Object.hasOwn(this.currEval.prototype,"runInNewContext")){var h=this.currEval;S.cache[u]=new h(c)}else{if("function"!=typeof this.currEval)throw new TypeError('Unknown "eval" property "'.concat(this.currEval,'"'));S.cache[u]={runInNewContext:function(e){return a.currEval(c,e)}}}}try{return S.cache[u].runInNewContext(this.currSandbox)}catch(t){if(this.ignoreEvalErrors)return!1;throw new Error("jsonPath: "+t.message+": "+e)}},S.cache={},S.toPathString=function(e){for(var t=e,r=t.length,n="$",i=1;i<r;i++)/^(~|\^|@(?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*?\(\))$/.test(t[i])||(n+=/^[\*0-9]+$/.test(t[i])?"["+t[i]+"]":"['"+t[i]+"']");return n},S.toPointer=function(e){for(var t=e,r=t.length,n="",i=1;i<r;i++)/^(~|\^|@(?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*?\(\))$/.test(t[i])||(n+="/"+t[i].toString().replace(/~/g,"~0").replace(/\//g,"~1"));return n},S.toPathArray=function(e){var t=S.cache;if(t[e])return t[e].concat();var r=[],n=e.replace(/@(?:null|boolean|number|string|integer|undefined|nonFinite|scalar|array|object|function|other)\(\)/g,";$&;").replace(/['\[](\??\((?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*?\))['\]](?!(?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])\])/g,(function(e,t){return"[#"+(r.push(t)-1)+"]"})).replace(/\[["']((?:[\0-&\(-\\\^-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^ ... [truncated]
dist/index-browser-umd.min.cjs.map+1 −1 modifieddist/index-node-cjs.cjs+1382 −31 modified@@ -2,14 +2,1365 @@ var vm = require('vm'); +/** + * @implements {IHooks} + */ +class Hooks { + /** + * @callback HookCallback + * @this {*|Jsep} this + * @param {Jsep} env + * @returns: void + */ + /** + * Adds the given callback to the list of callbacks for the given hook. + * + * The callback will be invoked when the hook it is registered for is run. + * + * One callback function can be registered to multiple hooks and the same hook multiple times. + * + * @param {string|object} name The name of the hook, or an object of callbacks keyed by name + * @param {HookCallback|boolean} callback The callback function which is given environment variables. + * @param {?boolean} [first=false] Will add the hook to the top of the list (defaults to the bottom) + * @public + */ + add(name, callback, first) { + if (typeof arguments[0] != 'string') { + // Multiple hook callbacks, keyed by name + for (let name in arguments[0]) { + this.add(name, arguments[0][name], arguments[1]); + } + } else { + (Array.isArray(name) ? name : [name]).forEach(function (name) { + this[name] = this[name] || []; + if (callback) { + this[name][first ? 'unshift' : 'push'](callback); + } + }, this); + } + } + + /** + * Runs a hook invoking all registered callbacks with the given environment variables. + * + * Callbacks will be invoked synchronously and in the order in which they were registered. + * + * @param {string} name The name of the hook. + * @param {Object<string, any>} env The environment variables of the hook passed to all callbacks registered. + * @public + */ + run(name, env) { + this[name] = this[name] || []; + this[name].forEach(function (callback) { + callback.call(env && env.context ? env.context : env, env); + }); + } +} + +/** + * @implements {IPlugins} + */ +class Plugins { + constructor(jsep) { + this.jsep = jsep; + this.registered = {}; + } + + /** + * @callback PluginSetup + * @this {Jsep} jsep + * @returns: void + */ + /** + * Adds the given plugin(s) to the registry + * + * @param {object} plugins + * @param {string} plugins.name The name of the plugin + * @param {PluginSetup} plugins.init The init function + * @public + */ + register(...plugins) { + plugins.forEach(plugin => { + if (typeof plugin !== 'object' || !plugin.name || !plugin.init) { + throw new Error('Invalid JSEP plugin format'); + } + if (this.registered[plugin.name]) { + // already registered. Ignore. + return; + } + plugin.init(this.jsep); + this.registered[plugin.name] = plugin; + }); + } +} + +// JavaScript Expression Parser (JSEP) 1.3.9 + +class Jsep { + /** + * @returns {string} + */ + static get version() { + // To be filled in by the template + return '1.3.9'; + } + + /** + * @returns {string} + */ + static toString() { + return 'JavaScript Expression Parser (JSEP) v' + Jsep.version; + } + // ==================== CONFIG ================================ + /** + * @method addUnaryOp + * @param {string} op_name The name of the unary op to add + * @returns {Jsep} + */ + static addUnaryOp(op_name) { + Jsep.max_unop_len = Math.max(op_name.length, Jsep.max_unop_len); + Jsep.unary_ops[op_name] = 1; + return Jsep; + } + + /** + * @method jsep.addBinaryOp + * @param {string} op_name The name of the binary op to add + * @param {number} precedence The precedence of the binary op (can be a float). Higher number = higher precedence + * @param {boolean} [isRightAssociative=false] whether operator is right-associative + * @returns {Jsep} + */ + static addBinaryOp(op_name, precedence, isRightAssociative) { + Jsep.max_binop_len = Math.max(op_name.length, Jsep.max_binop_len); + Jsep.binary_ops[op_name] = precedence; + if (isRightAssociative) { + Jsep.right_associative.add(op_name); + } else { + Jsep.right_associative.delete(op_name); + } + return Jsep; + } + + /** + * @method addIdentifierChar + * @param {string} char The additional character to treat as a valid part of an identifier + * @returns {Jsep} + */ + static addIdentifierChar(char) { + Jsep.additional_identifier_chars.add(char); + return Jsep; + } + + /** + * @method addLiteral + * @param {string} literal_name The name of the literal to add + * @param {*} literal_value The value of the literal + * @returns {Jsep} + */ + static addLiteral(literal_name, literal_value) { + Jsep.literals[literal_name] = literal_value; + return Jsep; + } + + /** + * @method removeUnaryOp + * @param {string} op_name The name of the unary op to remove + * @returns {Jsep} + */ + static removeUnaryOp(op_name) { + delete Jsep.unary_ops[op_name]; + if (op_name.length === Jsep.max_unop_len) { + Jsep.max_unop_len = Jsep.getMaxKeyLen(Jsep.unary_ops); + } + return Jsep; + } + + /** + * @method removeAllUnaryOps + * @returns {Jsep} + */ + static removeAllUnaryOps() { + Jsep.unary_ops = {}; + Jsep.max_unop_len = 0; + return Jsep; + } + + /** + * @method removeIdentifierChar + * @param {string} char The additional character to stop treating as a valid part of an identifier + * @returns {Jsep} + */ + static removeIdentifierChar(char) { + Jsep.additional_identifier_chars.delete(char); + return Jsep; + } + + /** + * @method removeBinaryOp + * @param {string} op_name The name of the binary op to remove + * @returns {Jsep} + */ + static removeBinaryOp(op_name) { + delete Jsep.binary_ops[op_name]; + if (op_name.length === Jsep.max_binop_len) { + Jsep.max_binop_len = Jsep.getMaxKeyLen(Jsep.binary_ops); + } + Jsep.right_associative.delete(op_name); + return Jsep; + } + + /** + * @method removeAllBinaryOps + * @returns {Jsep} + */ + static removeAllBinaryOps() { + Jsep.binary_ops = {}; + Jsep.max_binop_len = 0; + return Jsep; + } + + /** + * @method removeLiteral + * @param {string} literal_name The name of the literal to remove + * @returns {Jsep} + */ + static removeLiteral(literal_name) { + delete Jsep.literals[literal_name]; + return Jsep; + } + + /** + * @method removeAllLiterals + * @returns {Jsep} + */ + static removeAllLiterals() { + Jsep.literals = {}; + return Jsep; + } + // ==================== END CONFIG ============================ + + /** + * @returns {string} + */ + get char() { + return this.expr.charAt(this.index); + } + + /** + * @returns {number} + */ + get code() { + return this.expr.charCodeAt(this.index); + } + /** + * @param {string} expr a string with the passed in express + * @returns Jsep + */ + constructor(expr) { + // `index` stores the character number we are currently at + // All of the gobbles below will modify `index` as we move along + this.expr = expr; + this.index = 0; + } + + /** + * static top-level parser + * @returns {jsep.Expression} + */ + static parse(expr) { + return new Jsep(expr).parse(); + } + + /** + * Get the longest key length of any object + * @param {object} obj + * @returns {number} + */ + static getMaxKeyLen(obj) { + return Math.max(0, ...Object.keys(obj).map(k => k.length)); + } + + /** + * `ch` is a character code in the next three functions + * @param {number} ch + * @returns {boolean} + */ + static isDecimalDigit(ch) { + return ch >= 48 && ch <= 57; // 0...9 + } + + /** + * Returns the precedence of a binary operator or `0` if it isn't a binary operator. Can be float. + * @param {string} op_val + * @returns {number} + */ + static binaryPrecedence(op_val) { + return Jsep.binary_ops[op_val] || 0; + } + + /** + * Looks for start of identifier + * @param {number} ch + * @returns {boolean} + */ + static isIdentifierStart(ch) { + return ch >= 65 && ch <= 90 || + // A...Z + ch >= 97 && ch <= 122 || + // a...z + ch >= 128 && !Jsep.binary_ops[String.fromCharCode(ch)] || + // any non-ASCII that is not an operator + Jsep.additional_identifier_chars.has(String.fromCharCode(ch)); // additional characters + } + + /** + * @param {number} ch + * @returns {boolean} + */ + static isIdentifierPart(ch) { + return Jsep.isIdentifierStart(ch) || Jsep.isDecimalDigit(ch); + } + + /** + * throw error at index of the expression + * @param {string} message + * @throws + */ + throwError(message) { + const error = new Error(message + ' at character ' + this.index); + error.index = this.index; + error.description = message; + throw error; + } + + /** + * Run a given hook + * @param {string} name + * @param {jsep.Expression|false} [node] + * @returns {?jsep.Expression} + */ + runHook(name, node) { + if (Jsep.hooks[name]) { + const env = { + context: this, + node + }; + Jsep.hooks.run(name, env); + return env.node; + } + return node; + } + + /** + * Runs a given hook until one returns a node + * @param {string} name + * @returns {?jsep.Expression} + */ + searchHook(name) { + if (Jsep.hooks[name]) { + const env = { + context: this + }; + Jsep.hooks[name].find(function (callback) { + callback.call(env.context, env); + return env.node; + }); + return env.node; + } + } + + /** + * Push `index` up to the next non-space character + */ + gobbleSpaces() { + let ch = this.code; + // Whitespace + while (ch === Jsep.SPACE_CODE || ch === Jsep.TAB_CODE || ch === Jsep.LF_CODE || ch === Jsep.CR_CODE) { + ch = this.expr.charCodeAt(++this.index); + } + this.runHook('gobble-spaces'); + } + + /** + * Top-level method to parse all expressions and returns compound or single node + * @returns {jsep.Expression} + */ + parse() { + this.runHook('before-all'); + const nodes = this.gobbleExpressions(); + + // If there's only one expression just try returning the expression + const node = nodes.length === 1 ? nodes[0] : { + type: Jsep.COMPOUND, + body: nodes + }; + return this.runHook('after-all', node); + } + + /** + * top-level parser (but can be reused within as well) + * @param {number} [untilICode] + * @returns {jsep.Expression[]} + */ + gobbleExpressions(untilICode) { + let nodes = [], + ch_i, + node; + while (this.index < this.expr.length) { + ch_i = this.code; + + // Expressions can be separated by semicolons, commas, or just inferred without any + // separators + if (ch_i === Jsep.SEMCOL_CODE || ch_i === Jsep.COMMA_CODE) { + this.index++; // ignore separators + } else { + // Try to gobble each expression individually + if (node = this.gobbleExpression()) { + nodes.push(node); + // If we weren't able to find a binary expression and are out of room, then + // the expression passed in probably has too much + } else if (this.index < this.expr.length) { + if (ch_i === untilICode) { + break; + } + this.throwError('Unexpected "' + this.char + '"'); + } + } + } + return nodes; + } + + /** + * The main parsing function. + * @returns {?jsep.Expression} + */ + gobbleExpression() { + const node = this.searchHook('gobble-expression') || this.gobbleBinaryExpression(); + this.gobbleSpaces(); + return this.runHook('after-expression', node); + } + + /** + * Search for the operation portion of the string (e.g. `+`, `===`) + * Start by taking the longest possible binary operations (3 characters: `===`, `!==`, `>>>`) + * and move down from 3 to 2 to 1 character until a matching binary operation is found + * then, return that binary operation + * @returns {string|boolean} + */ + gobbleBinaryOp() { + this.gobbleSpaces(); + let to_check = this.expr.substr(this.index, Jsep.max_binop_len); + let tc_len = to_check.length; + while (tc_len > 0) { + // Don't accept a binary op when it is an identifier. + // Binary ops that start with a identifier-valid character must be followed + // by a non identifier-part valid character + if (Jsep.binary_ops.hasOwnProperty(to_check) && (!Jsep.isIdentifierStart(this.code) || this.index + to_check.length < this.expr.length && !Jsep.isIdentifierPart(this.expr.charCodeAt(this.index + to_check.length)))) { + this.index += tc_len; + return to_check; + } + to_check = to_check.substr(0, --tc_len); + } + return false; + } + + /** + * This function is responsible for gobbling an individual expression, + * e.g. `1`, `1+2`, `a+(b*2)-Math.sqrt(2)` + * @returns {?jsep.BinaryExpression} + */ + gobbleBinaryExpression() { + let node, biop, prec, stack, biop_info, left, right, i, cur_biop; + + // First, try to get the leftmost thing + // Then, check to see if there's a binary operator operating on that leftmost thing + // Don't gobbleBinaryOp without a left-hand-side + left = this.gobbleToken(); + if (!left) { + return left; + } + biop = this.gobbleBinaryOp(); + + // If there wasn't a binary operator, just return the leftmost node + if (!biop) { + return left; + } + + // Otherwise, we need to start a stack to properly place the binary operations in their + // precedence structure + biop_info = { + value: biop, + prec: Jsep.binaryPrecedence(biop), + right_a: Jsep.right_associative.has(biop) + }; + right = this.gobbleToken(); + if (!right) { + this.throwError("Expected expression after " + biop); + } + stack = [left, biop_info, right]; + + // Properly deal with precedence using [recursive descent](http://www.engr.mun.ca/~theo/Misc/exp_parsing.htm) + while (biop = this.gobbleBinaryOp()) { + prec = Jsep.binaryPrecedence(biop); + if (prec === 0) { + this.index -= biop.length; + break; + } + biop_info = { + value: biop, + prec, + right_a: Jsep.right_associative.has(biop) + }; + cur_biop = biop; + + // Reduce: make a binary expression from the three topmost entries. + const comparePrev = prev => biop_info.right_a && prev.right_a ? prec > prev.prec : prec <= prev.prec; + while (stack.length > 2 && comparePrev(stack[stack.length - 2])) { + right = stack.pop(); + biop = stack.pop().value; + left = stack.pop(); + node = { + type: Jsep.BINARY_EXP, + operator: biop, + left, + right + }; + stack.push(node); + } + node = this.gobbleToken(); + if (!node) { + this.throwError("Expected expression after " + cur_biop); + } + stack.push(biop_info, node); + } + i = stack.length - 1; + node = stack[i]; + while (i > 1) { + node = { + type: Jsep.BINARY_EXP, + operator: stack[i - 1].value, + left: stack[i - 2], + right: node + }; + i -= 2; + } + return node; + } + + /** + * An individual part of a binary expression: + * e.g. `foo.bar(baz)`, `1`, `"abc"`, `(a % 2)` (because it's in parenthesis) + * @returns {boolean|jsep.Expression} + */ + gobbleToken() { + let ch, to_check, tc_len, node; + this.gobbleSpaces(); + node = this.searchHook('gobble-token'); + if (node) { + return this.runHook('after-token', node); + } + ch = this.code; + if (Jsep.isDecimalDigit(ch) || ch === Jsep.PERIOD_CODE) { + // Char code 46 is a dot `.` which can start off a numeric literal + return this.gobbleNumericLiteral(); + } + if (ch === Jsep.SQUOTE_CODE || ch === Jsep.DQUOTE_CODE) { + // Single or double quotes + node = this.gobbleStringLiteral(); + } else if (ch === Jsep.OBRACK_CODE) { + node = this.gobbleArray(); + } else { + to_check = this.expr.substr(this.index, Jsep.max_unop_len); + tc_len = to_check.length; + while (tc_len > 0) { + // Don't accept an unary op when it is an identifier. + // Unary ops that start with a identifier-valid character must be followed + // by a non identifier-part valid character + if (Jsep.unary_ops.hasOwnProperty(to_check) && (!Jsep.isIdentifierStart(this.code) || this.index + to_check.length < this.expr.length && !Jsep.isIdentifierPart(this.expr.charCodeAt(this.index + to_check.length)))) { + this.index += tc_len; + const argument = this.gobbleToken(); + if (!argument) { + this.throwError('missing unaryOp argument'); + } + return this.runHook('after-token', { + type: Jsep.UNARY_EXP, + operator: to_check, + argument, + prefix: true + }); + } + to_check = to_check.substr(0, --tc_len); + } + if (Jsep.isIdentifierStart(ch)) { + node = this.gobbleIdentifier(); + if (Jsep.literals.hasOwnProperty(node.name)) { + node = { + type: Jsep.LITERAL, + value: Jsep.literals[node.name], + raw: node.name + }; + } else if (node.name === Jsep.this_str) { + node = { + type: Jsep.THIS_EXP + }; + } + } else if (ch === Jsep.OPAREN_CODE) { + // open parenthesis + node = this.gobbleGroup(); + } + } + if (!node) { + return this.runHook('after-token', false); + } + node = this.gobbleTokenProperty(node); + return this.runHook('after-token', node); + } + + /** + * Gobble properties of of identifiers/strings/arrays/groups. + * e.g. `foo`, `bar.baz`, `foo['bar'].baz` + * It also gobbles function calls: + * e.g. `Math.acos(obj.angle)` + * @param {jsep.Expression} node + * @returns {jsep.Expression} + */ + gobbleTokenProperty(node) { + this.gobbleSpaces(); + let ch = this.code; + while (ch === Jsep.PERIOD_CODE || ch === Jsep.OBRACK_CODE || ch === Jsep.OPAREN_CODE || ch === Jsep.QUMARK_CODE) { + let optional; + if (ch === Jsep.QUMARK_CODE) { + if (this.expr.charCodeAt(this.index + 1) !== Jsep.PERIOD_CODE) { + break; + } + optional = true; + this.index += 2; + this.gobbleSpaces(); + ch = this.code; + } + this.index++; + if (ch === Jsep.OBRACK_CODE) { + node = { + type: Jsep.MEMBER_EXP, + computed: true, + object: node, + property: this.gobbleExpression() + }; + if (!node.property) { + this.throwError('Unexpected "' + this.char + '"'); + } + this.gobbleSpaces(); + ch = this.code; + if (ch !== Jsep.CBRACK_CODE) { + this.throwError('Unclosed ['); + } + this.index++; + } else if (ch === Jsep.OPAREN_CODE) { + // A function call is being made; gobble all the arguments + node = { + type: Jsep.CALL_EXP, + 'arguments': this.gobbleArguments(Jsep.CPAREN_CODE), + callee: node + }; + } else if (ch === Jsep.PERIOD_CODE || optional) { + if (optional) { + this.index--; + } + this.gobbleSpaces(); + node = { + type: Jsep.MEMBER_EXP, + computed: false, + object: node, + property: this.gobbleIdentifier() + }; + } + if (optional) { + node.optional = true; + } // else leave undefined for compatibility with esprima + + this.gobbleSpaces(); + ch = this.code; + } + return node; + } + + /** + * Parse simple numeric literals: `12`, `3.4`, `.5`. Do this by using a string to + * keep track of everything in the numeric literal and then calling `parseFloat` on that string + * @returns {jsep.Literal} + */ + gobbleNumericLiteral() { + let number = '', + ch, + chCode; + while (Jsep.isDecimalDigit(this.code)) { + number += this.expr.charAt(this.index++); + } + if (this.code === Jsep.PERIOD_CODE) { + // can start with a decimal marker + number += this.expr.charAt(this.index++); + while (Jsep.isDecimalDigit(this.code)) { + number += this.expr.charAt(this.index++); + } + } + ch = this.char; + if (ch === 'e' || ch === 'E') { + // exponent marker + number += this.expr.charAt(this.index++); + ch = this.char; + if (ch === '+' || ch === '-') { + // exponent sign + number += this.expr.charAt(this.index++); + } + while (Jsep.isDecimalDigit(this.code)) { + // exponent itself + number += this.expr.charAt(this.index++); + } + if (!Jsep.isDecimalDigit(this.expr.charCodeAt(this.index - 1))) { + this.throwError('Expected exponent (' + number + this.char + ')'); + } + } + chCode = this.code; + + // Check to make sure this isn't a variable name that start with a number (123abc) + if (Jsep.isIdentifierStart(chCode)) { + this.throwError('Variable names cannot start with a number (' + number + this.char + ')'); + } else if (chCode === Jsep.PERIOD_CODE || number.length === 1 && number.charCodeAt(0) === Jsep.PERIOD_CODE) { + this.throwError('Unexpected period'); + } + return { + type: Jsep.LITERAL, + value: parseFloat(number), + raw: number + }; + } + + /** + * Parses a string literal, staring with single or double quotes with basic support for escape codes + * e.g. `"hello world"`, `'this is\nJSEP'` + * @returns {jsep.Literal} + */ + gobbleStringLiteral() { + let str = ''; + const startIndex = this.index; + const quote = this.expr.charAt(this.index++); + let closed = false; + while (this.index < this.expr.length) { + let ch = this.expr.charAt(this.index++); + if (ch === quote) { + closed = true; + break; + } else if (ch === '\\') { + // Check for all of the common escape codes + ch = this.expr.charAt(this.index++); + switch (ch) { + case 'n': + str += '\n'; + break; + case 'r': + str += '\r'; + break; + case 't': + str += '\t'; + break; + case 'b': + str += '\b'; + break; + case 'f': + str += '\f'; + break; + case 'v': + str += '\x0B'; + break; + default: + str += ch; + } + } else { + str += ch; + } + } + if (!closed) { + this.throwError('Unclosed quote after "' + str + '"'); + } + return { + type: Jsep.LITERAL, + value: str, + raw: this.expr.substring(startIndex, this.index) + }; + } + + /** + * Gobbles only identifiers + * e.g.: `foo`, `_value`, `$x1` + * Also, this function checks if that identifier is a literal: + * (e.g. `true`, `false`, `null`) or `this` + * @returns {jsep.Identifier} + */ + gobbleIdentifier() { + let ch = this.code, + start = this.index; + if (Jsep.isIdentifierStart(ch)) { + this.index++; + } else { + this.throwError('Unexpected ' + this.char); + } + while (this.index < this.expr.length) { + ch = this.code; + if (Jsep.isIdentifierPart(ch)) { + this.index++; + } else { + break; + } + } + return { + type: Jsep.IDENTIFIER, + name: this.expr.slice(start, this.index) + }; + } + + /** + * Gobbles a list of arguments within the context of a function call + * or array literal. This function also assumes that the opening character + * `(` or `[` has already been gobbled, and gobbles expressions and commas + * until the terminator character `)` or `]` is encountered. + * e.g. `foo(bar, baz)`, `my_func()`, or `[bar, baz]` + * @param {number} termination + * @returns {jsep.Expression[]} + */ + gobbleArguments(termination) { + const args = []; + let closed = false; + let separator_count = 0; + while (this.index < this.expr.length) { + this.gobbleSpaces(); + let ch_i = this.code; + if (ch_i === termination) { + // done parsing + closed = true; + this.index++; + if (termination === Jsep.CPAREN_CODE && separator_count && separator_count >= args.length) { + this.throwError('Unexpected token ' + String.fromCharCode(termination)); + } + break; + } else if (ch_i === Jsep.COMMA_CODE) { + // between expressions + this.index++; + separator_count++; + if (separator_count !== args.length) { + // missing argument + if (termination === Jsep.CPAREN_CODE) { + this.throwError('Unexpected token ,'); + } else if (termination === Jsep.CBRACK_CODE) { + for (let arg = args.length; arg < separator_count; arg++) { + args.push(null); + } + } + } + } else if (args.length !== separator_count && separator_count !== 0) { + // NOTE: `&& separator_count !== 0` allows for either all commas, or all spaces as arguments + this.throwError('Expected comma'); + } else { + const node = this.gobbleExpression(); + if (!node || node.type === Jsep.COMPOUND) { + this.throwError('Expected comma'); + } + args.push(node); + } + } + if (!closed) { + this.throwError('Expected ' + String.fromCharCode(termination)); + } + return args; + } + + /** + * Responsible for parsing a group of things within parentheses `()` + * that have no identifier in front (so not a function call) + * This function assumes that it needs to gobble the opening parenthesis + * and then tries to gobble everything within that parenthesis, assuming + * that the next thing it should see is the close parenthesis. If not, + * then the expression probably doesn't have a `)` + * @returns {boolean|jsep.Expression} + */ + gobbleGroup() { + this.index++; + let nodes = this.gobbleExpressions(Jsep.CPAREN_CODE); + if (this.code === Jsep.CPAREN_CODE) { + this.index++; + if (nodes.length === 1) { + return nodes[0]; + } else if (!nodes.length) { + return false; + } else { + return { + type: Jsep.SEQUENCE_EXP, + expressions: nodes + }; + } + } else { + this.throwError('Unclosed ('); + } + } + + /** + * Responsible for parsing Array literals `[1, 2, 3]` + * This function assumes that it needs to gobble the opening bracket + * and then tries to gobble the expressions as arguments. + * @returns {jsep.ArrayExpression} + */ + gobbleArray() { + this.index++; + return { + type: Jsep.ARRAY_EXP, + elements: this.gobbleArguments(Jsep.CBRACK_CODE) + }; + } +} + +// Static fields: +const hooks = new Hooks(); +Object.assign(Jsep, { + hooks, + plugins: new Plugins(Jsep), + // Node Types + // ---------- + // This is the full set of types that any JSEP node can be. + // Store them here to save space when minified + COMPOUND: 'Compound', + SEQUENCE_EXP: 'SequenceExpression', + IDENTIFIER: 'Identifier', + MEMBER_EXP: 'MemberExpression', + LITERAL: 'Literal', + THIS_EXP: 'ThisExpression', + CALL_EXP: 'CallExpression', + UNARY_EXP: 'UnaryExpression', + BINARY_EXP: 'BinaryExpression', + ARRAY_EXP: 'ArrayExpression', + TAB_CODE: 9, + LF_CODE: 10, + CR_CODE: 13, + SPACE_CODE: 32, + PERIOD_CODE: 46, + // '.' + COMMA_CODE: 44, + // ',' + SQUOTE_CODE: 39, + // single quote + DQUOTE_CODE: 34, + // double quotes + OPAREN_CODE: 40, + // ( + CPAREN_CODE: 41, + // ) + OBRACK_CODE: 91, + // [ + CBRACK_CODE: 93, + // ] + QUMARK_CODE: 63, + // ? + SEMCOL_CODE: 59, + // ; + COLON_CODE: 58, + // : + + // Operations + // ---------- + // Use a quickly-accessible map to store all of the unary operators + // Values are set to `1` (it really doesn't matter) + unary_ops: { + '-': 1, + '!': 1, + '~': 1, + '+': 1 + }, + // Also use a map for the binary operations but set their values to their + // binary precedence for quick reference (higher number = higher precedence) + // see [Order of operations](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence) + binary_ops: { + '||': 1, + '&&': 2, + '|': 3, + '^': 4, + '&': 5, + '==': 6, + '!=': 6, + '===': 6, + '!==': 6, + '<': 7, + '>': 7, + '<=': 7, + '>=': 7, + '<<': 8, + '>>': 8, + '>>>': 8, + '+': 9, + '-': 9, + '*': 10, + '/': 10, + '%': 10 + }, + // sets specific binary_ops as right-associative + right_associative: new Set(), + // Additional valid identifier chars, apart from a-z, A-Z and 0-9 (except on the starting char) + additional_identifier_chars: new Set(['$', '_']), + // Literals + // ---------- + // Store the values to return for the various literals we may encounter + literals: { + 'true': true, + 'false': false, + 'null': null + }, + // Except for `this`, which is special. This could be changed to something like `'self'` as well + this_str: 'this' +}); +Jsep.max_unop_len = Jsep.getMaxKeyLen(Jsep.unary_ops); +Jsep.max_binop_len = Jsep.getMaxKeyLen(Jsep.binary_ops); + +// Backward Compatibility: +const jsep = expr => new Jsep(expr).parse(); +const stdClassProps = Object.getOwnPropertyNames(class Test {}); +Object.getOwnPropertyNames(Jsep).filter(prop => !stdClassProps.includes(prop) && jsep[prop] === undefined).forEach(m => { + jsep[m] = Jsep[m]; +}); +jsep.Jsep = Jsep; // allows for const { Jsep } = require('jsep'); + +const CONDITIONAL_EXP = 'ConditionalExpression'; +var ternary = { + name: 'ternary', + init(jsep) { + // Ternary expression: test ? consequent : alternate + jsep.hooks.add('after-expression', function gobbleTernary(env) { + if (env.node && this.code === jsep.QUMARK_CODE) { + this.index++; + const test = env.node; + const consequent = this.gobbleExpression(); + if (!consequent) { + this.throwError('Expected expression'); + } + this.gobbleSpaces(); + if (this.code === jsep.COLON_CODE) { + this.index++; + const alternate = this.gobbleExpression(); + if (!alternate) { + this.throwError('Expected expression'); + } + env.node = { + type: CONDITIONAL_EXP, + test, + consequent, + alternate + }; + + // check for operators of higher priority than ternary (i.e. assignment) + // jsep sets || at 1, and assignment at 0.9, and conditional should be between them + if (test.operator && jsep.binary_ops[test.operator] <= 0.9) { + let newTest = test; + while (newTest.right.operator && jsep.binary_ops[newTest.right.operator] <= 0.9) { + newTest = newTest.right; + } + env.node.test = newTest.right; + newTest.right = env.node; + env.node = test; + } + } else { + this.throwError('Expected :'); + } + } + }); + } +}; + +// Add default plugins: + +jsep.plugins.register(ternary); + +const FSLASH_CODE = 47; // '/' +const BSLASH_CODE = 92; // '\\' + +var index = { + name: 'regex', + init(jsep) { + // Regex literal: /abc123/ig + jsep.hooks.add('gobble-token', function gobbleRegexLiteral(env) { + if (this.code === FSLASH_CODE) { + const patternIndex = ++this.index; + let inCharSet = false; + while (this.index < this.expr.length) { + if (this.code === FSLASH_CODE && !inCharSet) { + const pattern = this.expr.slice(patternIndex, this.index); + let flags = ''; + while (++this.index < this.expr.length) { + const code = this.code; + if (code >= 97 && code <= 122 // a...z + || code >= 65 && code <= 90 // A...Z + || code >= 48 && code <= 57) { + // 0-9 + flags += this.char; + } else { + break; + } + } + let value; + try { + value = new RegExp(pattern, flags); + } catch (e) { + this.throwError(e.message); + } + env.node = { + type: jsep.LITERAL, + value, + raw: this.expr.slice(patternIndex - 1, this.index) + }; + + // allow . [] and () after regex: /regex/.test(a) + env.node = this.gobbleTokenProperty(env.node); + return env.node; + } + if (this.code === jsep.OBRACK_CODE) { + inCharSet = true; + } else if (inCharSet && this.code === jsep.CBRACK_CODE) { + inCharSet = false; + } + this.index += this.code === BSLASH_CODE ? 2 : 1; + } + this.throwError('Unclosed Regex'); + } + }); + } +}; + +const PLUS_CODE = 43; // + +const MINUS_CODE = 45; // - + +const plugin = { + name: 'assignment', + assignmentOperators: new Set(['=', '*=', '**=', '/=', '%=', '+=', '-=', '<<=', '>>=', '>>>=', '&=', '^=', '|=']), + updateOperators: [PLUS_CODE, MINUS_CODE], + assignmentPrecedence: 0.9, + init(jsep) { + const updateNodeTypes = [jsep.IDENTIFIER, jsep.MEMBER_EXP]; + plugin.assignmentOperators.forEach(op => jsep.addBinaryOp(op, plugin.assignmentPrecedence, true)); + jsep.hooks.add('gobble-token', function gobbleUpdatePrefix(env) { + const code = this.code; + if (plugin.updateOperators.some(c => c === code && c === this.expr.charCodeAt(this.index + 1))) { + this.index += 2; + env.node = { + type: 'UpdateExpression', + operator: code === PLUS_CODE ? '++' : '--', + argument: this.gobbleTokenProperty(this.gobbleIdentifier()), + prefix: true + }; + if (!env.node.argument || !updateNodeTypes.includes(env.node.argument.type)) { + this.throwError(`Unexpected ${env.node.operator}`); + } + } + }); + jsep.hooks.add('after-token', function gobbleUpdatePostfix(env) { + if (env.node) { + const code = this.code; + if (plugin.updateOperators.some(c => c === code && c === this.expr.charCodeAt(this.index + 1))) { + if (!updateNodeTypes.includes(env.node.type)) { + this.throwError(`Unexpected ${env.node.operator}`); + } + this.index += 2; + env.node = { + type: 'UpdateExpression', + operator: code === PLUS_CODE ? '++' : '--', + argument: env.node, + prefix: false + }; + } + } + }); + jsep.hooks.add('after-expression', function gobbleAssignment(env) { + if (env.node) { + // Note: Binaries can be chained in a single expression to respect + // operator precedence (i.e. a = b = 1 + 2 + 3) + // Update all binary assignment nodes in the tree + updateBinariesToAssignments(env.node); + } + }); + function updateBinariesToAssignments(node) { + if (plugin.assignmentOperators.has(node.operator)) { + node.type = 'AssignmentExpression'; + updateBinariesToAssignments(node.left); + updateBinariesToAssignments(node.right); + } else if (!node.operator) { + Object.values(node).forEach(val => { + if (val && typeof val === 'object') { + updateBinariesToAssignments(val); + } + }); + } + } + } +}; + +/* eslint-disable no-bitwise */ + +// register plugins +jsep.plugins.register(index, plugin); +const SafeEval = { + /** + * @param {jsep.Expression} ast + * @param {Record<string, any>} subs + */ + evalAst(ast, subs) { + switch (ast.type) { + case 'BinaryExpression': + case 'LogicalExpression': + return SafeEval.evalBinaryExpression(ast, subs); + case 'Compound': + return SafeEval.evalCompound(ast, subs); + case 'ConditionalExpression': + return SafeEval.evalConditionalExpression(ast, subs); + case 'Identifier': + return SafeEval.evalIdentifier(ast, subs); + case 'Literal': + return SafeEval.evalLiteral(ast, subs); + case 'MemberExpression': + return SafeEval.evalMemberExpression(ast, subs); + case 'UnaryExpression': + return SafeEval.evalUnaryExpression(ast, subs); + case 'ArrayExpression': + return SafeEval.evalArrayExpression(ast, subs); + case 'CallExpression': + return SafeEval.evalCallExpression(ast, subs); + case 'AssignmentExpression': + return SafeEval.evalAssignmentExpression(ast, subs); + default: + throw SyntaxError('Unexpected expression', ast); + } + }, + evalBinaryExpression(ast, subs) { + const result = { + '||': (a, b) => a || b(), + '&&': (a, b) => a && b(), + '|': (a, b) => a | b(), + '^': (a, b) => a ^ b(), + '&': (a, b) => a & b(), + // eslint-disable-next-line eqeqeq + '==': (a, b) => a == b(), + // eslint-disable-next-line eqeqeq + '!=': (a, b) => a != b(), + '===': (a, b) => a === b(), + '!==': (a, b) => a !== b(), + '<': (a, b) => a < b(), + '>': (a, b) => a > b(), + '<=': (a, b) => a <= b(), + '>=': (a, b) => a >= b(), + '<<': (a, b) => a << b(), + '>>': (a, b) => a >> b(), + '>>>': (a, b) => a >>> b(), + '+': (a, b) => a + b(), + '-': (a, b) => a - b(), + '*': (a, b) => a * b(), + '/': (a, b) => a / b(), + '%': (a, b) => a % b() + }[ast.operator](SafeEval.evalAst(ast.left, subs), () => SafeEval.evalAst(ast.right, subs)); + return result; + }, + evalCompound(ast, subs) { + let last; + for (let i = 0; i < ast.body.length; i++) { + if (ast.body[i].type === 'Identifier' && ['var', 'let', 'const'].includes(ast.body[i].name) && ast.body[i + 1] && ast.body[i + 1].type === 'AssignmentExpression') { + // var x=2; is detected as + // [{Identifier var}, {AssignmentExpression x=2}] + // eslint-disable-next-line @stylistic/max-len -- Long + // eslint-disable-next-line sonarjs/updated-loop-counter -- Convenient + i += 1; + } + const expr = ast.body[i]; + last = SafeEval.evalAst(expr, subs); + } + return last; + }, + evalConditionalExpression(ast, subs) { + if (SafeEval.evalAst(ast.test, subs)) { + return SafeEval.evalAst(ast.consequent, subs); + } + return SafeEval.evalAst(ast.alternate, subs); + }, + evalIdentifier(ast, subs) { + if (ast.name in subs) { + return subs[ast.name]; + } + throw ReferenceError(`${ast.name} is not defined`); + }, + evalLiteral(ast) { + return ast.value; + }, + evalMemberExpression(ast, subs) { + const prop = ast.computed ? SafeEval.evalAst(ast.property) // `object[property]` + : ast.property.name; // `object.property` property is Identifier + const obj = SafeEval.evalAst(ast.object, subs); + const result = obj[prop]; + if (typeof result === 'function') { + return result.bind(obj); // arrow functions aren't affected by bind. + } + return result; + }, + evalUnaryExpression(ast, subs) { + const result = { + '-': a => -SafeEval.evalAst(a, subs), + '!': a => !SafeEval.evalAst(a, subs), + '~': a => ~SafeEval.evalAst(a, subs), + // eslint-disable-next-line no-implicit-coercion + '+': a => +SafeEval.evalAst(a, subs) + }[ast.operator](ast.argument); + return result; + }, + evalArrayExpression(ast, subs) { + return ast.elements.map(el => SafeEval.evalAst(el, subs)); + }, + evalCallExpression(ast, subs) { + const args = ast.arguments.map(arg => SafeEval.evalAst(arg, subs)); + const func = SafeEval.evalAst(ast.callee, subs); + return func(...args); + }, + evalAssignmentExpression(ast, subs) { + if (ast.left.type !== 'Identifier') { + throw SyntaxError('Invalid left-hand side in assignment'); + } + const id = ast.left.name; + const value = SafeEval.evalAst(ast.right, subs); + subs[id] = value; + return subs[id]; + } +}; + +/** + * A replacement for NodeJS' VM.Script which is also {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP | Content Security Policy} friendly. + */ +class SafeScript { + /** + * @param {string} expr Expression to evaluate + */ + constructor(expr) { + this.code = expr; + this.ast = jsep(this.code); + } + + /** + * @param {object} context Object whose items will be added + * to evaluation + * @returns {EvaluatedResult} Result of evaluated code + */ + runInNewContext(context) { + const keyMap = { + ...context + }; + return SafeEval.evalAst(this.ast, keyMap); + } +} + /* eslint-disable camelcase, unicorn/prefer-string-replace-all, unicorn/prefer-at */ -const { - hasOwnProperty: hasOwnProp -} = Object.prototype; + /** - * @typedef {null|boolean|number|string|PlainObject|GenericArray} JSONObject + * @typedef {null|boolean|number|string|object|GenericArray} JSONObject */ /** @@ -60,16 +1411,16 @@ class NewError extends Error { } /** -* @typedef {PlainObject} ReturnObject +* @typedef {object} ReturnObject * @property {string} path * @property {JSONObject} value -* @property {PlainObject|GenericArray} parent +* @property {object|GenericArray} parent * @property {string} parentProperty */ /** * @callback JSONPathCallback -* @param {string|PlainObject} preferredOutput +* @param {string|object} preferredOutput * @param {"value"|"property"} type * @param {ReturnObject} fullRetObj * @returns {void} @@ -79,7 +1430,7 @@ class NewError extends Error { * @callback OtherTypeCallback * @param {JSONObject} val * @param {string} path -* @param {PlainObject|GenericArray} parent +* @param {object|GenericArray} parent * @param {string} parentPropName * @returns {boolean} */ @@ -100,21 +1451,21 @@ class NewError extends Error { */ /** - * @typedef {typeof import('./jsonpath-browser').SafeScript} EvalClass + * @typedef {typeof SafeScript} EvalClass */ /** - * @typedef {PlainObject} JSONPathOptions + * @typedef {object} JSONPathOptions * @property {JSON} json * @property {string|string[]} path * @property {"value"|"path"|"pointer"|"parent"|"parentProperty"| * "all"} [resultType="value"] * @property {boolean} [flatten=false] * @property {boolean} [wrap=true] - * @property {PlainObject} [sandbox={}] + * @property {object} [sandbox={}] * @property {EvalCallback|EvalClass|'safe'|'native'| * boolean} [eval = 'safe'] - * @property {PlainObject|GenericArray|null} [parent=null] + * @property {object|GenericArray|null} [parent=null] * @property {string|null} [parentProperty=null] * @property {JSONPathCallback} [callback] * @property {OtherTypeCallback} [otherTypeCallback] Defaults to @@ -162,7 +1513,7 @@ function JSONPath(opts, expr, obj, callback, otherTypeCallback) { this.path = opts.path || expr; this.resultType = opts.resultType || 'value'; this.flatten = opts.flatten || false; - this.wrap = hasOwnProp.call(opts, 'wrap') ? opts.wrap : true; + this.wrap = Object.hasOwn(opts, 'wrap') ? opts.wrap : true; this.sandbox = opts.sandbox || {}; this.eval = opts.eval === undefined ? 'safe' : opts.eval; this.ignoreEvalErrors = typeof opts.ignoreEvalErrors === 'undefined' ? false : opts.ignoreEvalErrors; @@ -208,21 +1559,21 @@ JSONPath.prototype.evaluate = function (expr, json, callback, otherTypeCallback) if (!expr.path && expr.path !== '') { throw new TypeError('You must supply a "path" property when providing an object ' + 'argument to JSONPath.evaluate().'); } - if (!hasOwnProp.call(expr, 'json')) { + if (!Object.hasOwn(expr, 'json')) { throw new TypeError('You must supply a "json" property when providing an object ' + 'argument to JSONPath.evaluate().'); } ({ json } = expr); - flatten = hasOwnProp.call(expr, 'flatten') ? expr.flatten : flatten; - this.currResultType = hasOwnProp.call(expr, 'resultType') ? expr.resultType : this.currResultType; - this.currSandbox = hasOwnProp.call(expr, 'sandbox') ? expr.sandbox : this.currSandbox; - wrap = hasOwnProp.call(expr, 'wrap') ? expr.wrap : wrap; - this.currEval = hasOwnProp.call(expr, 'eval') ? expr.eval : this.currEval; - callback = hasOwnProp.call(expr, 'callback') ? expr.callback : callback; - this.currOtherTypeCallback = hasOwnProp.call(expr, 'otherTypeCallback') ? expr.otherTypeCallback : this.currOtherTypeCallback; - currParent = hasOwnProp.call(expr, 'parent') ? expr.parent : currParent; - currParentProperty = hasOwnProp.call(expr, 'parentProperty') ? expr.parentProperty : currParentProperty; + flatten = Object.hasOwn(expr, 'flatten') ? expr.flatten : flatten; + this.currResultType = Object.hasOwn(expr, 'resultType') ? expr.resultType : this.currResultType; + this.currSandbox = Object.hasOwn(expr, 'sandbox') ? expr.sandbox : this.currSandbox; + wrap = Object.hasOwn(expr, 'wrap') ? expr.wrap : wrap; + this.currEval = Object.hasOwn(expr, 'eval') ? expr.eval : this.currEval; + callback = Object.hasOwn(expr, 'callback') ? expr.callback : callback; + this.currOtherTypeCallback = Object.hasOwn(expr, 'otherTypeCallback') ? expr.otherTypeCallback : this.currOtherTypeCallback; + currParent = Object.hasOwn(expr, 'parent') ? expr.parent : currParent; + currParentProperty = Object.hasOwn(expr, 'parentProperty') ? expr.parentProperty : currParentProperty; expr = expr.path; } currParent = currParent || null; @@ -296,7 +1647,7 @@ JSONPath.prototype._handleCallback = function (fullRetObj, callback, type) { * @param {string} expr * @param {JSONObject} val * @param {string} path - * @param {PlainObject|GenericArray} parent + * @param {object|GenericArray} parent * @param {string} parentPropName * @param {JSONPathCallback} callback * @param {boolean} hasArrExpr @@ -341,7 +1692,7 @@ JSONPath.prototype._trace = function (expr, val, path, parent, parentPropName, c ret.push(elems); } } - if ((typeof loc !== 'string' || literalPriority) && val && hasOwnProp.call(val, loc)) { + if ((typeof loc !== 'string' || literalPriority) && val && Object.hasOwn(val, loc)) { // simple case--directly follow property addRet(this._trace(x, val[loc], push(path, loc), val, loc, callback, hasArrExpr)); // eslint-disable-next-line unicorn/prefer-switch -- Part of larger `if` @@ -490,7 +1841,7 @@ JSONPath.prototype._trace = function (expr, val, path, parent, parentPropName, c return retObj; } // `-escaped property - } else if (loc[0] === '`' && val && hasOwnProp.call(val, loc.slice(1))) { + } else if (loc[0] === '`' && val && Object.hasOwn(val, loc.slice(1))) { const locProp = loc.slice(1); addRet(this._trace(x, val[locProp], push(path, locProp), val, locProp, callback, hasArrExpr, true)); } else if (loc.includes(',')) { @@ -500,7 +1851,7 @@ JSONPath.prototype._trace = function (expr, val, path, parent, parentPropName, c addRet(this._trace(unshift(part, x), val, path, parent, parentPropName, callback, true)); } // simple case--directly follow property - } else if (!literalPriority && val && hasOwnProp.call(val, loc)) { + } else if (!literalPriority && val && Object.hasOwn(val, loc)) { addRet(this._trace(x, val[loc], push(path, loc), val, loc, callback, hasArrExpr, true)); } @@ -586,7 +1937,7 @@ JSONPath.prototype._eval = function (code, _v, _vname, path, parent, parentPropN JSONPath.cache[scriptCacheKey] = new this.safeVm.Script(script); } else if (this.currEval === 'native') { JSONPath.cache[scriptCacheKey] = new this.vm.Script(script); - } else if (typeof this.currEval === 'function' && this.currEval.prototype && hasOwnProp.call(this.currEval.prototype, 'runInNewContext')) { + } else if (typeof this.currEval === 'function' && this.currEval.prototype && Object.hasOwn(this.currEval.prototype, 'runInNewContext')) { const CurrEval = this.currEval; JSONPath.cache[scriptCacheKey] = new CurrEval(script); } else if (typeof this.currEval === 'function') { @@ -691,10 +2042,10 @@ JSONPath.toPathArray = function (expr) { cache[expr] = exprList; return cache[expr].concat(); }; +JSONPath.prototype.safeVm = { + Script: SafeScript +}; JSONPath.prototype.vm = vm; -JSONPath.prototype.safeVm = vm; -const SafeScript = vm.Script; exports.JSONPath = JSONPath; -exports.SafeScript = SafeScript;
dist/index-node-esm.js+1383 −31 modified@@ -1,13 +1,1364 @@ import vm from 'vm'; +/** + * @implements {IHooks} + */ +class Hooks { + /** + * @callback HookCallback + * @this {*|Jsep} this + * @param {Jsep} env + * @returns: void + */ + /** + * Adds the given callback to the list of callbacks for the given hook. + * + * The callback will be invoked when the hook it is registered for is run. + * + * One callback function can be registered to multiple hooks and the same hook multiple times. + * + * @param {string|object} name The name of the hook, or an object of callbacks keyed by name + * @param {HookCallback|boolean} callback The callback function which is given environment variables. + * @param {?boolean} [first=false] Will add the hook to the top of the list (defaults to the bottom) + * @public + */ + add(name, callback, first) { + if (typeof arguments[0] != 'string') { + // Multiple hook callbacks, keyed by name + for (let name in arguments[0]) { + this.add(name, arguments[0][name], arguments[1]); + } + } else { + (Array.isArray(name) ? name : [name]).forEach(function (name) { + this[name] = this[name] || []; + if (callback) { + this[name][first ? 'unshift' : 'push'](callback); + } + }, this); + } + } + + /** + * Runs a hook invoking all registered callbacks with the given environment variables. + * + * Callbacks will be invoked synchronously and in the order in which they were registered. + * + * @param {string} name The name of the hook. + * @param {Object<string, any>} env The environment variables of the hook passed to all callbacks registered. + * @public + */ + run(name, env) { + this[name] = this[name] || []; + this[name].forEach(function (callback) { + callback.call(env && env.context ? env.context : env, env); + }); + } +} + +/** + * @implements {IPlugins} + */ +class Plugins { + constructor(jsep) { + this.jsep = jsep; + this.registered = {}; + } + + /** + * @callback PluginSetup + * @this {Jsep} jsep + * @returns: void + */ + /** + * Adds the given plugin(s) to the registry + * + * @param {object} plugins + * @param {string} plugins.name The name of the plugin + * @param {PluginSetup} plugins.init The init function + * @public + */ + register(...plugins) { + plugins.forEach(plugin => { + if (typeof plugin !== 'object' || !plugin.name || !plugin.init) { + throw new Error('Invalid JSEP plugin format'); + } + if (this.registered[plugin.name]) { + // already registered. Ignore. + return; + } + plugin.init(this.jsep); + this.registered[plugin.name] = plugin; + }); + } +} + +// JavaScript Expression Parser (JSEP) 1.3.9 + +class Jsep { + /** + * @returns {string} + */ + static get version() { + // To be filled in by the template + return '1.3.9'; + } + + /** + * @returns {string} + */ + static toString() { + return 'JavaScript Expression Parser (JSEP) v' + Jsep.version; + } + // ==================== CONFIG ================================ + /** + * @method addUnaryOp + * @param {string} op_name The name of the unary op to add + * @returns {Jsep} + */ + static addUnaryOp(op_name) { + Jsep.max_unop_len = Math.max(op_name.length, Jsep.max_unop_len); + Jsep.unary_ops[op_name] = 1; + return Jsep; + } + + /** + * @method jsep.addBinaryOp + * @param {string} op_name The name of the binary op to add + * @param {number} precedence The precedence of the binary op (can be a float). Higher number = higher precedence + * @param {boolean} [isRightAssociative=false] whether operator is right-associative + * @returns {Jsep} + */ + static addBinaryOp(op_name, precedence, isRightAssociative) { + Jsep.max_binop_len = Math.max(op_name.length, Jsep.max_binop_len); + Jsep.binary_ops[op_name] = precedence; + if (isRightAssociative) { + Jsep.right_associative.add(op_name); + } else { + Jsep.right_associative.delete(op_name); + } + return Jsep; + } + + /** + * @method addIdentifierChar + * @param {string} char The additional character to treat as a valid part of an identifier + * @returns {Jsep} + */ + static addIdentifierChar(char) { + Jsep.additional_identifier_chars.add(char); + return Jsep; + } + + /** + * @method addLiteral + * @param {string} literal_name The name of the literal to add + * @param {*} literal_value The value of the literal + * @returns {Jsep} + */ + static addLiteral(literal_name, literal_value) { + Jsep.literals[literal_name] = literal_value; + return Jsep; + } + + /** + * @method removeUnaryOp + * @param {string} op_name The name of the unary op to remove + * @returns {Jsep} + */ + static removeUnaryOp(op_name) { + delete Jsep.unary_ops[op_name]; + if (op_name.length === Jsep.max_unop_len) { + Jsep.max_unop_len = Jsep.getMaxKeyLen(Jsep.unary_ops); + } + return Jsep; + } + + /** + * @method removeAllUnaryOps + * @returns {Jsep} + */ + static removeAllUnaryOps() { + Jsep.unary_ops = {}; + Jsep.max_unop_len = 0; + return Jsep; + } + + /** + * @method removeIdentifierChar + * @param {string} char The additional character to stop treating as a valid part of an identifier + * @returns {Jsep} + */ + static removeIdentifierChar(char) { + Jsep.additional_identifier_chars.delete(char); + return Jsep; + } + + /** + * @method removeBinaryOp + * @param {string} op_name The name of the binary op to remove + * @returns {Jsep} + */ + static removeBinaryOp(op_name) { + delete Jsep.binary_ops[op_name]; + if (op_name.length === Jsep.max_binop_len) { + Jsep.max_binop_len = Jsep.getMaxKeyLen(Jsep.binary_ops); + } + Jsep.right_associative.delete(op_name); + return Jsep; + } + + /** + * @method removeAllBinaryOps + * @returns {Jsep} + */ + static removeAllBinaryOps() { + Jsep.binary_ops = {}; + Jsep.max_binop_len = 0; + return Jsep; + } + + /** + * @method removeLiteral + * @param {string} literal_name The name of the literal to remove + * @returns {Jsep} + */ + static removeLiteral(literal_name) { + delete Jsep.literals[literal_name]; + return Jsep; + } + + /** + * @method removeAllLiterals + * @returns {Jsep} + */ + static removeAllLiterals() { + Jsep.literals = {}; + return Jsep; + } + // ==================== END CONFIG ============================ + + /** + * @returns {string} + */ + get char() { + return this.expr.charAt(this.index); + } + + /** + * @returns {number} + */ + get code() { + return this.expr.charCodeAt(this.index); + } + /** + * @param {string} expr a string with the passed in express + * @returns Jsep + */ + constructor(expr) { + // `index` stores the character number we are currently at + // All of the gobbles below will modify `index` as we move along + this.expr = expr; + this.index = 0; + } + + /** + * static top-level parser + * @returns {jsep.Expression} + */ + static parse(expr) { + return new Jsep(expr).parse(); + } + + /** + * Get the longest key length of any object + * @param {object} obj + * @returns {number} + */ + static getMaxKeyLen(obj) { + return Math.max(0, ...Object.keys(obj).map(k => k.length)); + } + + /** + * `ch` is a character code in the next three functions + * @param {number} ch + * @returns {boolean} + */ + static isDecimalDigit(ch) { + return ch >= 48 && ch <= 57; // 0...9 + } + + /** + * Returns the precedence of a binary operator or `0` if it isn't a binary operator. Can be float. + * @param {string} op_val + * @returns {number} + */ + static binaryPrecedence(op_val) { + return Jsep.binary_ops[op_val] || 0; + } + + /** + * Looks for start of identifier + * @param {number} ch + * @returns {boolean} + */ + static isIdentifierStart(ch) { + return ch >= 65 && ch <= 90 || + // A...Z + ch >= 97 && ch <= 122 || + // a...z + ch >= 128 && !Jsep.binary_ops[String.fromCharCode(ch)] || + // any non-ASCII that is not an operator + Jsep.additional_identifier_chars.has(String.fromCharCode(ch)); // additional characters + } + + /** + * @param {number} ch + * @returns {boolean} + */ + static isIdentifierPart(ch) { + return Jsep.isIdentifierStart(ch) || Jsep.isDecimalDigit(ch); + } + + /** + * throw error at index of the expression + * @param {string} message + * @throws + */ + throwError(message) { + const error = new Error(message + ' at character ' + this.index); + error.index = this.index; + error.description = message; + throw error; + } + + /** + * Run a given hook + * @param {string} name + * @param {jsep.Expression|false} [node] + * @returns {?jsep.Expression} + */ + runHook(name, node) { + if (Jsep.hooks[name]) { + const env = { + context: this, + node + }; + Jsep.hooks.run(name, env); + return env.node; + } + return node; + } + + /** + * Runs a given hook until one returns a node + * @param {string} name + * @returns {?jsep.Expression} + */ + searchHook(name) { + if (Jsep.hooks[name]) { + const env = { + context: this + }; + Jsep.hooks[name].find(function (callback) { + callback.call(env.context, env); + return env.node; + }); + return env.node; + } + } + + /** + * Push `index` up to the next non-space character + */ + gobbleSpaces() { + let ch = this.code; + // Whitespace + while (ch === Jsep.SPACE_CODE || ch === Jsep.TAB_CODE || ch === Jsep.LF_CODE || ch === Jsep.CR_CODE) { + ch = this.expr.charCodeAt(++this.index); + } + this.runHook('gobble-spaces'); + } + + /** + * Top-level method to parse all expressions and returns compound or single node + * @returns {jsep.Expression} + */ + parse() { + this.runHook('before-all'); + const nodes = this.gobbleExpressions(); + + // If there's only one expression just try returning the expression + const node = nodes.length === 1 ? nodes[0] : { + type: Jsep.COMPOUND, + body: nodes + }; + return this.runHook('after-all', node); + } + + /** + * top-level parser (but can be reused within as well) + * @param {number} [untilICode] + * @returns {jsep.Expression[]} + */ + gobbleExpressions(untilICode) { + let nodes = [], + ch_i, + node; + while (this.index < this.expr.length) { + ch_i = this.code; + + // Expressions can be separated by semicolons, commas, or just inferred without any + // separators + if (ch_i === Jsep.SEMCOL_CODE || ch_i === Jsep.COMMA_CODE) { + this.index++; // ignore separators + } else { + // Try to gobble each expression individually + if (node = this.gobbleExpression()) { + nodes.push(node); + // If we weren't able to find a binary expression and are out of room, then + // the expression passed in probably has too much + } else if (this.index < this.expr.length) { + if (ch_i === untilICode) { + break; + } + this.throwError('Unexpected "' + this.char + '"'); + } + } + } + return nodes; + } + + /** + * The main parsing function. + * @returns {?jsep.Expression} + */ + gobbleExpression() { + const node = this.searchHook('gobble-expression') || this.gobbleBinaryExpression(); + this.gobbleSpaces(); + return this.runHook('after-expression', node); + } + + /** + * Search for the operation portion of the string (e.g. `+`, `===`) + * Start by taking the longest possible binary operations (3 characters: `===`, `!==`, `>>>`) + * and move down from 3 to 2 to 1 character until a matching binary operation is found + * then, return that binary operation + * @returns {string|boolean} + */ + gobbleBinaryOp() { + this.gobbleSpaces(); + let to_check = this.expr.substr(this.index, Jsep.max_binop_len); + let tc_len = to_check.length; + while (tc_len > 0) { + // Don't accept a binary op when it is an identifier. + // Binary ops that start with a identifier-valid character must be followed + // by a non identifier-part valid character + if (Jsep.binary_ops.hasOwnProperty(to_check) && (!Jsep.isIdentifierStart(this.code) || this.index + to_check.length < this.expr.length && !Jsep.isIdentifierPart(this.expr.charCodeAt(this.index + to_check.length)))) { + this.index += tc_len; + return to_check; + } + to_check = to_check.substr(0, --tc_len); + } + return false; + } + + /** + * This function is responsible for gobbling an individual expression, + * e.g. `1`, `1+2`, `a+(b*2)-Math.sqrt(2)` + * @returns {?jsep.BinaryExpression} + */ + gobbleBinaryExpression() { + let node, biop, prec, stack, biop_info, left, right, i, cur_biop; + + // First, try to get the leftmost thing + // Then, check to see if there's a binary operator operating on that leftmost thing + // Don't gobbleBinaryOp without a left-hand-side + left = this.gobbleToken(); + if (!left) { + return left; + } + biop = this.gobbleBinaryOp(); + + // If there wasn't a binary operator, just return the leftmost node + if (!biop) { + return left; + } + + // Otherwise, we need to start a stack to properly place the binary operations in their + // precedence structure + biop_info = { + value: biop, + prec: Jsep.binaryPrecedence(biop), + right_a: Jsep.right_associative.has(biop) + }; + right = this.gobbleToken(); + if (!right) { + this.throwError("Expected expression after " + biop); + } + stack = [left, biop_info, right]; + + // Properly deal with precedence using [recursive descent](http://www.engr.mun.ca/~theo/Misc/exp_parsing.htm) + while (biop = this.gobbleBinaryOp()) { + prec = Jsep.binaryPrecedence(biop); + if (prec === 0) { + this.index -= biop.length; + break; + } + biop_info = { + value: biop, + prec, + right_a: Jsep.right_associative.has(biop) + }; + cur_biop = biop; + + // Reduce: make a binary expression from the three topmost entries. + const comparePrev = prev => biop_info.right_a && prev.right_a ? prec > prev.prec : prec <= prev.prec; + while (stack.length > 2 && comparePrev(stack[stack.length - 2])) { + right = stack.pop(); + biop = stack.pop().value; + left = stack.pop(); + node = { + type: Jsep.BINARY_EXP, + operator: biop, + left, + right + }; + stack.push(node); + } + node = this.gobbleToken(); + if (!node) { + this.throwError("Expected expression after " + cur_biop); + } + stack.push(biop_info, node); + } + i = stack.length - 1; + node = stack[i]; + while (i > 1) { + node = { + type: Jsep.BINARY_EXP, + operator: stack[i - 1].value, + left: stack[i - 2], + right: node + }; + i -= 2; + } + return node; + } + + /** + * An individual part of a binary expression: + * e.g. `foo.bar(baz)`, `1`, `"abc"`, `(a % 2)` (because it's in parenthesis) + * @returns {boolean|jsep.Expression} + */ + gobbleToken() { + let ch, to_check, tc_len, node; + this.gobbleSpaces(); + node = this.searchHook('gobble-token'); + if (node) { + return this.runHook('after-token', node); + } + ch = this.code; + if (Jsep.isDecimalDigit(ch) || ch === Jsep.PERIOD_CODE) { + // Char code 46 is a dot `.` which can start off a numeric literal + return this.gobbleNumericLiteral(); + } + if (ch === Jsep.SQUOTE_CODE || ch === Jsep.DQUOTE_CODE) { + // Single or double quotes + node = this.gobbleStringLiteral(); + } else if (ch === Jsep.OBRACK_CODE) { + node = this.gobbleArray(); + } else { + to_check = this.expr.substr(this.index, Jsep.max_unop_len); + tc_len = to_check.length; + while (tc_len > 0) { + // Don't accept an unary op when it is an identifier. + // Unary ops that start with a identifier-valid character must be followed + // by a non identifier-part valid character + if (Jsep.unary_ops.hasOwnProperty(to_check) && (!Jsep.isIdentifierStart(this.code) || this.index + to_check.length < this.expr.length && !Jsep.isIdentifierPart(this.expr.charCodeAt(this.index + to_check.length)))) { + this.index += tc_len; + const argument = this.gobbleToken(); + if (!argument) { + this.throwError('missing unaryOp argument'); + } + return this.runHook('after-token', { + type: Jsep.UNARY_EXP, + operator: to_check, + argument, + prefix: true + }); + } + to_check = to_check.substr(0, --tc_len); + } + if (Jsep.isIdentifierStart(ch)) { + node = this.gobbleIdentifier(); + if (Jsep.literals.hasOwnProperty(node.name)) { + node = { + type: Jsep.LITERAL, + value: Jsep.literals[node.name], + raw: node.name + }; + } else if (node.name === Jsep.this_str) { + node = { + type: Jsep.THIS_EXP + }; + } + } else if (ch === Jsep.OPAREN_CODE) { + // open parenthesis + node = this.gobbleGroup(); + } + } + if (!node) { + return this.runHook('after-token', false); + } + node = this.gobbleTokenProperty(node); + return this.runHook('after-token', node); + } + + /** + * Gobble properties of of identifiers/strings/arrays/groups. + * e.g. `foo`, `bar.baz`, `foo['bar'].baz` + * It also gobbles function calls: + * e.g. `Math.acos(obj.angle)` + * @param {jsep.Expression} node + * @returns {jsep.Expression} + */ + gobbleTokenProperty(node) { + this.gobbleSpaces(); + let ch = this.code; + while (ch === Jsep.PERIOD_CODE || ch === Jsep.OBRACK_CODE || ch === Jsep.OPAREN_CODE || ch === Jsep.QUMARK_CODE) { + let optional; + if (ch === Jsep.QUMARK_CODE) { + if (this.expr.charCodeAt(this.index + 1) !== Jsep.PERIOD_CODE) { + break; + } + optional = true; + this.index += 2; + this.gobbleSpaces(); + ch = this.code; + } + this.index++; + if (ch === Jsep.OBRACK_CODE) { + node = { + type: Jsep.MEMBER_EXP, + computed: true, + object: node, + property: this.gobbleExpression() + }; + if (!node.property) { + this.throwError('Unexpected "' + this.char + '"'); + } + this.gobbleSpaces(); + ch = this.code; + if (ch !== Jsep.CBRACK_CODE) { + this.throwError('Unclosed ['); + } + this.index++; + } else if (ch === Jsep.OPAREN_CODE) { + // A function call is being made; gobble all the arguments + node = { + type: Jsep.CALL_EXP, + 'arguments': this.gobbleArguments(Jsep.CPAREN_CODE), + callee: node + }; + } else if (ch === Jsep.PERIOD_CODE || optional) { + if (optional) { + this.index--; + } + this.gobbleSpaces(); + node = { + type: Jsep.MEMBER_EXP, + computed: false, + object: node, + property: this.gobbleIdentifier() + }; + } + if (optional) { + node.optional = true; + } // else leave undefined for compatibility with esprima + + this.gobbleSpaces(); + ch = this.code; + } + return node; + } + + /** + * Parse simple numeric literals: `12`, `3.4`, `.5`. Do this by using a string to + * keep track of everything in the numeric literal and then calling `parseFloat` on that string + * @returns {jsep.Literal} + */ + gobbleNumericLiteral() { + let number = '', + ch, + chCode; + while (Jsep.isDecimalDigit(this.code)) { + number += this.expr.charAt(this.index++); + } + if (this.code === Jsep.PERIOD_CODE) { + // can start with a decimal marker + number += this.expr.charAt(this.index++); + while (Jsep.isDecimalDigit(this.code)) { + number += this.expr.charAt(this.index++); + } + } + ch = this.char; + if (ch === 'e' || ch === 'E') { + // exponent marker + number += this.expr.charAt(this.index++); + ch = this.char; + if (ch === '+' || ch === '-') { + // exponent sign + number += this.expr.charAt(this.index++); + } + while (Jsep.isDecimalDigit(this.code)) { + // exponent itself + number += this.expr.charAt(this.index++); + } + if (!Jsep.isDecimalDigit(this.expr.charCodeAt(this.index - 1))) { + this.throwError('Expected exponent (' + number + this.char + ')'); + } + } + chCode = this.code; + + // Check to make sure this isn't a variable name that start with a number (123abc) + if (Jsep.isIdentifierStart(chCode)) { + this.throwError('Variable names cannot start with a number (' + number + this.char + ')'); + } else if (chCode === Jsep.PERIOD_CODE || number.length === 1 && number.charCodeAt(0) === Jsep.PERIOD_CODE) { + this.throwError('Unexpected period'); + } + return { + type: Jsep.LITERAL, + value: parseFloat(number), + raw: number + }; + } + + /** + * Parses a string literal, staring with single or double quotes with basic support for escape codes + * e.g. `"hello world"`, `'this is\nJSEP'` + * @returns {jsep.Literal} + */ + gobbleStringLiteral() { + let str = ''; + const startIndex = this.index; + const quote = this.expr.charAt(this.index++); + let closed = false; + while (this.index < this.expr.length) { + let ch = this.expr.charAt(this.index++); + if (ch === quote) { + closed = true; + break; + } else if (ch === '\\') { + // Check for all of the common escape codes + ch = this.expr.charAt(this.index++); + switch (ch) { + case 'n': + str += '\n'; + break; + case 'r': + str += '\r'; + break; + case 't': + str += '\t'; + break; + case 'b': + str += '\b'; + break; + case 'f': + str += '\f'; + break; + case 'v': + str += '\x0B'; + break; + default: + str += ch; + } + } else { + str += ch; + } + } + if (!closed) { + this.throwError('Unclosed quote after "' + str + '"'); + } + return { + type: Jsep.LITERAL, + value: str, + raw: this.expr.substring(startIndex, this.index) + }; + } + + /** + * Gobbles only identifiers + * e.g.: `foo`, `_value`, `$x1` + * Also, this function checks if that identifier is a literal: + * (e.g. `true`, `false`, `null`) or `this` + * @returns {jsep.Identifier} + */ + gobbleIdentifier() { + let ch = this.code, + start = this.index; + if (Jsep.isIdentifierStart(ch)) { + this.index++; + } else { + this.throwError('Unexpected ' + this.char); + } + while (this.index < this.expr.length) { + ch = this.code; + if (Jsep.isIdentifierPart(ch)) { + this.index++; + } else { + break; + } + } + return { + type: Jsep.IDENTIFIER, + name: this.expr.slice(start, this.index) + }; + } + + /** + * Gobbles a list of arguments within the context of a function call + * or array literal. This function also assumes that the opening character + * `(` or `[` has already been gobbled, and gobbles expressions and commas + * until the terminator character `)` or `]` is encountered. + * e.g. `foo(bar, baz)`, `my_func()`, or `[bar, baz]` + * @param {number} termination + * @returns {jsep.Expression[]} + */ + gobbleArguments(termination) { + const args = []; + let closed = false; + let separator_count = 0; + while (this.index < this.expr.length) { + this.gobbleSpaces(); + let ch_i = this.code; + if (ch_i === termination) { + // done parsing + closed = true; + this.index++; + if (termination === Jsep.CPAREN_CODE && separator_count && separator_count >= args.length) { + this.throwError('Unexpected token ' + String.fromCharCode(termination)); + } + break; + } else if (ch_i === Jsep.COMMA_CODE) { + // between expressions + this.index++; + separator_count++; + if (separator_count !== args.length) { + // missing argument + if (termination === Jsep.CPAREN_CODE) { + this.throwError('Unexpected token ,'); + } else if (termination === Jsep.CBRACK_CODE) { + for (let arg = args.length; arg < separator_count; arg++) { + args.push(null); + } + } + } + } else if (args.length !== separator_count && separator_count !== 0) { + // NOTE: `&& separator_count !== 0` allows for either all commas, or all spaces as arguments + this.throwError('Expected comma'); + } else { + const node = this.gobbleExpression(); + if (!node || node.type === Jsep.COMPOUND) { + this.throwError('Expected comma'); + } + args.push(node); + } + } + if (!closed) { + this.throwError('Expected ' + String.fromCharCode(termination)); + } + return args; + } + + /** + * Responsible for parsing a group of things within parentheses `()` + * that have no identifier in front (so not a function call) + * This function assumes that it needs to gobble the opening parenthesis + * and then tries to gobble everything within that parenthesis, assuming + * that the next thing it should see is the close parenthesis. If not, + * then the expression probably doesn't have a `)` + * @returns {boolean|jsep.Expression} + */ + gobbleGroup() { + this.index++; + let nodes = this.gobbleExpressions(Jsep.CPAREN_CODE); + if (this.code === Jsep.CPAREN_CODE) { + this.index++; + if (nodes.length === 1) { + return nodes[0]; + } else if (!nodes.length) { + return false; + } else { + return { + type: Jsep.SEQUENCE_EXP, + expressions: nodes + }; + } + } else { + this.throwError('Unclosed ('); + } + } + + /** + * Responsible for parsing Array literals `[1, 2, 3]` + * This function assumes that it needs to gobble the opening bracket + * and then tries to gobble the expressions as arguments. + * @returns {jsep.ArrayExpression} + */ + gobbleArray() { + this.index++; + return { + type: Jsep.ARRAY_EXP, + elements: this.gobbleArguments(Jsep.CBRACK_CODE) + }; + } +} + +// Static fields: +const hooks = new Hooks(); +Object.assign(Jsep, { + hooks, + plugins: new Plugins(Jsep), + // Node Types + // ---------- + // This is the full set of types that any JSEP node can be. + // Store them here to save space when minified + COMPOUND: 'Compound', + SEQUENCE_EXP: 'SequenceExpression', + IDENTIFIER: 'Identifier', + MEMBER_EXP: 'MemberExpression', + LITERAL: 'Literal', + THIS_EXP: 'ThisExpression', + CALL_EXP: 'CallExpression', + UNARY_EXP: 'UnaryExpression', + BINARY_EXP: 'BinaryExpression', + ARRAY_EXP: 'ArrayExpression', + TAB_CODE: 9, + LF_CODE: 10, + CR_CODE: 13, + SPACE_CODE: 32, + PERIOD_CODE: 46, + // '.' + COMMA_CODE: 44, + // ',' + SQUOTE_CODE: 39, + // single quote + DQUOTE_CODE: 34, + // double quotes + OPAREN_CODE: 40, + // ( + CPAREN_CODE: 41, + // ) + OBRACK_CODE: 91, + // [ + CBRACK_CODE: 93, + // ] + QUMARK_CODE: 63, + // ? + SEMCOL_CODE: 59, + // ; + COLON_CODE: 58, + // : + + // Operations + // ---------- + // Use a quickly-accessible map to store all of the unary operators + // Values are set to `1` (it really doesn't matter) + unary_ops: { + '-': 1, + '!': 1, + '~': 1, + '+': 1 + }, + // Also use a map for the binary operations but set their values to their + // binary precedence for quick reference (higher number = higher precedence) + // see [Order of operations](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence) + binary_ops: { + '||': 1, + '&&': 2, + '|': 3, + '^': 4, + '&': 5, + '==': 6, + '!=': 6, + '===': 6, + '!==': 6, + '<': 7, + '>': 7, + '<=': 7, + '>=': 7, + '<<': 8, + '>>': 8, + '>>>': 8, + '+': 9, + '-': 9, + '*': 10, + '/': 10, + '%': 10 + }, + // sets specific binary_ops as right-associative + right_associative: new Set(), + // Additional valid identifier chars, apart from a-z, A-Z and 0-9 (except on the starting char) + additional_identifier_chars: new Set(['$', '_']), + // Literals + // ---------- + // Store the values to return for the various literals we may encounter + literals: { + 'true': true, + 'false': false, + 'null': null + }, + // Except for `this`, which is special. This could be changed to something like `'self'` as well + this_str: 'this' +}); +Jsep.max_unop_len = Jsep.getMaxKeyLen(Jsep.unary_ops); +Jsep.max_binop_len = Jsep.getMaxKeyLen(Jsep.binary_ops); + +// Backward Compatibility: +const jsep = expr => new Jsep(expr).parse(); +const stdClassProps = Object.getOwnPropertyNames(class Test {}); +Object.getOwnPropertyNames(Jsep).filter(prop => !stdClassProps.includes(prop) && jsep[prop] === undefined).forEach(m => { + jsep[m] = Jsep[m]; +}); +jsep.Jsep = Jsep; // allows for const { Jsep } = require('jsep'); + +const CONDITIONAL_EXP = 'ConditionalExpression'; +var ternary = { + name: 'ternary', + init(jsep) { + // Ternary expression: test ? consequent : alternate + jsep.hooks.add('after-expression', function gobbleTernary(env) { + if (env.node && this.code === jsep.QUMARK_CODE) { + this.index++; + const test = env.node; + const consequent = this.gobbleExpression(); + if (!consequent) { + this.throwError('Expected expression'); + } + this.gobbleSpaces(); + if (this.code === jsep.COLON_CODE) { + this.index++; + const alternate = this.gobbleExpression(); + if (!alternate) { + this.throwError('Expected expression'); + } + env.node = { + type: CONDITIONAL_EXP, + test, + consequent, + alternate + }; + + // check for operators of higher priority than ternary (i.e. assignment) + // jsep sets || at 1, and assignment at 0.9, and conditional should be between them + if (test.operator && jsep.binary_ops[test.operator] <= 0.9) { + let newTest = test; + while (newTest.right.operator && jsep.binary_ops[newTest.right.operator] <= 0.9) { + newTest = newTest.right; + } + env.node.test = newTest.right; + newTest.right = env.node; + env.node = test; + } + } else { + this.throwError('Expected :'); + } + } + }); + } +}; + +// Add default plugins: + +jsep.plugins.register(ternary); + +const FSLASH_CODE = 47; // '/' +const BSLASH_CODE = 92; // '\\' + +var index = { + name: 'regex', + init(jsep) { + // Regex literal: /abc123/ig + jsep.hooks.add('gobble-token', function gobbleRegexLiteral(env) { + if (this.code === FSLASH_CODE) { + const patternIndex = ++this.index; + let inCharSet = false; + while (this.index < this.expr.length) { + if (this.code === FSLASH_CODE && !inCharSet) { + const pattern = this.expr.slice(patternIndex, this.index); + let flags = ''; + while (++this.index < this.expr.length) { + const code = this.code; + if (code >= 97 && code <= 122 // a...z + || code >= 65 && code <= 90 // A...Z + || code >= 48 && code <= 57) { + // 0-9 + flags += this.char; + } else { + break; + } + } + let value; + try { + value = new RegExp(pattern, flags); + } catch (e) { + this.throwError(e.message); + } + env.node = { + type: jsep.LITERAL, + value, + raw: this.expr.slice(patternIndex - 1, this.index) + }; + + // allow . [] and () after regex: /regex/.test(a) + env.node = this.gobbleTokenProperty(env.node); + return env.node; + } + if (this.code === jsep.OBRACK_CODE) { + inCharSet = true; + } else if (inCharSet && this.code === jsep.CBRACK_CODE) { + inCharSet = false; + } + this.index += this.code === BSLASH_CODE ? 2 : 1; + } + this.throwError('Unclosed Regex'); + } + }); + } +}; + +const PLUS_CODE = 43; // + +const MINUS_CODE = 45; // - + +const plugin = { + name: 'assignment', + assignmentOperators: new Set(['=', '*=', '**=', '/=', '%=', '+=', '-=', '<<=', '>>=', '>>>=', '&=', '^=', '|=']), + updateOperators: [PLUS_CODE, MINUS_CODE], + assignmentPrecedence: 0.9, + init(jsep) { + const updateNodeTypes = [jsep.IDENTIFIER, jsep.MEMBER_EXP]; + plugin.assignmentOperators.forEach(op => jsep.addBinaryOp(op, plugin.assignmentPrecedence, true)); + jsep.hooks.add('gobble-token', function gobbleUpdatePrefix(env) { + const code = this.code; + if (plugin.updateOperators.some(c => c === code && c === this.expr.charCodeAt(this.index + 1))) { + this.index += 2; + env.node = { + type: 'UpdateExpression', + operator: code === PLUS_CODE ? '++' : '--', + argument: this.gobbleTokenProperty(this.gobbleIdentifier()), + prefix: true + }; + if (!env.node.argument || !updateNodeTypes.includes(env.node.argument.type)) { + this.throwError(`Unexpected ${env.node.operator}`); + } + } + }); + jsep.hooks.add('after-token', function gobbleUpdatePostfix(env) { + if (env.node) { + const code = this.code; + if (plugin.updateOperators.some(c => c === code && c === this.expr.charCodeAt(this.index + 1))) { + if (!updateNodeTypes.includes(env.node.type)) { + this.throwError(`Unexpected ${env.node.operator}`); + } + this.index += 2; + env.node = { + type: 'UpdateExpression', + operator: code === PLUS_CODE ? '++' : '--', + argument: env.node, + prefix: false + }; + } + } + }); + jsep.hooks.add('after-expression', function gobbleAssignment(env) { + if (env.node) { + // Note: Binaries can be chained in a single expression to respect + // operator precedence (i.e. a = b = 1 + 2 + 3) + // Update all binary assignment nodes in the tree + updateBinariesToAssignments(env.node); + } + }); + function updateBinariesToAssignments(node) { + if (plugin.assignmentOperators.has(node.operator)) { + node.type = 'AssignmentExpression'; + updateBinariesToAssignments(node.left); + updateBinariesToAssignments(node.right); + } else if (!node.operator) { + Object.values(node).forEach(val => { + if (val && typeof val === 'object') { + updateBinariesToAssignments(val); + } + }); + } + } + } +}; + +/* eslint-disable no-bitwise */ + +// register plugins +jsep.plugins.register(index, plugin); +const SafeEval = { + /** + * @param {jsep.Expression} ast + * @param {Record<string, any>} subs + */ + evalAst(ast, subs) { + switch (ast.type) { + case 'BinaryExpression': + case 'LogicalExpression': + return SafeEval.evalBinaryExpression(ast, subs); + case 'Compound': + return SafeEval.evalCompound(ast, subs); + case 'ConditionalExpression': + return SafeEval.evalConditionalExpression(ast, subs); + case 'Identifier': + return SafeEval.evalIdentifier(ast, subs); + case 'Literal': + return SafeEval.evalLiteral(ast, subs); + case 'MemberExpression': + return SafeEval.evalMemberExpression(ast, subs); + case 'UnaryExpression': + return SafeEval.evalUnaryExpression(ast, subs); + case 'ArrayExpression': + return SafeEval.evalArrayExpression(ast, subs); + case 'CallExpression': + return SafeEval.evalCallExpression(ast, subs); + case 'AssignmentExpression': + return SafeEval.evalAssignmentExpression(ast, subs); + default: + throw SyntaxError('Unexpected expression', ast); + } + }, + evalBinaryExpression(ast, subs) { + const result = { + '||': (a, b) => a || b(), + '&&': (a, b) => a && b(), + '|': (a, b) => a | b(), + '^': (a, b) => a ^ b(), + '&': (a, b) => a & b(), + // eslint-disable-next-line eqeqeq + '==': (a, b) => a == b(), + // eslint-disable-next-line eqeqeq + '!=': (a, b) => a != b(), + '===': (a, b) => a === b(), + '!==': (a, b) => a !== b(), + '<': (a, b) => a < b(), + '>': (a, b) => a > b(), + '<=': (a, b) => a <= b(), + '>=': (a, b) => a >= b(), + '<<': (a, b) => a << b(), + '>>': (a, b) => a >> b(), + '>>>': (a, b) => a >>> b(), + '+': (a, b) => a + b(), + '-': (a, b) => a - b(), + '*': (a, b) => a * b(), + '/': (a, b) => a / b(), + '%': (a, b) => a % b() + }[ast.operator](SafeEval.evalAst(ast.left, subs), () => SafeEval.evalAst(ast.right, subs)); + return result; + }, + evalCompound(ast, subs) { + let last; + for (let i = 0; i < ast.body.length; i++) { + if (ast.body[i].type === 'Identifier' && ['var', 'let', 'const'].includes(ast.body[i].name) && ast.body[i + 1] && ast.body[i + 1].type === 'AssignmentExpression') { + // var x=2; is detected as + // [{Identifier var}, {AssignmentExpression x=2}] + // eslint-disable-next-line @stylistic/max-len -- Long + // eslint-disable-next-line sonarjs/updated-loop-counter -- Convenient + i += 1; + } + const expr = ast.body[i]; + last = SafeEval.evalAst(expr, subs); + } + return last; + }, + evalConditionalExpression(ast, subs) { + if (SafeEval.evalAst(ast.test, subs)) { + return SafeEval.evalAst(ast.consequent, subs); + } + return SafeEval.evalAst(ast.alternate, subs); + }, + evalIdentifier(ast, subs) { + if (ast.name in subs) { + return subs[ast.name]; + } + throw ReferenceError(`${ast.name} is not defined`); + }, + evalLiteral(ast) { + return ast.value; + }, + evalMemberExpression(ast, subs) { + const prop = ast.computed ? SafeEval.evalAst(ast.property) // `object[property]` + : ast.property.name; // `object.property` property is Identifier + const obj = SafeEval.evalAst(ast.object, subs); + const result = obj[prop]; + if (typeof result === 'function') { + return result.bind(obj); // arrow functions aren't affected by bind. + } + return result; + }, + evalUnaryExpression(ast, subs) { + const result = { + '-': a => -SafeEval.evalAst(a, subs), + '!': a => !SafeEval.evalAst(a, subs), + '~': a => ~SafeEval.evalAst(a, subs), + // eslint-disable-next-line no-implicit-coercion + '+': a => +SafeEval.evalAst(a, subs) + }[ast.operator](ast.argument); + return result; + }, + evalArrayExpression(ast, subs) { + return ast.elements.map(el => SafeEval.evalAst(el, subs)); + }, + evalCallExpression(ast, subs) { + const args = ast.arguments.map(arg => SafeEval.evalAst(arg, subs)); + const func = SafeEval.evalAst(ast.callee, subs); + return func(...args); + }, + evalAssignmentExpression(ast, subs) { + if (ast.left.type !== 'Identifier') { + throw SyntaxError('Invalid left-hand side in assignment'); + } + const id = ast.left.name; + const value = SafeEval.evalAst(ast.right, subs); + subs[id] = value; + return subs[id]; + } +}; + +/** + * A replacement for NodeJS' VM.Script which is also {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP | Content Security Policy} friendly. + */ +class SafeScript { + /** + * @param {string} expr Expression to evaluate + */ + constructor(expr) { + this.code = expr; + this.ast = jsep(this.code); + } + + /** + * @param {object} context Object whose items will be added + * to evaluation + * @returns {EvaluatedResult} Result of evaluated code + */ + runInNewContext(context) { + const keyMap = { + ...context + }; + return SafeEval.evalAst(this.ast, keyMap); + } +} + /* eslint-disable camelcase, unicorn/prefer-string-replace-all, unicorn/prefer-at */ -const { - hasOwnProperty: hasOwnProp -} = Object.prototype; + /** - * @typedef {null|boolean|number|string|PlainObject|GenericArray} JSONObject + * @typedef {null|boolean|number|string|object|GenericArray} JSONObject */ /** @@ -58,16 +1409,16 @@ class NewError extends Error { } /** -* @typedef {PlainObject} ReturnObject +* @typedef {object} ReturnObject * @property {string} path * @property {JSONObject} value -* @property {PlainObject|GenericArray} parent +* @property {object|GenericArray} parent * @property {string} parentProperty */ /** * @callback JSONPathCallback -* @param {string|PlainObject} preferredOutput +* @param {string|object} preferredOutput * @param {"value"|"property"} type * @param {ReturnObject} fullRetObj * @returns {void} @@ -77,7 +1428,7 @@ class NewError extends Error { * @callback OtherTypeCallback * @param {JSONObject} val * @param {string} path -* @param {PlainObject|GenericArray} parent +* @param {object|GenericArray} parent * @param {string} parentPropName * @returns {boolean} */ @@ -98,21 +1449,21 @@ class NewError extends Error { */ /** - * @typedef {typeof import('./jsonpath-browser').SafeScript} EvalClass + * @typedef {typeof SafeScript} EvalClass */ /** - * @typedef {PlainObject} JSONPathOptions + * @typedef {object} JSONPathOptions * @property {JSON} json * @property {string|string[]} path * @property {"value"|"path"|"pointer"|"parent"|"parentProperty"| * "all"} [resultType="value"] * @property {boolean} [flatten=false] * @property {boolean} [wrap=true] - * @property {PlainObject} [sandbox={}] + * @property {object} [sandbox={}] * @property {EvalCallback|EvalClass|'safe'|'native'| * boolean} [eval = 'safe'] - * @property {PlainObject|GenericArray|null} [parent=null] + * @property {object|GenericArray|null} [parent=null] * @property {string|null} [parentProperty=null] * @property {JSONPathCallback} [callback] * @property {OtherTypeCallback} [otherTypeCallback] Defaults to @@ -160,7 +1511,7 @@ function JSONPath(opts, expr, obj, callback, otherTypeCallback) { this.path = opts.path || expr; this.resultType = opts.resultType || 'value'; this.flatten = opts.flatten || false; - this.wrap = hasOwnProp.call(opts, 'wrap') ? opts.wrap : true; + this.wrap = Object.hasOwn(opts, 'wrap') ? opts.wrap : true; this.sandbox = opts.sandbox || {}; this.eval = opts.eval === undefined ? 'safe' : opts.eval; this.ignoreEvalErrors = typeof opts.ignoreEvalErrors === 'undefined' ? false : opts.ignoreEvalErrors; @@ -206,21 +1557,21 @@ JSONPath.prototype.evaluate = function (expr, json, callback, otherTypeCallback) if (!expr.path && expr.path !== '') { throw new TypeError('You must supply a "path" property when providing an object ' + 'argument to JSONPath.evaluate().'); } - if (!hasOwnProp.call(expr, 'json')) { + if (!Object.hasOwn(expr, 'json')) { throw new TypeError('You must supply a "json" property when providing an object ' + 'argument to JSONPath.evaluate().'); } ({ json } = expr); - flatten = hasOwnProp.call(expr, 'flatten') ? expr.flatten : flatten; - this.currResultType = hasOwnProp.call(expr, 'resultType') ? expr.resultType : this.currResultType; - this.currSandbox = hasOwnProp.call(expr, 'sandbox') ? expr.sandbox : this.currSandbox; - wrap = hasOwnProp.call(expr, 'wrap') ? expr.wrap : wrap; - this.currEval = hasOwnProp.call(expr, 'eval') ? expr.eval : this.currEval; - callback = hasOwnProp.call(expr, 'callback') ? expr.callback : callback; - this.currOtherTypeCallback = hasOwnProp.call(expr, 'otherTypeCallback') ? expr.otherTypeCallback : this.currOtherTypeCallback; - currParent = hasOwnProp.call(expr, 'parent') ? expr.parent : currParent; - currParentProperty = hasOwnProp.call(expr, 'parentProperty') ? expr.parentProperty : currParentProperty; + flatten = Object.hasOwn(expr, 'flatten') ? expr.flatten : flatten; + this.currResultType = Object.hasOwn(expr, 'resultType') ? expr.resultType : this.currResultType; + this.currSandbox = Object.hasOwn(expr, 'sandbox') ? expr.sandbox : this.currSandbox; + wrap = Object.hasOwn(expr, 'wrap') ? expr.wrap : wrap; + this.currEval = Object.hasOwn(expr, 'eval') ? expr.eval : this.currEval; + callback = Object.hasOwn(expr, 'callback') ? expr.callback : callback; + this.currOtherTypeCallback = Object.hasOwn(expr, 'otherTypeCallback') ? expr.otherTypeCallback : this.currOtherTypeCallback; + currParent = Object.hasOwn(expr, 'parent') ? expr.parent : currParent; + currParentProperty = Object.hasOwn(expr, 'parentProperty') ? expr.parentProperty : currParentProperty; expr = expr.path; } currParent = currParent || null; @@ -294,7 +1645,7 @@ JSONPath.prototype._handleCallback = function (fullRetObj, callback, type) { * @param {string} expr * @param {JSONObject} val * @param {string} path - * @param {PlainObject|GenericArray} parent + * @param {object|GenericArray} parent * @param {string} parentPropName * @param {JSONPathCallback} callback * @param {boolean} hasArrExpr @@ -339,7 +1690,7 @@ JSONPath.prototype._trace = function (expr, val, path, parent, parentPropName, c ret.push(elems); } } - if ((typeof loc !== 'string' || literalPriority) && val && hasOwnProp.call(val, loc)) { + if ((typeof loc !== 'string' || literalPriority) && val && Object.hasOwn(val, loc)) { // simple case--directly follow property addRet(this._trace(x, val[loc], push(path, loc), val, loc, callback, hasArrExpr)); // eslint-disable-next-line unicorn/prefer-switch -- Part of larger `if` @@ -488,7 +1839,7 @@ JSONPath.prototype._trace = function (expr, val, path, parent, parentPropName, c return retObj; } // `-escaped property - } else if (loc[0] === '`' && val && hasOwnProp.call(val, loc.slice(1))) { + } else if (loc[0] === '`' && val && Object.hasOwn(val, loc.slice(1))) { const locProp = loc.slice(1); addRet(this._trace(x, val[locProp], push(path, locProp), val, locProp, callback, hasArrExpr, true)); } else if (loc.includes(',')) { @@ -498,7 +1849,7 @@ JSONPath.prototype._trace = function (expr, val, path, parent, parentPropName, c addRet(this._trace(unshift(part, x), val, path, parent, parentPropName, callback, true)); } // simple case--directly follow property - } else if (!literalPriority && val && hasOwnProp.call(val, loc)) { + } else if (!literalPriority && val && Object.hasOwn(val, loc)) { addRet(this._trace(x, val[loc], push(path, loc), val, loc, callback, hasArrExpr, true)); } @@ -584,7 +1935,7 @@ JSONPath.prototype._eval = function (code, _v, _vname, path, parent, parentPropN JSONPath.cache[scriptCacheKey] = new this.safeVm.Script(script); } else if (this.currEval === 'native') { JSONPath.cache[scriptCacheKey] = new this.vm.Script(script); - } else if (typeof this.currEval === 'function' && this.currEval.prototype && hasOwnProp.call(this.currEval.prototype, 'runInNewContext')) { + } else if (typeof this.currEval === 'function' && this.currEval.prototype && Object.hasOwn(this.currEval.prototype, 'runInNewContext')) { const CurrEval = this.currEval; JSONPath.cache[scriptCacheKey] = new CurrEval(script); } else if (typeof this.currEval === 'function') { @@ -689,9 +2040,10 @@ JSONPath.toPathArray = function (expr) { cache[expr] = exprList; return cache[expr].concat(); }; +JSONPath.prototype.safeVm = { + Script: SafeScript +}; JSONPath.prototype.vm = vm; -JSONPath.prototype.safeVm = vm; -const SafeScript = vm.Script; -export { JSONPath, SafeScript }; +export { JSONPath };
package.json+1 −1 modified@@ -1,7 +1,7 @@ { "author": "Stefan Goessner", "name": "jsonpath-plus", - "version": "9.0.0", + "version": "10.0.0", "type": "module", "bin": { "jsonpath": "./bin/jsonpath-cli.js",
src/jsonpath-browser.js+2 −174 modified@@ -1,7 +1,3 @@ -/* eslint-disable no-bitwise */ -import jsep from 'jsep'; -import jsepRegex from '@jsep-plugin/regex'; -import jsepAssignment from '@jsep-plugin/assignment'; import {JSONPath} from './jsonpath.js'; /** @@ -38,170 +34,6 @@ const moveToAnotherArray = function (source, target, conditionCb) { } }; -// register plugins -jsep.plugins.register(jsepRegex, jsepAssignment); - -const SafeEval = { - /** - * @param {jsep.Expression} ast - * @param {Record<string, any>} subs - */ - evalAst (ast, subs) { - switch (ast.type) { - case 'BinaryExpression': - case 'LogicalExpression': - return SafeEval.evalBinaryExpression(ast, subs); - case 'Compound': - return SafeEval.evalCompound(ast, subs); - case 'ConditionalExpression': - return SafeEval.evalConditionalExpression(ast, subs); - case 'Identifier': - return SafeEval.evalIdentifier(ast, subs); - case 'Literal': - return SafeEval.evalLiteral(ast, subs); - case 'MemberExpression': - return SafeEval.evalMemberExpression(ast, subs); - case 'UnaryExpression': - return SafeEval.evalUnaryExpression(ast, subs); - case 'ArrayExpression': - return SafeEval.evalArrayExpression(ast, subs); - case 'CallExpression': - return SafeEval.evalCallExpression(ast, subs); - case 'AssignmentExpression': - return SafeEval.evalAssignmentExpression(ast, subs); - default: - throw SyntaxError('Unexpected expression', ast); - } - }, - evalBinaryExpression (ast, subs) { - const result = { - '||': (a, b) => a || b(), - '&&': (a, b) => a && b(), - '|': (a, b) => a | b(), - '^': (a, b) => a ^ b(), - '&': (a, b) => a & b(), - // eslint-disable-next-line eqeqeq - '==': (a, b) => a == b(), - // eslint-disable-next-line eqeqeq - '!=': (a, b) => a != b(), - '===': (a, b) => a === b(), - '!==': (a, b) => a !== b(), - '<': (a, b) => a < b(), - '>': (a, b) => a > b(), - '<=': (a, b) => a <= b(), - '>=': (a, b) => a >= b(), - '<<': (a, b) => a << b(), - '>>': (a, b) => a >> b(), - '>>>': (a, b) => a >>> b(), - '+': (a, b) => a + b(), - '-': (a, b) => a - b(), - '*': (a, b) => a * b(), - '/': (a, b) => a / b(), - '%': (a, b) => a % b() - }[ast.operator]( - SafeEval.evalAst(ast.left, subs), - () => SafeEval.evalAst(ast.right, subs) - ); - return result; - }, - evalCompound (ast, subs) { - let last; - for (let i = 0; i < ast.body.length; i++) { - if ( - ast.body[i].type === 'Identifier' && - ['var', 'let', 'const'].includes(ast.body[i].name) && - ast.body[i + 1] && - ast.body[i + 1].type === 'AssignmentExpression' - ) { - // var x=2; is detected as - // [{Identifier var}, {AssignmentExpression x=2}] - // eslint-disable-next-line @stylistic/max-len -- Long - // eslint-disable-next-line sonarjs/updated-loop-counter -- Convenient - i += 1; - } - const expr = ast.body[i]; - last = SafeEval.evalAst(expr, subs); - } - return last; - }, - evalConditionalExpression (ast, subs) { - if (SafeEval.evalAst(ast.test, subs)) { - return SafeEval.evalAst(ast.consequent, subs); - } - return SafeEval.evalAst(ast.alternate, subs); - }, - evalIdentifier (ast, subs) { - if (ast.name in subs) { - return subs[ast.name]; - } - throw ReferenceError(`${ast.name} is not defined`); - }, - evalLiteral (ast) { - return ast.value; - }, - evalMemberExpression (ast, subs) { - const prop = ast.computed - ? SafeEval.evalAst(ast.property) // `object[property]` - : ast.property.name; // `object.property` property is Identifier - const obj = SafeEval.evalAst(ast.object, subs); - const result = obj[prop]; - if (typeof result === 'function') { - return result.bind(obj); // arrow functions aren't affected by bind. - } - return result; - }, - evalUnaryExpression (ast, subs) { - const result = { - '-': (a) => -SafeEval.evalAst(a, subs), - '!': (a) => !SafeEval.evalAst(a, subs), - '~': (a) => ~SafeEval.evalAst(a, subs), - // eslint-disable-next-line no-implicit-coercion - '+': (a) => +SafeEval.evalAst(a, subs) - }[ast.operator](ast.argument); - return result; - }, - evalArrayExpression (ast, subs) { - return ast.elements.map((el) => SafeEval.evalAst(el, subs)); - }, - evalCallExpression (ast, subs) { - const args = ast.arguments.map((arg) => SafeEval.evalAst(arg, subs)); - const func = SafeEval.evalAst(ast.callee, subs); - return func(...args); - }, - evalAssignmentExpression (ast, subs) { - if (ast.left.type !== 'Identifier') { - throw SyntaxError('Invalid left-hand side in assignment'); - } - const id = ast.left.name; - const value = SafeEval.evalAst(ast.right, subs); - subs[id] = value; - return subs[id]; - } -}; - -/** - * A replacement for NodeJS' VM.Script which is also {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP | Content Security Policy} friendly. - */ -class SafeScript { - /** - * @param {string} expr Expression to evaluate - */ - constructor (expr) { - this.code = expr; - this.ast = jsep(this.code); - } - - /** - * @param {PlainObject} context Object whose items will be added - * to evaluation - * @returns {EvaluatedResult} Result of evaluated code - */ - runInNewContext (context) { - const keyMap = {...context}; - return SafeEval.evalAst(this.ast, keyMap); - } -} - /** * In-browser replacement for NodeJS' VM.Script. */ @@ -214,7 +46,7 @@ class Script { } /** - * @param {PlainObject} context Object whose items will be added + * @param {object} context Object whose items will be added * to evaluation * @returns {EvaluatedResult} Result of evaluated code */ @@ -267,8 +99,4 @@ JSONPath.prototype.vm = { Script }; -JSONPath.prototype.safeVm = { - Script: SafeScript -}; - -export {JSONPath, SafeScript}; +export {JSONPath};
src/jsonpath.js+31 −26 modified@@ -1,9 +1,10 @@ /* eslint-disable camelcase, unicorn/prefer-string-replace-all, unicorn/prefer-at */ -const {hasOwnProperty: hasOwnProp} = Object.prototype; + +import {SafeScript} from './Safe-Script.js'; /** - * @typedef {null|boolean|number|string|PlainObject|GenericArray} JSONObject + * @typedef {null|boolean|number|string|object|GenericArray} JSONObject */ /** @@ -57,16 +58,16 @@ class NewError extends Error { } /** -* @typedef {PlainObject} ReturnObject +* @typedef {object} ReturnObject * @property {string} path * @property {JSONObject} value -* @property {PlainObject|GenericArray} parent +* @property {object|GenericArray} parent * @property {string} parentProperty */ /** * @callback JSONPathCallback -* @param {string|PlainObject} preferredOutput +* @param {string|object} preferredOutput * @param {"value"|"property"} type * @param {ReturnObject} fullRetObj * @returns {void} @@ -76,7 +77,7 @@ class NewError extends Error { * @callback OtherTypeCallback * @param {JSONObject} val * @param {string} path -* @param {PlainObject|GenericArray} parent +* @param {object|GenericArray} parent * @param {string} parentPropName * @returns {boolean} */ @@ -97,21 +98,21 @@ class NewError extends Error { */ /** - * @typedef {typeof import('./jsonpath-browser').SafeScript} EvalClass + * @typedef {typeof SafeScript} EvalClass */ /** - * @typedef {PlainObject} JSONPathOptions + * @typedef {object} JSONPathOptions * @property {JSON} json * @property {string|string[]} path * @property {"value"|"path"|"pointer"|"parent"|"parentProperty"| * "all"} [resultType="value"] * @property {boolean} [flatten=false] * @property {boolean} [wrap=true] - * @property {PlainObject} [sandbox={}] + * @property {object} [sandbox={}] * @property {EvalCallback|EvalClass|'safe'|'native'| * boolean} [eval = 'safe'] - * @property {PlainObject|GenericArray|null} [parent=null] + * @property {object|GenericArray|null} [parent=null] * @property {string|null} [parentProperty=null] * @property {JSONPathCallback} [callback] * @property {OtherTypeCallback} [otherTypeCallback] Defaults to @@ -160,7 +161,7 @@ function JSONPath (opts, expr, obj, callback, otherTypeCallback) { this.path = opts.path || expr; this.resultType = opts.resultType || 'value'; this.flatten = opts.flatten || false; - this.wrap = hasOwnProp.call(opts, 'wrap') ? opts.wrap : true; + this.wrap = Object.hasOwn(opts, 'wrap') ? opts.wrap : true; this.sandbox = opts.sandbox || {}; this.eval = opts.eval === undefined ? 'safe' : opts.eval; this.ignoreEvalErrors = (typeof opts.ignoreEvalErrors === 'undefined') @@ -218,30 +219,30 @@ JSONPath.prototype.evaluate = function ( 'argument to JSONPath.evaluate().' ); } - if (!(hasOwnProp.call(expr, 'json'))) { + if (!(Object.hasOwn(expr, 'json'))) { throw new TypeError( 'You must supply a "json" property when providing an object ' + 'argument to JSONPath.evaluate().' ); } ({json} = expr); - flatten = hasOwnProp.call(expr, 'flatten') ? expr.flatten : flatten; - this.currResultType = hasOwnProp.call(expr, 'resultType') + flatten = Object.hasOwn(expr, 'flatten') ? expr.flatten : flatten; + this.currResultType = Object.hasOwn(expr, 'resultType') ? expr.resultType : this.currResultType; - this.currSandbox = hasOwnProp.call(expr, 'sandbox') + this.currSandbox = Object.hasOwn(expr, 'sandbox') ? expr.sandbox : this.currSandbox; - wrap = hasOwnProp.call(expr, 'wrap') ? expr.wrap : wrap; - this.currEval = hasOwnProp.call(expr, 'eval') + wrap = Object.hasOwn(expr, 'wrap') ? expr.wrap : wrap; + this.currEval = Object.hasOwn(expr, 'eval') ? expr.eval : this.currEval; - callback = hasOwnProp.call(expr, 'callback') ? expr.callback : callback; - this.currOtherTypeCallback = hasOwnProp.call(expr, 'otherTypeCallback') + callback = Object.hasOwn(expr, 'callback') ? expr.callback : callback; + this.currOtherTypeCallback = Object.hasOwn(expr, 'otherTypeCallback') ? expr.otherTypeCallback : this.currOtherTypeCallback; - currParent = hasOwnProp.call(expr, 'parent') ? expr.parent : currParent; - currParentProperty = hasOwnProp.call(expr, 'parentProperty') + currParent = Object.hasOwn(expr, 'parent') ? expr.parent : currParent; + currParentProperty = Object.hasOwn(expr, 'parentProperty') ? expr.parentProperty : currParentProperty; expr = expr.path; @@ -327,7 +328,7 @@ JSONPath.prototype._handleCallback = function (fullRetObj, callback, type) { * @param {string} expr * @param {JSONObject} val * @param {string} path - * @param {PlainObject|GenericArray} parent + * @param {object|GenericArray} parent * @param {string} parentPropName * @param {JSONPathCallback} callback * @param {boolean} hasArrExpr @@ -376,7 +377,7 @@ JSONPath.prototype._trace = function ( } } if ((typeof loc !== 'string' || literalPriority) && val && - hasOwnProp.call(val, loc) + Object.hasOwn(val, loc) ) { // simple case--directly follow property addRet(this._trace(x, val[loc], push(path, loc), val, loc, callback, hasArrExpr)); @@ -533,7 +534,7 @@ JSONPath.prototype._trace = function ( return retObj; } // `-escaped property - } else if (loc[0] === '`' && val && hasOwnProp.call(val, loc.slice(1))) { + } else if (loc[0] === '`' && val && Object.hasOwn(val, loc.slice(1))) { const locProp = loc.slice(1); addRet(this._trace( x, val[locProp], push(path, locProp), val, locProp, callback, @@ -549,7 +550,7 @@ JSONPath.prototype._trace = function ( } // simple case--directly follow property } else if ( - !literalPriority && val && hasOwnProp.call(val, loc) + !literalPriority && val && Object.hasOwn(val, loc) ) { addRet( this._trace(x, val[loc], push(path, loc), val, loc, callback, @@ -664,7 +665,7 @@ JSONPath.prototype._eval = function ( } else if ( typeof this.currEval === 'function' && this.currEval.prototype && - hasOwnProp.call(this.currEval.prototype, 'runInNewContext') + Object.hasOwn(this.currEval.prototype, 'runInNewContext') ) { const CurrEval = this.currEval; JSONPath.cache[scriptCacheKey] = new CurrEval(script); @@ -777,4 +778,8 @@ JSONPath.toPathArray = function (expr) { return cache[expr].concat(); }; +JSONPath.prototype.safeVm = { + Script: SafeScript +}; + export {JSONPath};
src/jsonpath-node.js+1 −5 modified@@ -2,11 +2,7 @@ import vm from 'vm'; import {JSONPath} from './jsonpath.js'; JSONPath.prototype.vm = vm; -JSONPath.prototype.safeVm = vm; - -const SafeScript = vm.Script; export { - JSONPath, - SafeScript + JSONPath };
src/Safe-Script.js+170 −0 added@@ -0,0 +1,170 @@ +/* eslint-disable no-bitwise */ +import jsep from 'jsep'; +import jsepRegex from '@jsep-plugin/regex'; +import jsepAssignment from '@jsep-plugin/assignment'; + +// register plugins +jsep.plugins.register(jsepRegex, jsepAssignment); + +const SafeEval = { + /** + * @param {jsep.Expression} ast + * @param {Record<string, any>} subs + */ + evalAst (ast, subs) { + switch (ast.type) { + case 'BinaryExpression': + case 'LogicalExpression': + return SafeEval.evalBinaryExpression(ast, subs); + case 'Compound': + return SafeEval.evalCompound(ast, subs); + case 'ConditionalExpression': + return SafeEval.evalConditionalExpression(ast, subs); + case 'Identifier': + return SafeEval.evalIdentifier(ast, subs); + case 'Literal': + return SafeEval.evalLiteral(ast, subs); + case 'MemberExpression': + return SafeEval.evalMemberExpression(ast, subs); + case 'UnaryExpression': + return SafeEval.evalUnaryExpression(ast, subs); + case 'ArrayExpression': + return SafeEval.evalArrayExpression(ast, subs); + case 'CallExpression': + return SafeEval.evalCallExpression(ast, subs); + case 'AssignmentExpression': + return SafeEval.evalAssignmentExpression(ast, subs); + default: + throw SyntaxError('Unexpected expression', ast); + } + }, + evalBinaryExpression (ast, subs) { + const result = { + '||': (a, b) => a || b(), + '&&': (a, b) => a && b(), + '|': (a, b) => a | b(), + '^': (a, b) => a ^ b(), + '&': (a, b) => a & b(), + // eslint-disable-next-line eqeqeq + '==': (a, b) => a == b(), + // eslint-disable-next-line eqeqeq + '!=': (a, b) => a != b(), + '===': (a, b) => a === b(), + '!==': (a, b) => a !== b(), + '<': (a, b) => a < b(), + '>': (a, b) => a > b(), + '<=': (a, b) => a <= b(), + '>=': (a, b) => a >= b(), + '<<': (a, b) => a << b(), + '>>': (a, b) => a >> b(), + '>>>': (a, b) => a >>> b(), + '+': (a, b) => a + b(), + '-': (a, b) => a - b(), + '*': (a, b) => a * b(), + '/': (a, b) => a / b(), + '%': (a, b) => a % b() + }[ast.operator]( + SafeEval.evalAst(ast.left, subs), + () => SafeEval.evalAst(ast.right, subs) + ); + return result; + }, + evalCompound (ast, subs) { + let last; + for (let i = 0; i < ast.body.length; i++) { + if ( + ast.body[i].type === 'Identifier' && + ['var', 'let', 'const'].includes(ast.body[i].name) && + ast.body[i + 1] && + ast.body[i + 1].type === 'AssignmentExpression' + ) { + // var x=2; is detected as + // [{Identifier var}, {AssignmentExpression x=2}] + // eslint-disable-next-line @stylistic/max-len -- Long + // eslint-disable-next-line sonarjs/updated-loop-counter -- Convenient + i += 1; + } + const expr = ast.body[i]; + last = SafeEval.evalAst(expr, subs); + } + return last; + }, + evalConditionalExpression (ast, subs) { + if (SafeEval.evalAst(ast.test, subs)) { + return SafeEval.evalAst(ast.consequent, subs); + } + return SafeEval.evalAst(ast.alternate, subs); + }, + evalIdentifier (ast, subs) { + if (ast.name in subs) { + return subs[ast.name]; + } + throw ReferenceError(`${ast.name} is not defined`); + }, + evalLiteral (ast) { + return ast.value; + }, + evalMemberExpression (ast, subs) { + const prop = ast.computed + ? SafeEval.evalAst(ast.property) // `object[property]` + : ast.property.name; // `object.property` property is Identifier + const obj = SafeEval.evalAst(ast.object, subs); + const result = obj[prop]; + if (typeof result === 'function') { + return result.bind(obj); // arrow functions aren't affected by bind. + } + return result; + }, + evalUnaryExpression (ast, subs) { + const result = { + '-': (a) => -SafeEval.evalAst(a, subs), + '!': (a) => !SafeEval.evalAst(a, subs), + '~': (a) => ~SafeEval.evalAst(a, subs), + // eslint-disable-next-line no-implicit-coercion + '+': (a) => +SafeEval.evalAst(a, subs) + }[ast.operator](ast.argument); + return result; + }, + evalArrayExpression (ast, subs) { + return ast.elements.map((el) => SafeEval.evalAst(el, subs)); + }, + evalCallExpression (ast, subs) { + const args = ast.arguments.map((arg) => SafeEval.evalAst(arg, subs)); + const func = SafeEval.evalAst(ast.callee, subs); + return func(...args); + }, + evalAssignmentExpression (ast, subs) { + if (ast.left.type !== 'Identifier') { + throw SyntaxError('Invalid left-hand side in assignment'); + } + const id = ast.left.name; + const value = SafeEval.evalAst(ast.right, subs); + subs[id] = value; + return subs[id]; + } +}; + +/** + * A replacement for NodeJS' VM.Script which is also {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP | Content Security Policy} friendly. + */ +class SafeScript { + /** + * @param {string} expr Expression to evaluate + */ + constructor (expr) { + this.code = expr; + this.ast = jsep(this.code); + } + + /** + * @param {object} context Object whose items will be added + * to evaluation + * @returns {EvaluatedResult} Result of evaluated code + */ + runInNewContext (context) { + const keyMap = {...context}; + return SafeEval.evalAst(this.ast, keyMap); + } +} + +export {SafeScript};
Vulnerability mechanics
Generated by null/stub on May 9, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.
References
11- github.com/advisories/GHSA-pppg-cpfq-h7wrghsaADVISORY
- nvd.nist.gov/vuln/detail/CVE-2024-21534ghsaADVISORY
- github.com/JSONPath-Plus/JSONPath/commit/6b2f1b4c234292c75912b790bf7e2d7339d4ccd3ghsaWEB
- github.com/JSONPath-Plus/JSONPath/commit/73ad72e5ee788d8287dea6e8283a3f16f63c9eb8ghsaWEB
- github.com/JSONPath-Plus/JSONPath/commit/b70aa713553caf838a63bac923195a5bc541fd72ghsaWEB
- github.com/JSONPath-Plus/JSONPath/compare/v9.0.0...v10.1.0nvdWEB
- github.com/JSONPath-Plus/JSONPath/issues/226nvdWEB
- github.com/JSONPath-Plus/JSONPath/issues/226ghsaWEB
- github.com/JSONPath-Plus/JSONPath/pull/233ghsaWEB
- security.snyk.io/vuln/SNYK-JAVA-ORGWEBJARSNPM-8185019nvdWEB
- security.snyk.io/vuln/SNYK-JS-JSONPATHPLUS-7945884nvdWEB
News mentions
0No linked articles in our index yet.