Socket
Socket
Sign inDemoInstall

jsonpath-plus

Package Overview
Dependencies
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsonpath-plus - npm Package Compare versions

Comparing version 0.18.0 to 0.18.1

.DS_Store

4

CHANGES.md
# jsonpath-plus changes
## 0.18.1 (May 14, 2019)
- Fix: Expose `pointer` on `resultType: "all"`
## 0.18.0 (October 20, 2018)

@@ -4,0 +8,0 @@

@@ -393,2 +393,3 @@ function _typeof(obj) {

case 'all':
ea.pointer = JSONPath.toPointer(ea.path);
ea.path = typeof ea.path === 'string' ? ea.path : JSONPath.toPathString(ea.path);

@@ -445,2 +446,3 @@ return ea;

if (Array.isArray(elems)) {
// This was causing excessive stack size in Node (with or without Babel) against our performance test: `ret.push(...elems);`
elems.forEach(function (t) {

@@ -702,2 +704,3 @@ ret.push(t);

if (Array.isArray(tmp)) {
// This was causing excessive stack size in Node (with or without Babel) against our performance test: `ret.push(...tmp);`
tmp.forEach(function (t) {

@@ -704,0 +707,0 @@ ret.push(t);

2

dist/index-es.min.js

@@ -1,2 +0,2 @@

function _typeof(t){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function _classCallCheck(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function _inherits(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&_setPrototypeOf(t,e)}function _getPrototypeOf(t){return(_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function _setPrototypeOf(t,e){return(_setPrototypeOf=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(t){return!1}}function _construct(t,e,r){return(_construct=isNativeReflectConstruct()?Reflect.construct:function(t,e,r){var n=[null];n.push.apply(n,e);var a=new(Function.bind.apply(t,n));return r&&_setPrototypeOf(a,r.prototype),a}).apply(null,arguments)}function _isNativeFunction(t){return-1!==Function.toString.call(t).indexOf("[native code]")}function _wrapNativeSuper(t){var e="function"==typeof Map?new Map:void 0;return(_wrapNativeSuper=function(t){if(null===t||!_isNativeFunction(t))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,r)}function r(){return _construct(t,arguments,_getPrototypeOf(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),_setPrototypeOf(r,t)})(t)}function _assertThisInitialized(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function _possibleConstructorReturn(t,e){return!e||"object"!=typeof e&&"function"!=typeof e?_assertThisInitialized(t):e}var globalEval=eval,supportsNodeVM=!("undefined"==typeof module||!module.exports||"undefined"!=typeof navigator&&"ReactNative"===navigator.product),allowedResultTypes=["value","path","pointer","parent","parentProperty","all"],hasOwnProperty=Object.prototype.hasOwnProperty,moveToAnotherArray=function(t,e,r){for(var n=t.length,a=0;a<n;a++){r(t[a])&&e.push(t.splice(a--,1)[0])}},vm=supportsNodeVM?require("vm"):{runInNewContext:function(t,e){var r=Object.keys(e),n=[];moveToAnotherArray(r,n,function(t){return"function"==typeof e[t]});var a=n.reduce(function(t,r){var n=e[r].toString();return/function/.exec(n)||(n="function "+n),"var "+r+"="+n+";"+t},"")+r.reduce(function(t,r){return"var "+r+"="+JSON.stringify(e[r]).replace(/\u2028|\u2029/g,function(t){return"\\u202"+("\u2028"===t?"8":"9")})+";"+t},t);return globalEval(a)}};function push(t,e){return(t=t.slice()).push(e),t}function unshift(t,e){return(e=e.slice()).unshift(t),e}var NewError=function(t){function e(t){var r;return _classCallCheck(this,e),(r=_possibleConstructorReturn(this,_getPrototypeOf(e).call(this,'JSONPath should not be called with "new" (it prevents return of (unwrapped) scalar values)'))).avoidNew=!0,r.value=t,r}return _inherits(e,_wrapNativeSuper(Error)),e}();function JSONPath(t,e,r,n,a){if(!(this instanceof JSONPath))try{return new JSONPath(t,e,r,n,a)}catch(t){if(!t.avoidNew)throw t;return t.value}"string"==typeof t&&(a=n,n=r,r=e,e=t,t={});var o=(t=t||{}).hasOwnProperty("json")&&t.hasOwnProperty("path");if(this.json=t.json||r,this.path=t.path||e,this.resultType=t.resultType&&t.resultType.toLowerCase()||"value",this.flatten=t.flatten||!1,this.wrap=!t.hasOwnProperty("wrap")||t.wrap,this.sandbox=t.sandbox||{},this.preventEval=t.preventEval||!1,this.parent=t.parent||null,this.parentProperty=t.parentProperty||null,this.callback=t.callback||n||null,this.otherTypeCallback=t.otherTypeCallback||a||function(){throw new Error("You must supply an otherTypeCallback callback option with the @other() operator.")},!1!==t.autostart){var i=this.evaluate({path:o?t.path:e,json:o?t.json:r});if(!i||"object"!==_typeof(i))throw new NewError(i);return i}}JSONPath.prototype.evaluate=function(t,e,r,n){var a=this,o=this.parent,i=this.parentProperty,s=this.flatten,p=this.wrap;if(this.currResultType=this.resultType,this.currPreventEval=this.preventEval,this.currSandbox=this.sandbox,r=r||this.callback,this.currOtherTypeCallback=n||this.otherTypeCallback,e=e||this.json,(t=t||this.path)&&"object"===_typeof(t)){if(!t.path)throw new Error('You must supply a "path" property when providing an object argument to JSONPath.evaluate().');e=t.hasOwnProperty("json")?t.json:e,s=t.hasOwnProperty("flatten")?t.flatten:s,this.currResultType=t.hasOwnProperty("resultType")?t.resultType:this.currResultType,this.currSandbox=t.hasOwnProperty("sandbox")?t.sandbox:this.currSandbox,p=t.hasOwnProperty("wrap")?t.wrap:p,this.currPreventEval=t.hasOwnProperty("preventEval")?t.preventEval:this.currPreventEval,r=t.hasOwnProperty("callback")?t.callback:r,this.currOtherTypeCallback=t.hasOwnProperty("otherTypeCallback")?t.otherTypeCallback:this.currOtherTypeCallback,o=t.hasOwnProperty("parent")?t.parent:o,i=t.hasOwnProperty("parentProperty")?t.parentProperty:i,t=t.path}if(o=o||null,i=i||null,Array.isArray(t)&&(t=JSONPath.toPathString(t)),t&&e&&allowedResultTypes.includes(this.currResultType)){this._obj=e;var c=JSONPath.toPathArray(t);"$"===c[0]&&c.length>1&&c.shift(),this._hasParentSelector=null;var u=this._trace(c,e,["$"],o,i,r).filter(function(t){return t&&!t.isParentSelector});return u.length?1!==u.length||p||Array.isArray(u[0].value)?u.reduce(function(t,e){var r=a._getPreferredOutput(e);return s&&Array.isArray(r)?t=t.concat(r):t.push(r),t},[]):this._getPreferredOutput(u[0]):p?[]:void 0}},JSONPath.prototype._getPreferredOutput=function(t){var e=this.currResultType;switch(e){case"all":return t.path="string"==typeof t.path?t.path:JSONPath.toPathString(t.path),t;case"value":case"parent":case"parentProperty":return t[e];case"path":return JSONPath.toPathString(t[e]);case"pointer":return JSONPath.toPointer(t.path)}},JSONPath.prototype._handleCallback=function(t,e,r){if(e){var n=this._getPreferredOutput(t);t.path="string"==typeof t.path?t.path:JSONPath.toPathString(t.path),e(n,r,t)}},JSONPath.prototype._trace=function(t,e,r,n,a,o,i){var s,p=this;if(!t.length)return s={path:r,value:e,parent:n,parentProperty:a},this._handleCallback(s,o,"value"),s;var c=t[0],u=t.slice(1),l=[];function h(t){Array.isArray(t)?t.forEach(function(t){l.push(t)}):l.push(t)}if(("string"!=typeof c||i)&&e&&hasOwnProperty.call(e,c))h(this._trace(u,e[c],push(r,c),e,c,o));else if("*"===c)this._walk(c,u,e,r,n,a,o,function(t,e,r,n,a,o,i,s){h(p._trace(unshift(t,r),n,a,o,i,s,!0))});else if(".."===c)h(this._trace(u,e,r,n,a,o)),this._walk(c,u,e,r,n,a,o,function(t,e,r,n,a,o,i,s){"object"===_typeof(n[t])&&h(p._trace(unshift(e,r),n[t],push(a,t),n,t,s))});else{if("^"===c)return this._hasParentSelector=!0,r.length?{path:r.slice(0,-1),expr:u,isParentSelector:!0}:[];if("~"===c)return s={path:push(r,c),value:a,parent:n,parentProperty:null},this._handleCallback(s,o,"property"),s;if("$"===c)h(this._trace(u,e,r,null,null,o));else if(/^(-?[0-9]*):(-?[0-9]*):?([0-9]*)$/.test(c))h(this._slice(c,u,e,r,n,a,o));else if(0===c.indexOf("?(")){if(this.currPreventEval)throw new Error("Eval [?(expr)] prevented in JSONPath expression.");this._walk(c,u,e,r,n,a,o,function(t,e,r,n,a,o,i,s){p._eval(e.replace(/^\?\((.*?)\)$/,"$1"),n[t],t,a,o,i)&&h(p._trace(unshift(t,r),n,a,o,i,s))})}else if("("===c[0]){if(this.currPreventEval)throw new Error("Eval [(expr)] prevented in JSONPath expression.");h(this._trace(unshift(this._eval(c,e,r[r.length-1],r.slice(0,-1),n,a),u),e,r,n,a,o))}else if("@"===c[0]){var f=!1,y=c.slice(1,-2);switch(y){case"scalar":e&&["object","function"].includes(_typeof(e))||(f=!0);break;case"boolean":case"string":case"undefined":case"function":_typeof(e)===y&&(f=!0);break;case"number":_typeof(e)===y&&isFinite(e)&&(f=!0);break;case"nonFinite":"number"!=typeof e||isFinite(e)||(f=!0);break;case"object":e&&_typeof(e)===y&&(f=!0);break;case"array":Array.isArray(e)&&(f=!0);break;case"other":f=this.currOtherTypeCallback(e,r,n,a);break;case"integer":e!==+e||!isFinite(e)||e%1||(f=!0);break;case"null":null===e&&(f=!0)}if(f)return s={path:r,value:e,parent:n,parentProperty:a},this._handleCallback(s,o,"value"),s}else if("`"===c[0]&&e&&hasOwnProperty.call(e,c.slice(1))){var v=c.slice(1);h(this._trace(u,e[v],push(r,v),e,v,o,!0))}else if(c.includes(",")){var P=c.split(","),_=!0,b=!1,O=void 0;try{for(var w,g=P[Symbol.iterator]();!(_=(w=g.next()).done);_=!0){var d=w.value;h(this._trace(unshift(d,u),e,r,n,a,o))}}catch(t){b=!0,O=t}finally{try{_||null==g.return||g.return()}finally{if(b)throw O}}}else!i&&e&&hasOwnProperty.call(e,c)&&h(this._trace(u,e[c],push(r,c),e,c,o,!0))}if(this._hasParentSelector)for(var S=0;S<l.length;S++){var N=l[S];if(N.isParentSelector){var k=p._trace(N.expr,e,N.path,n,a,o);if(Array.isArray(k)){l[S]=k[0];for(var m=k.length,x=1;x<m;x++)S++,l.splice(S,0,k[x])}else l[S]=k}}return l},JSONPath.prototype._walk=function(t,e,r,n,a,o,i,s){if(Array.isArray(r))for(var p=r.length,c=0;c<p;c++)s(c,t,e,r,n,a,o,i);else if("object"===_typeof(r))for(var u in r)hasOwnProperty.call(r,u)&&s(u,t,e,r,n,a,o,i)},JSONPath.prototype._slice=function(t,e,r,n,a,o,i){if(Array.isArray(r)){var s=r.length,p=t.split(":"),c=p[2]&&parseInt(p[2],10)||1,u=p[0]&&parseInt(p[0],10)||0,l=p[1]&&parseInt(p[1],10)||s;u=u<0?Math.max(0,u+s):Math.min(s,u),l=l<0?Math.max(0,l+s):Math.min(s,l);for(var h=[],f=u;f<l;f+=c){var y=this._trace(unshift(f,e),r,n,a,o,i);Array.isArray(y)?y.forEach(function(t){h.push(t)}):h.push(y)}return h}},JSONPath.prototype._eval=function(t,e,r,n,a,o){if(!this._obj||!e)return!1;t.includes("@parentProperty")&&(this.currSandbox._$_parentProperty=o,t=t.replace(/@parentProperty/g,"_$_parentProperty")),t.includes("@parent")&&(this.currSandbox._$_parent=a,t=t.replace(/@parent/g,"_$_parent")),t.includes("@property")&&(this.currSandbox._$_property=r,t=t.replace(/@property/g,"_$_property")),t.includes("@path")&&(this.currSandbox._$_path=JSONPath.toPathString(n.concat([r])),t=t.replace(/@path/g,"_$_path")),t.match(/@([.\s)[])/)&&(this.currSandbox._$_v=e,t=t.replace(/@([.\s)[])/g,"_$_v$1"));try{return vm.runInNewContext(t,this.currSandbox)}catch(e){throw console.log(e),new Error("jsonPath: "+e.message+": "+t)}},JSONPath.cache={},JSONPath.toPathString=function(t){for(var e=t,r=e.length,n="$",a=1;a<r;a++)/^(~|\^|@.*?\(\))$/.test(e[a])||(n+=/^[0-9*]+$/.test(e[a])?"["+e[a]+"]":"['"+e[a]+"']");return n},JSONPath.toPointer=function(t){for(var e=t,r=e.length,n="",a=1;a<r;a++)/^(~|\^|@.*?\(\))$/.test(e[a])||(n+="/"+e[a].toString().replace(/~/g,"~0").replace(/\//g,"~1"));return n},JSONPath.toPathArray=function(t){var e=JSONPath.cache;if(e[t])return e[t].concat();var r=[],n=t.replace(/@(?:null|boolean|number|string|integer|undefined|nonFinite|scalar|array|object|function|other)\(\)/g,";$&;").replace(/[['](\??\(.*?\))[\]']/g,function(t,e){return"[#"+(r.push(e)-1)+"]"}).replace(/\['([^'\]]*)'\]/g,function(t,e){return"['"+e.replace(/\./g,"%@%").replace(/~/g,"%%@@%%")+"']"}).replace(/~/g,";~;").replace(/'?\.'?(?![^[]*\])|\['?/g,";").replace(/%@%/g,".").replace(/%%@@%%/g,"~").replace(/(?:;)?(\^+)(?:;)?/g,function(t,e){return";"+e.split("").join(";")+";"}).replace(/;;;|;;/g,";..;").replace(/;$|'?\]|'$/g,"").split(";").map(function(t){var e=t.match(/#([0-9]+)/);return e&&e[1]?r[e[1]]:t});return e[t]=n,e[t]};export{JSONPath};
function _typeof(t){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function _classCallCheck(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function _inherits(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&_setPrototypeOf(t,e)}function _getPrototypeOf(t){return(_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function _setPrototypeOf(t,e){return(_setPrototypeOf=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(t){return!1}}function _construct(t,e,r){return(_construct=isNativeReflectConstruct()?Reflect.construct:function(t,e,r){var n=[null];n.push.apply(n,e);var a=new(Function.bind.apply(t,n));return r&&_setPrototypeOf(a,r.prototype),a}).apply(null,arguments)}function _isNativeFunction(t){return-1!==Function.toString.call(t).indexOf("[native code]")}function _wrapNativeSuper(t){var e="function"==typeof Map?new Map:void 0;return(_wrapNativeSuper=function(t){if(null===t||!_isNativeFunction(t))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,r)}function r(){return _construct(t,arguments,_getPrototypeOf(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),_setPrototypeOf(r,t)})(t)}function _assertThisInitialized(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function _possibleConstructorReturn(t,e){return!e||"object"!=typeof e&&"function"!=typeof e?_assertThisInitialized(t):e}var globalEval=eval,supportsNodeVM=!("undefined"==typeof module||!module.exports||"undefined"!=typeof navigator&&"ReactNative"===navigator.product),allowedResultTypes=["value","path","pointer","parent","parentProperty","all"],hasOwnProperty=Object.prototype.hasOwnProperty,moveToAnotherArray=function(t,e,r){for(var n=t.length,a=0;a<n;a++){r(t[a])&&e.push(t.splice(a--,1)[0])}},vm=supportsNodeVM?require("vm"):{runInNewContext:function(t,e){var r=Object.keys(e),n=[];moveToAnotherArray(r,n,function(t){return"function"==typeof e[t]});var a=n.reduce(function(t,r){var n=e[r].toString();return/function/.exec(n)||(n="function "+n),"var "+r+"="+n+";"+t},"")+r.reduce(function(t,r){return"var "+r+"="+JSON.stringify(e[r]).replace(/\u2028|\u2029/g,function(t){return"\\u202"+("\u2028"===t?"8":"9")})+";"+t},t);return globalEval(a)}};function push(t,e){return(t=t.slice()).push(e),t}function unshift(t,e){return(e=e.slice()).unshift(t),e}var NewError=function(t){function e(t){var r;return _classCallCheck(this,e),(r=_possibleConstructorReturn(this,_getPrototypeOf(e).call(this,'JSONPath should not be called with "new" (it prevents return of (unwrapped) scalar values)'))).avoidNew=!0,r.value=t,r}return _inherits(e,_wrapNativeSuper(Error)),e}();function JSONPath(t,e,r,n,a){if(!(this instanceof JSONPath))try{return new JSONPath(t,e,r,n,a)}catch(t){if(!t.avoidNew)throw t;return t.value}"string"==typeof t&&(a=n,n=r,r=e,e=t,t={});var o=(t=t||{}).hasOwnProperty("json")&&t.hasOwnProperty("path");if(this.json=t.json||r,this.path=t.path||e,this.resultType=t.resultType&&t.resultType.toLowerCase()||"value",this.flatten=t.flatten||!1,this.wrap=!t.hasOwnProperty("wrap")||t.wrap,this.sandbox=t.sandbox||{},this.preventEval=t.preventEval||!1,this.parent=t.parent||null,this.parentProperty=t.parentProperty||null,this.callback=t.callback||n||null,this.otherTypeCallback=t.otherTypeCallback||a||function(){throw new Error("You must supply an otherTypeCallback callback option with the @other() operator.")},!1!==t.autostart){var i=this.evaluate({path:o?t.path:e,json:o?t.json:r});if(!i||"object"!==_typeof(i))throw new NewError(i);return i}}JSONPath.prototype.evaluate=function(t,e,r,n){var a=this,o=this.parent,i=this.parentProperty,s=this.flatten,p=this.wrap;if(this.currResultType=this.resultType,this.currPreventEval=this.preventEval,this.currSandbox=this.sandbox,r=r||this.callback,this.currOtherTypeCallback=n||this.otherTypeCallback,e=e||this.json,(t=t||this.path)&&"object"===_typeof(t)){if(!t.path)throw new Error('You must supply a "path" property when providing an object argument to JSONPath.evaluate().');e=t.hasOwnProperty("json")?t.json:e,s=t.hasOwnProperty("flatten")?t.flatten:s,this.currResultType=t.hasOwnProperty("resultType")?t.resultType:this.currResultType,this.currSandbox=t.hasOwnProperty("sandbox")?t.sandbox:this.currSandbox,p=t.hasOwnProperty("wrap")?t.wrap:p,this.currPreventEval=t.hasOwnProperty("preventEval")?t.preventEval:this.currPreventEval,r=t.hasOwnProperty("callback")?t.callback:r,this.currOtherTypeCallback=t.hasOwnProperty("otherTypeCallback")?t.otherTypeCallback:this.currOtherTypeCallback,o=t.hasOwnProperty("parent")?t.parent:o,i=t.hasOwnProperty("parentProperty")?t.parentProperty:i,t=t.path}if(o=o||null,i=i||null,Array.isArray(t)&&(t=JSONPath.toPathString(t)),t&&e&&allowedResultTypes.includes(this.currResultType)){this._obj=e;var c=JSONPath.toPathArray(t);"$"===c[0]&&c.length>1&&c.shift(),this._hasParentSelector=null;var u=this._trace(c,e,["$"],o,i,r).filter(function(t){return t&&!t.isParentSelector});return u.length?1!==u.length||p||Array.isArray(u[0].value)?u.reduce(function(t,e){var r=a._getPreferredOutput(e);return s&&Array.isArray(r)?t=t.concat(r):t.push(r),t},[]):this._getPreferredOutput(u[0]):p?[]:void 0}},JSONPath.prototype._getPreferredOutput=function(t){var e=this.currResultType;switch(e){case"all":return t.pointer=JSONPath.toPointer(t.path),t.path="string"==typeof t.path?t.path:JSONPath.toPathString(t.path),t;case"value":case"parent":case"parentProperty":return t[e];case"path":return JSONPath.toPathString(t[e]);case"pointer":return JSONPath.toPointer(t.path)}},JSONPath.prototype._handleCallback=function(t,e,r){if(e){var n=this._getPreferredOutput(t);t.path="string"==typeof t.path?t.path:JSONPath.toPathString(t.path),e(n,r,t)}},JSONPath.prototype._trace=function(t,e,r,n,a,o,i){var s,p=this;if(!t.length)return s={path:r,value:e,parent:n,parentProperty:a},this._handleCallback(s,o,"value"),s;var c=t[0],u=t.slice(1),l=[];function h(t){Array.isArray(t)?t.forEach(function(t){l.push(t)}):l.push(t)}if(("string"!=typeof c||i)&&e&&hasOwnProperty.call(e,c))h(this._trace(u,e[c],push(r,c),e,c,o));else if("*"===c)this._walk(c,u,e,r,n,a,o,function(t,e,r,n,a,o,i,s){h(p._trace(unshift(t,r),n,a,o,i,s,!0))});else if(".."===c)h(this._trace(u,e,r,n,a,o)),this._walk(c,u,e,r,n,a,o,function(t,e,r,n,a,o,i,s){"object"===_typeof(n[t])&&h(p._trace(unshift(e,r),n[t],push(a,t),n,t,s))});else{if("^"===c)return this._hasParentSelector=!0,r.length?{path:r.slice(0,-1),expr:u,isParentSelector:!0}:[];if("~"===c)return s={path:push(r,c),value:a,parent:n,parentProperty:null},this._handleCallback(s,o,"property"),s;if("$"===c)h(this._trace(u,e,r,null,null,o));else if(/^(-?[0-9]*):(-?[0-9]*):?([0-9]*)$/.test(c))h(this._slice(c,u,e,r,n,a,o));else if(0===c.indexOf("?(")){if(this.currPreventEval)throw new Error("Eval [?(expr)] prevented in JSONPath expression.");this._walk(c,u,e,r,n,a,o,function(t,e,r,n,a,o,i,s){p._eval(e.replace(/^\?\((.*?)\)$/,"$1"),n[t],t,a,o,i)&&h(p._trace(unshift(t,r),n,a,o,i,s))})}else if("("===c[0]){if(this.currPreventEval)throw new Error("Eval [(expr)] prevented in JSONPath expression.");h(this._trace(unshift(this._eval(c,e,r[r.length-1],r.slice(0,-1),n,a),u),e,r,n,a,o))}else if("@"===c[0]){var f=!1,y=c.slice(1,-2);switch(y){case"scalar":e&&["object","function"].includes(_typeof(e))||(f=!0);break;case"boolean":case"string":case"undefined":case"function":_typeof(e)===y&&(f=!0);break;case"number":_typeof(e)===y&&isFinite(e)&&(f=!0);break;case"nonFinite":"number"!=typeof e||isFinite(e)||(f=!0);break;case"object":e&&_typeof(e)===y&&(f=!0);break;case"array":Array.isArray(e)&&(f=!0);break;case"other":f=this.currOtherTypeCallback(e,r,n,a);break;case"integer":e!==+e||!isFinite(e)||e%1||(f=!0);break;case"null":null===e&&(f=!0)}if(f)return s={path:r,value:e,parent:n,parentProperty:a},this._handleCallback(s,o,"value"),s}else if("`"===c[0]&&e&&hasOwnProperty.call(e,c.slice(1))){var v=c.slice(1);h(this._trace(u,e[v],push(r,v),e,v,o,!0))}else if(c.includes(",")){var P=c.split(","),_=!0,b=!1,O=void 0;try{for(var w,g=P[Symbol.iterator]();!(_=(w=g.next()).done);_=!0){var d=w.value;h(this._trace(unshift(d,u),e,r,n,a,o))}}catch(t){b=!0,O=t}finally{try{_||null==g.return||g.return()}finally{if(b)throw O}}}else!i&&e&&hasOwnProperty.call(e,c)&&h(this._trace(u,e[c],push(r,c),e,c,o,!0))}if(this._hasParentSelector)for(var S=0;S<l.length;S++){var N=l[S];if(N.isParentSelector){var k=p._trace(N.expr,e,N.path,n,a,o);if(Array.isArray(k)){l[S]=k[0];for(var m=k.length,x=1;x<m;x++)S++,l.splice(S,0,k[x])}else l[S]=k}}return l},JSONPath.prototype._walk=function(t,e,r,n,a,o,i,s){if(Array.isArray(r))for(var p=r.length,c=0;c<p;c++)s(c,t,e,r,n,a,o,i);else if("object"===_typeof(r))for(var u in r)hasOwnProperty.call(r,u)&&s(u,t,e,r,n,a,o,i)},JSONPath.prototype._slice=function(t,e,r,n,a,o,i){if(Array.isArray(r)){var s=r.length,p=t.split(":"),c=p[2]&&parseInt(p[2],10)||1,u=p[0]&&parseInt(p[0],10)||0,l=p[1]&&parseInt(p[1],10)||s;u=u<0?Math.max(0,u+s):Math.min(s,u),l=l<0?Math.max(0,l+s):Math.min(s,l);for(var h=[],f=u;f<l;f+=c){var y=this._trace(unshift(f,e),r,n,a,o,i);Array.isArray(y)?y.forEach(function(t){h.push(t)}):h.push(y)}return h}},JSONPath.prototype._eval=function(t,e,r,n,a,o){if(!this._obj||!e)return!1;t.includes("@parentProperty")&&(this.currSandbox._$_parentProperty=o,t=t.replace(/@parentProperty/g,"_$_parentProperty")),t.includes("@parent")&&(this.currSandbox._$_parent=a,t=t.replace(/@parent/g,"_$_parent")),t.includes("@property")&&(this.currSandbox._$_property=r,t=t.replace(/@property/g,"_$_property")),t.includes("@path")&&(this.currSandbox._$_path=JSONPath.toPathString(n.concat([r])),t=t.replace(/@path/g,"_$_path")),t.match(/@([.\s)[])/)&&(this.currSandbox._$_v=e,t=t.replace(/@([.\s)[])/g,"_$_v$1"));try{return vm.runInNewContext(t,this.currSandbox)}catch(e){throw console.log(e),new Error("jsonPath: "+e.message+": "+t)}},JSONPath.cache={},JSONPath.toPathString=function(t){for(var e=t,r=e.length,n="$",a=1;a<r;a++)/^(~|\^|@.*?\(\))$/.test(e[a])||(n+=/^[0-9*]+$/.test(e[a])?"["+e[a]+"]":"['"+e[a]+"']");return n},JSONPath.toPointer=function(t){for(var e=t,r=e.length,n="",a=1;a<r;a++)/^(~|\^|@.*?\(\))$/.test(e[a])||(n+="/"+e[a].toString().replace(/~/g,"~0").replace(/\//g,"~1"));return n},JSONPath.toPathArray=function(t){var e=JSONPath.cache;if(e[t])return e[t].concat();var r=[],n=t.replace(/@(?:null|boolean|number|string|integer|undefined|nonFinite|scalar|array|object|function|other)\(\)/g,";$&;").replace(/[['](\??\(.*?\))[\]']/g,function(t,e){return"[#"+(r.push(e)-1)+"]"}).replace(/\['([^'\]]*)'\]/g,function(t,e){return"['"+e.replace(/\./g,"%@%").replace(/~/g,"%%@@%%")+"']"}).replace(/~/g,";~;").replace(/'?\.'?(?![^[]*\])|\['?/g,";").replace(/%@%/g,".").replace(/%%@@%%/g,"~").replace(/(?:;)?(\^+)(?:;)?/g,function(t,e){return";"+e.split("").join(";")+";"}).replace(/;;;|;;/g,";..;").replace(/;$|'?\]|'$/g,"").split(";").map(function(t){var e=t.match(/#([0-9]+)/);return e&&e[1]?r[e[1]]:t});return e[t]=n,e[t]};export{JSONPath};
//# sourceMappingURL=index-es.min.js.map

@@ -399,2 +399,3 @@ (function (global, factory) {

case 'all':
ea.pointer = JSONPath.toPointer(ea.path);
ea.path = typeof ea.path === 'string' ? ea.path : JSONPath.toPathString(ea.path);

@@ -451,2 +452,3 @@ return ea;

if (Array.isArray(elems)) {
// This was causing excessive stack size in Node (with or without Babel) against our performance test: `ret.push(...elems);`
elems.forEach(function (t) {

@@ -708,2 +710,3 @@ ret.push(t);

if (Array.isArray(tmp)) {
// This was causing excessive stack size in Node (with or without Babel) against our performance test: `ret.push(...tmp);`
tmp.forEach(function (t) {

@@ -710,0 +713,0 @@ ret.push(t);

@@ -1,2 +0,2 @@

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.JSONPath={})}(this,function(t){"use strict";function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function r(t){return(r=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function n(t,e){return(n=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function a(t,e,r){return(a=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(t){return!1}}()?Reflect.construct:function(t,e,r){var a=[null];a.push.apply(a,e);var o=new(Function.bind.apply(t,a));return r&&n(o,r.prototype),o}).apply(null,arguments)}function o(t){var e="function"==typeof Map?new Map:void 0;return(o=function(t){if(null===t||(o=t,-1===Function.toString.call(o).indexOf("[native code]")))return t;var o;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,i)}function i(){return a(t,arguments,r(this).constructor)}return i.prototype=Object.create(t.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),n(i,t)})(t)}function i(t,e){return!e||"object"!=typeof e&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}var c=eval,u=!("undefined"==typeof module||!module.exports||"undefined"!=typeof navigator&&"ReactNative"===navigator.product),l=["value","path","pointer","parent","parentProperty","all"],s=Object.prototype.hasOwnProperty,p=u?require("vm"):{runInNewContext:function(t,e){var r=Object.keys(e),n=[];!function(t,e,r){for(var n=t.length,a=0;a<n;a++)r(t[a])&&e.push(t.splice(a--,1)[0])}(r,n,function(t){return"function"==typeof e[t]});var a=n.reduce(function(t,r){var n=e[r].toString();return/function/.exec(n)||(n="function "+n),"var "+r+"="+n+";"+t},"")+r.reduce(function(t,r){return"var "+r+"="+JSON.stringify(e[r]).replace(/\u2028|\u2029/g,function(t){return"\\u202"+("\u2028"===t?"8":"9")})+";"+t},t);return c(a)}};function h(t,e){return(t=t.slice()).push(e),t}function f(t,e){return(e=e.slice()).unshift(t),e}var y=function(t){function e(t){var n;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),(n=i(this,r(e).call(this,'JSONPath should not be called with "new" (it prevents return of (unwrapped) scalar values)'))).avoidNew=!0,n.value=t,n}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&n(t,e)}(e,o(Error)),e}();function v(t,r,n,a,o){if(!(this instanceof v))try{return new v(t,r,n,a,o)}catch(t){if(!t.avoidNew)throw t;return t.value}"string"==typeof t&&(o=a,a=n,n=r,r=t,t={});var i=(t=t||{}).hasOwnProperty("json")&&t.hasOwnProperty("path");if(this.json=t.json||n,this.path=t.path||r,this.resultType=t.resultType&&t.resultType.toLowerCase()||"value",this.flatten=t.flatten||!1,this.wrap=!t.hasOwnProperty("wrap")||t.wrap,this.sandbox=t.sandbox||{},this.preventEval=t.preventEval||!1,this.parent=t.parent||null,this.parentProperty=t.parentProperty||null,this.callback=t.callback||a||null,this.otherTypeCallback=t.otherTypeCallback||o||function(){throw new Error("You must supply an otherTypeCallback callback option with the @other() operator.")},!1!==t.autostart){var c=this.evaluate({path:i?t.path:r,json:i?t.json:n});if(!c||"object"!==e(c))throw new y(c);return c}}v.prototype.evaluate=function(t,r,n,a){var o=this,i=this.parent,c=this.parentProperty,u=this.flatten,s=this.wrap;if(this.currResultType=this.resultType,this.currPreventEval=this.preventEval,this.currSandbox=this.sandbox,n=n||this.callback,this.currOtherTypeCallback=a||this.otherTypeCallback,r=r||this.json,(t=t||this.path)&&"object"===e(t)){if(!t.path)throw new Error('You must supply a "path" property when providing an object argument to JSONPath.evaluate().');r=t.hasOwnProperty("json")?t.json:r,u=t.hasOwnProperty("flatten")?t.flatten:u,this.currResultType=t.hasOwnProperty("resultType")?t.resultType:this.currResultType,this.currSandbox=t.hasOwnProperty("sandbox")?t.sandbox:this.currSandbox,s=t.hasOwnProperty("wrap")?t.wrap:s,this.currPreventEval=t.hasOwnProperty("preventEval")?t.preventEval:this.currPreventEval,n=t.hasOwnProperty("callback")?t.callback:n,this.currOtherTypeCallback=t.hasOwnProperty("otherTypeCallback")?t.otherTypeCallback:this.currOtherTypeCallback,i=t.hasOwnProperty("parent")?t.parent:i,c=t.hasOwnProperty("parentProperty")?t.parentProperty:c,t=t.path}if(i=i||null,c=c||null,Array.isArray(t)&&(t=v.toPathString(t)),t&&r&&l.includes(this.currResultType)){this._obj=r;var p=v.toPathArray(t);"$"===p[0]&&p.length>1&&p.shift(),this._hasParentSelector=null;var h=this._trace(p,r,["$"],i,c,n).filter(function(t){return t&&!t.isParentSelector});return h.length?1!==h.length||s||Array.isArray(h[0].value)?h.reduce(function(t,e){var r=o._getPreferredOutput(e);return u&&Array.isArray(r)?t=t.concat(r):t.push(r),t},[]):this._getPreferredOutput(h[0]):s?[]:void 0}},v.prototype._getPreferredOutput=function(t){var e=this.currResultType;switch(e){case"all":return t.path="string"==typeof t.path?t.path:v.toPathString(t.path),t;case"value":case"parent":case"parentProperty":return t[e];case"path":return v.toPathString(t[e]);case"pointer":return v.toPointer(t.path)}},v.prototype._handleCallback=function(t,e,r){if(e){var n=this._getPreferredOutput(t);t.path="string"==typeof t.path?t.path:v.toPathString(t.path),e(n,r,t)}},v.prototype._trace=function(t,r,n,a,o,i,c){var u,l=this;if(!t.length)return u={path:n,value:r,parent:a,parentProperty:o},this._handleCallback(u,i,"value"),u;var p=t[0],y=t.slice(1),v=[];function b(t){Array.isArray(t)?t.forEach(function(t){v.push(t)}):v.push(t)}if(("string"!=typeof p||c)&&r&&s.call(r,p))b(this._trace(y,r[p],h(n,p),r,p,i));else if("*"===p)this._walk(p,y,r,n,a,o,i,function(t,e,r,n,a,o,i,c){b(l._trace(f(t,r),n,a,o,i,c,!0))});else if(".."===p)b(this._trace(y,r,n,a,o,i)),this._walk(p,y,r,n,a,o,i,function(t,r,n,a,o,i,c,u){"object"===e(a[t])&&b(l._trace(f(r,n),a[t],h(o,t),a,t,u))});else{if("^"===p)return this._hasParentSelector=!0,n.length?{path:n.slice(0,-1),expr:y,isParentSelector:!0}:[];if("~"===p)return u={path:h(n,p),value:o,parent:a,parentProperty:null},this._handleCallback(u,i,"property"),u;if("$"===p)b(this._trace(y,r,n,null,null,i));else if(/^(-?[0-9]*):(-?[0-9]*):?([0-9]*)$/.test(p))b(this._slice(p,y,r,n,a,o,i));else if(0===p.indexOf("?(")){if(this.currPreventEval)throw new Error("Eval [?(expr)] prevented in JSONPath expression.");this._walk(p,y,r,n,a,o,i,function(t,e,r,n,a,o,i,c){l._eval(e.replace(/^\?\((.*?)\)$/,"$1"),n[t],t,a,o,i)&&b(l._trace(f(t,r),n,a,o,i,c))})}else if("("===p[0]){if(this.currPreventEval)throw new Error("Eval [(expr)] prevented in JSONPath expression.");b(this._trace(f(this._eval(p,r,n[n.length-1],n.slice(0,-1),a,o),y),r,n,a,o,i))}else if("@"===p[0]){var d=!1,g=p.slice(1,-2);switch(g){case"scalar":r&&["object","function"].includes(e(r))||(d=!0);break;case"boolean":case"string":case"undefined":case"function":e(r)===g&&(d=!0);break;case"number":e(r)===g&&isFinite(r)&&(d=!0);break;case"nonFinite":"number"!=typeof r||isFinite(r)||(d=!0);break;case"object":r&&e(r)===g&&(d=!0);break;case"array":Array.isArray(r)&&(d=!0);break;case"other":d=this.currOtherTypeCallback(r,n,a,o);break;case"integer":r!==+r||!isFinite(r)||r%1||(d=!0);break;case"null":null===r&&(d=!0)}if(d)return u={path:n,value:r,parent:a,parentProperty:o},this._handleCallback(u,i,"value"),u}else if("`"===p[0]&&r&&s.call(r,p.slice(1))){var P=p.slice(1);b(this._trace(y,r[P],h(n,P),r,P,i,!0))}else if(p.includes(",")){var _=p.split(","),w=!0,O=!1,S=void 0;try{for(var x,k=_[Symbol.iterator]();!(w=(x=k.next()).done);w=!0){var j=x.value;b(this._trace(f(j,y),r,n,a,o,i))}}catch(t){O=!0,S=t}finally{try{w||null==k.return||k.return()}finally{if(O)throw S}}}else!c&&r&&s.call(r,p)&&b(this._trace(y,r[p],h(n,p),r,p,i,!0))}if(this._hasParentSelector)for(var m=0;m<v.length;m++){var E=v[m];if(E.isParentSelector){var T=l._trace(E.expr,r,E.path,a,o,i);if(Array.isArray(T)){v[m]=T[0];for(var $=T.length,A=1;A<$;A++)m++,v.splice(m,0,T[A])}else v[m]=T}}return v},v.prototype._walk=function(t,r,n,a,o,i,c,u){if(Array.isArray(n))for(var l=n.length,p=0;p<l;p++)u(p,t,r,n,a,o,i,c);else if("object"===e(n))for(var h in n)s.call(n,h)&&u(h,t,r,n,a,o,i,c)},v.prototype._slice=function(t,e,r,n,a,o,i){if(Array.isArray(r)){var c=r.length,u=t.split(":"),l=u[2]&&parseInt(u[2],10)||1,s=u[0]&&parseInt(u[0],10)||0,p=u[1]&&parseInt(u[1],10)||c;s=s<0?Math.max(0,s+c):Math.min(c,s),p=p<0?Math.max(0,p+c):Math.min(c,p);for(var h=[],y=s;y<p;y+=l){var v=this._trace(f(y,e),r,n,a,o,i);Array.isArray(v)?v.forEach(function(t){h.push(t)}):h.push(v)}return h}},v.prototype._eval=function(t,e,r,n,a,o){if(!this._obj||!e)return!1;t.includes("@parentProperty")&&(this.currSandbox._$_parentProperty=o,t=t.replace(/@parentProperty/g,"_$_parentProperty")),t.includes("@parent")&&(this.currSandbox._$_parent=a,t=t.replace(/@parent/g,"_$_parent")),t.includes("@property")&&(this.currSandbox._$_property=r,t=t.replace(/@property/g,"_$_property")),t.includes("@path")&&(this.currSandbox._$_path=v.toPathString(n.concat([r])),t=t.replace(/@path/g,"_$_path")),t.match(/@([.\s)[])/)&&(this.currSandbox._$_v=e,t=t.replace(/@([.\s)[])/g,"_$_v$1"));try{return p.runInNewContext(t,this.currSandbox)}catch(e){throw console.log(e),new Error("jsonPath: "+e.message+": "+t)}},v.cache={},v.toPathString=function(t){for(var e=t,r=e.length,n="$",a=1;a<r;a++)/^(~|\^|@.*?\(\))$/.test(e[a])||(n+=/^[0-9*]+$/.test(e[a])?"["+e[a]+"]":"['"+e[a]+"']");return n},v.toPointer=function(t){for(var e=t,r=e.length,n="",a=1;a<r;a++)/^(~|\^|@.*?\(\))$/.test(e[a])||(n+="/"+e[a].toString().replace(/~/g,"~0").replace(/\//g,"~1"));return n},v.toPathArray=function(t){var e=v.cache;if(e[t])return e[t].concat();var r=[],n=t.replace(/@(?:null|boolean|number|string|integer|undefined|nonFinite|scalar|array|object|function|other)\(\)/g,";$&;").replace(/[['](\??\(.*?\))[\]']/g,function(t,e){return"[#"+(r.push(e)-1)+"]"}).replace(/\['([^'\]]*)'\]/g,function(t,e){return"['"+e.replace(/\./g,"%@%").replace(/~/g,"%%@@%%")+"']"}).replace(/~/g,";~;").replace(/'?\.'?(?![^[]*\])|\['?/g,";").replace(/%@%/g,".").replace(/%%@@%%/g,"~").replace(/(?:;)?(\^+)(?:;)?/g,function(t,e){return";"+e.split("").join(";")+";"}).replace(/;;;|;;/g,";..;").replace(/;$|'?\]|'$/g,"").split(";").map(function(t){var e=t.match(/#([0-9]+)/);return e&&e[1]?r[e[1]]:t});return e[t]=n,e[t]},t.JSONPath=v,Object.defineProperty(t,"__esModule",{value:!0})});
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.JSONPath={})}(this,function(t){"use strict";function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function r(t){return(r=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function n(t,e){return(n=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function a(t,e,r){return(a=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(t){return!1}}()?Reflect.construct:function(t,e,r){var a=[null];a.push.apply(a,e);var o=new(Function.bind.apply(t,a));return r&&n(o,r.prototype),o}).apply(null,arguments)}function o(t){var e="function"==typeof Map?new Map:void 0;return(o=function(t){if(null===t||(o=t,-1===Function.toString.call(o).indexOf("[native code]")))return t;var o;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,i)}function i(){return a(t,arguments,r(this).constructor)}return i.prototype=Object.create(t.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),n(i,t)})(t)}function i(t,e){return!e||"object"!=typeof e&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}var c=eval,u=!("undefined"==typeof module||!module.exports||"undefined"!=typeof navigator&&"ReactNative"===navigator.product),l=["value","path","pointer","parent","parentProperty","all"],p=Object.prototype.hasOwnProperty,s=u?require("vm"):{runInNewContext:function(t,e){var r=Object.keys(e),n=[];!function(t,e,r){for(var n=t.length,a=0;a<n;a++)r(t[a])&&e.push(t.splice(a--,1)[0])}(r,n,function(t){return"function"==typeof e[t]});var a=n.reduce(function(t,r){var n=e[r].toString();return/function/.exec(n)||(n="function "+n),"var "+r+"="+n+";"+t},"")+r.reduce(function(t,r){return"var "+r+"="+JSON.stringify(e[r]).replace(/\u2028|\u2029/g,function(t){return"\\u202"+("\u2028"===t?"8":"9")})+";"+t},t);return c(a)}};function h(t,e){return(t=t.slice()).push(e),t}function f(t,e){return(e=e.slice()).unshift(t),e}var y=function(t){function e(t){var n;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),(n=i(this,r(e).call(this,'JSONPath should not be called with "new" (it prevents return of (unwrapped) scalar values)'))).avoidNew=!0,n.value=t,n}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&n(t,e)}(e,o(Error)),e}();function v(t,r,n,a,o){if(!(this instanceof v))try{return new v(t,r,n,a,o)}catch(t){if(!t.avoidNew)throw t;return t.value}"string"==typeof t&&(o=a,a=n,n=r,r=t,t={});var i=(t=t||{}).hasOwnProperty("json")&&t.hasOwnProperty("path");if(this.json=t.json||n,this.path=t.path||r,this.resultType=t.resultType&&t.resultType.toLowerCase()||"value",this.flatten=t.flatten||!1,this.wrap=!t.hasOwnProperty("wrap")||t.wrap,this.sandbox=t.sandbox||{},this.preventEval=t.preventEval||!1,this.parent=t.parent||null,this.parentProperty=t.parentProperty||null,this.callback=t.callback||a||null,this.otherTypeCallback=t.otherTypeCallback||o||function(){throw new Error("You must supply an otherTypeCallback callback option with the @other() operator.")},!1!==t.autostart){var c=this.evaluate({path:i?t.path:r,json:i?t.json:n});if(!c||"object"!==e(c))throw new y(c);return c}}v.prototype.evaluate=function(t,r,n,a){var o=this,i=this.parent,c=this.parentProperty,u=this.flatten,p=this.wrap;if(this.currResultType=this.resultType,this.currPreventEval=this.preventEval,this.currSandbox=this.sandbox,n=n||this.callback,this.currOtherTypeCallback=a||this.otherTypeCallback,r=r||this.json,(t=t||this.path)&&"object"===e(t)){if(!t.path)throw new Error('You must supply a "path" property when providing an object argument to JSONPath.evaluate().');r=t.hasOwnProperty("json")?t.json:r,u=t.hasOwnProperty("flatten")?t.flatten:u,this.currResultType=t.hasOwnProperty("resultType")?t.resultType:this.currResultType,this.currSandbox=t.hasOwnProperty("sandbox")?t.sandbox:this.currSandbox,p=t.hasOwnProperty("wrap")?t.wrap:p,this.currPreventEval=t.hasOwnProperty("preventEval")?t.preventEval:this.currPreventEval,n=t.hasOwnProperty("callback")?t.callback:n,this.currOtherTypeCallback=t.hasOwnProperty("otherTypeCallback")?t.otherTypeCallback:this.currOtherTypeCallback,i=t.hasOwnProperty("parent")?t.parent:i,c=t.hasOwnProperty("parentProperty")?t.parentProperty:c,t=t.path}if(i=i||null,c=c||null,Array.isArray(t)&&(t=v.toPathString(t)),t&&r&&l.includes(this.currResultType)){this._obj=r;var s=v.toPathArray(t);"$"===s[0]&&s.length>1&&s.shift(),this._hasParentSelector=null;var h=this._trace(s,r,["$"],i,c,n).filter(function(t){return t&&!t.isParentSelector});return h.length?1!==h.length||p||Array.isArray(h[0].value)?h.reduce(function(t,e){var r=o._getPreferredOutput(e);return u&&Array.isArray(r)?t=t.concat(r):t.push(r),t},[]):this._getPreferredOutput(h[0]):p?[]:void 0}},v.prototype._getPreferredOutput=function(t){var e=this.currResultType;switch(e){case"all":return t.pointer=v.toPointer(t.path),t.path="string"==typeof t.path?t.path:v.toPathString(t.path),t;case"value":case"parent":case"parentProperty":return t[e];case"path":return v.toPathString(t[e]);case"pointer":return v.toPointer(t.path)}},v.prototype._handleCallback=function(t,e,r){if(e){var n=this._getPreferredOutput(t);t.path="string"==typeof t.path?t.path:v.toPathString(t.path),e(n,r,t)}},v.prototype._trace=function(t,r,n,a,o,i,c){var u,l=this;if(!t.length)return u={path:n,value:r,parent:a,parentProperty:o},this._handleCallback(u,i,"value"),u;var s=t[0],y=t.slice(1),v=[];function b(t){Array.isArray(t)?t.forEach(function(t){v.push(t)}):v.push(t)}if(("string"!=typeof s||c)&&r&&p.call(r,s))b(this._trace(y,r[s],h(n,s),r,s,i));else if("*"===s)this._walk(s,y,r,n,a,o,i,function(t,e,r,n,a,o,i,c){b(l._trace(f(t,r),n,a,o,i,c,!0))});else if(".."===s)b(this._trace(y,r,n,a,o,i)),this._walk(s,y,r,n,a,o,i,function(t,r,n,a,o,i,c,u){"object"===e(a[t])&&b(l._trace(f(r,n),a[t],h(o,t),a,t,u))});else{if("^"===s)return this._hasParentSelector=!0,n.length?{path:n.slice(0,-1),expr:y,isParentSelector:!0}:[];if("~"===s)return u={path:h(n,s),value:o,parent:a,parentProperty:null},this._handleCallback(u,i,"property"),u;if("$"===s)b(this._trace(y,r,n,null,null,i));else if(/^(-?[0-9]*):(-?[0-9]*):?([0-9]*)$/.test(s))b(this._slice(s,y,r,n,a,o,i));else if(0===s.indexOf("?(")){if(this.currPreventEval)throw new Error("Eval [?(expr)] prevented in JSONPath expression.");this._walk(s,y,r,n,a,o,i,function(t,e,r,n,a,o,i,c){l._eval(e.replace(/^\?\((.*?)\)$/,"$1"),n[t],t,a,o,i)&&b(l._trace(f(t,r),n,a,o,i,c))})}else if("("===s[0]){if(this.currPreventEval)throw new Error("Eval [(expr)] prevented in JSONPath expression.");b(this._trace(f(this._eval(s,r,n[n.length-1],n.slice(0,-1),a,o),y),r,n,a,o,i))}else if("@"===s[0]){var d=!1,g=s.slice(1,-2);switch(g){case"scalar":r&&["object","function"].includes(e(r))||(d=!0);break;case"boolean":case"string":case"undefined":case"function":e(r)===g&&(d=!0);break;case"number":e(r)===g&&isFinite(r)&&(d=!0);break;case"nonFinite":"number"!=typeof r||isFinite(r)||(d=!0);break;case"object":r&&e(r)===g&&(d=!0);break;case"array":Array.isArray(r)&&(d=!0);break;case"other":d=this.currOtherTypeCallback(r,n,a,o);break;case"integer":r!==+r||!isFinite(r)||r%1||(d=!0);break;case"null":null===r&&(d=!0)}if(d)return u={path:n,value:r,parent:a,parentProperty:o},this._handleCallback(u,i,"value"),u}else if("`"===s[0]&&r&&p.call(r,s.slice(1))){var P=s.slice(1);b(this._trace(y,r[P],h(n,P),r,P,i,!0))}else if(s.includes(",")){var _=s.split(","),w=!0,O=!1,S=void 0;try{for(var x,k=_[Symbol.iterator]();!(w=(x=k.next()).done);w=!0){var j=x.value;b(this._trace(f(j,y),r,n,a,o,i))}}catch(t){O=!0,S=t}finally{try{w||null==k.return||k.return()}finally{if(O)throw S}}}else!c&&r&&p.call(r,s)&&b(this._trace(y,r[s],h(n,s),r,s,i,!0))}if(this._hasParentSelector)for(var m=0;m<v.length;m++){var E=v[m];if(E.isParentSelector){var T=l._trace(E.expr,r,E.path,a,o,i);if(Array.isArray(T)){v[m]=T[0];for(var $=T.length,A=1;A<$;A++)m++,v.splice(m,0,T[A])}else v[m]=T}}return v},v.prototype._walk=function(t,r,n,a,o,i,c,u){if(Array.isArray(n))for(var l=n.length,s=0;s<l;s++)u(s,t,r,n,a,o,i,c);else if("object"===e(n))for(var h in n)p.call(n,h)&&u(h,t,r,n,a,o,i,c)},v.prototype._slice=function(t,e,r,n,a,o,i){if(Array.isArray(r)){var c=r.length,u=t.split(":"),l=u[2]&&parseInt(u[2],10)||1,p=u[0]&&parseInt(u[0],10)||0,s=u[1]&&parseInt(u[1],10)||c;p=p<0?Math.max(0,p+c):Math.min(c,p),s=s<0?Math.max(0,s+c):Math.min(c,s);for(var h=[],y=p;y<s;y+=l){var v=this._trace(f(y,e),r,n,a,o,i);Array.isArray(v)?v.forEach(function(t){h.push(t)}):h.push(v)}return h}},v.prototype._eval=function(t,e,r,n,a,o){if(!this._obj||!e)return!1;t.includes("@parentProperty")&&(this.currSandbox._$_parentProperty=o,t=t.replace(/@parentProperty/g,"_$_parentProperty")),t.includes("@parent")&&(this.currSandbox._$_parent=a,t=t.replace(/@parent/g,"_$_parent")),t.includes("@property")&&(this.currSandbox._$_property=r,t=t.replace(/@property/g,"_$_property")),t.includes("@path")&&(this.currSandbox._$_path=v.toPathString(n.concat([r])),t=t.replace(/@path/g,"_$_path")),t.match(/@([.\s)[])/)&&(this.currSandbox._$_v=e,t=t.replace(/@([.\s)[])/g,"_$_v$1"));try{return s.runInNewContext(t,this.currSandbox)}catch(e){throw console.log(e),new Error("jsonPath: "+e.message+": "+t)}},v.cache={},v.toPathString=function(t){for(var e=t,r=e.length,n="$",a=1;a<r;a++)/^(~|\^|@.*?\(\))$/.test(e[a])||(n+=/^[0-9*]+$/.test(e[a])?"["+e[a]+"]":"['"+e[a]+"']");return n},v.toPointer=function(t){for(var e=t,r=e.length,n="",a=1;a<r;a++)/^(~|\^|@.*?\(\))$/.test(e[a])||(n+="/"+e[a].toString().replace(/~/g,"~0").replace(/\//g,"~1"));return n},v.toPathArray=function(t){var e=v.cache;if(e[t])return e[t].concat();var r=[],n=t.replace(/@(?:null|boolean|number|string|integer|undefined|nonFinite|scalar|array|object|function|other)\(\)/g,";$&;").replace(/[['](\??\(.*?\))[\]']/g,function(t,e){return"[#"+(r.push(e)-1)+"]"}).replace(/\['([^'\]]*)'\]/g,function(t,e){return"['"+e.replace(/\./g,"%@%").replace(/~/g,"%%@@%%")+"']"}).replace(/~/g,";~;").replace(/'?\.'?(?![^[]*\])|\['?/g,";").replace(/%@%/g,".").replace(/%%@@%%/g,"~").replace(/(?:;)?(\^+)(?:;)?/g,function(t,e){return";"+e.split("").join(";")+";"}).replace(/;;;|;;/g,";..;").replace(/;$|'?\]|'$/g,"").split(";").map(function(t){var e=t.match(/#([0-9]+)/);return e&&e[1]?r[e[1]]:t});return e[t]=n,e[t]},t.JSONPath=v,Object.defineProperty(t,"__esModule",{value:!0})});
//# sourceMappingURL=index-umd.min.js.map
{
"author": "Stefan Goessner",
"name": "jsonpath-plus",
"version": "0.18.0",
"version": "0.18.1",
"main": "dist/index-umd.js",

@@ -6,0 +6,0 @@ "module": "dist/index-es.js",

@@ -6,3 +6,3 @@ # JSONPath Plus [![build status](https://secure.travis-ci.org/s3u/JSONPath.png)](http://travis-ci.org/s3u/JSONPath)

**Note that `jsonpath-plus` is currently suffering from [performance problems](https://github.com/s3u/JSONPath/issues/14)
**Note that `jsonpath-plus` may be suffering from [performance problems](https://github.com/s3u/JSONPath/issues/14)
and the maintainers are not currently able to work on resolving.

@@ -9,0 +9,0 @@ You may wish to use [jsonpath](https://www.npmjs.com/package/jsonpath)

@@ -225,2 +225,3 @@ /* eslint-disable no-eval */

case 'all':
ea.pointer = JSONPath.toPointer(ea.path);
ea.path = typeof ea.path === 'string' ? ea.path : JSONPath.toPathString(ea.path);

@@ -266,2 +267,3 @@ return ea;

if (Array.isArray(elems)) {
// This was causing excessive stack size in Node (with or without Babel) against our performance test: `ret.push(...elems);`
elems.forEach((t) => {

@@ -445,2 +447,3 @@ ret.push(t);

if (Array.isArray(tmp)) {
// This was causing excessive stack size in Node (with or without Babel) against our performance test: `ret.push(...tmp);`
tmp.forEach((t) => {

@@ -447,0 +450,0 @@ ret.push(t);

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc