Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jsonpath-plus

Package Overview
Dependencies
Maintainers
1
Versions
43
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 3.0.0 to 4.0.0

.babelrc.json

167

.eslintrc.js

@@ -0,78 +1,93 @@

'use strict';
module.exports = {
"extends": ["ash-nazg/sauron-node"],
parser: 'babel-eslint',
"settings": {
"polyfills": [
"Array.isArray",
"console",
"Date.now",
"document.head",
"document.querySelector",
"JSON",
"Object.keys",
'Object.values',
"XMLHttpRequest"
]
},
"overrides": [
{
"files": ["src/jsonpath.js", "test-helpers/node-env.js"],
// Apparent bug with `overrides` necessitating this
"globals": {
"require": "readonly",
"run": "readonly",
"module": "readonly"
},
rules: {
"node/no-unsupported-features/es-syntax": ["error", {
ignores: ['regexpNamedCaptureGroups', 'modules', 'dynamicImport']
}]
}
},
{
"files": ["*.md"],
"rules": {
"import/unambiguous": 0,
"import/no-commonjs": 0,
"import/no-unresolved": ["error", {"ignore": ["jsonpath-plus"]}],
"no-undef": 0,
"no-unused-vars": ["error", {
"varsIgnorePattern": "json|result"
}],
"node/no-missing-require": ["error", {
"allowModules": ["jsonpath-plus"]
}],
"node/no-missing-import": ["error", {
"allowModules": ["jsonpath-plus"]
}]
}
},
{
"files": ["test/**"],
"extends": [
"plugin:chai-expect/recommended",
"plugin:chai-friendly/recommended"
],
"globals": {
"assert": "readonly",
"expect": "readonly",
"jsonpath": "readonly"
},
"env": {"mocha": true},
"rules": {
"quotes": 0,
"import/unambiguous": 0,
// Todo: Reenable
"max-len": 0
}
}
],
"rules": {
"indent": ["error", 4, {"outerIIFEBody": 0}],
"promise/prefer-await-to-callbacks": 0,
"quote-props": 0,
"require-jsdoc": 0,
// Reenable when no longer having problems
"unicorn/no-unsafe-regex": 0
}
'extends': ['ash-nazg/sauron-node'],
parser: 'babel-eslint',
'settings': {
'polyfills': [
'Array.isArray',
'console',
'Date.now',
'document.head',
'document.querySelector',
'JSON',
'Number.isFinite',
'Number.parseInt',
'Object.keys',
'Object.values',
'XMLHttpRequest'
]
},
'overrides': [
{
files: ['.eslintrc.js', '.mocharc.js'],
extends: ['plugin:node/recommended-script'],
rules: {
'import/no-commonjs': 'off',
'import/ambiguous': 'off'
}
},
{
'files': ['src/jsonpath.js', 'test-helpers/node-env.js'],
// Apparent bug with `overrides` necessitating this
'globals': {
'require': 'readonly',
'run': 'readonly',
'module': 'readonly'
},
rules: {
'node/no-unsupported-features/es-syntax': ['error', {
ignores: [
'regexpNamedCaptureGroups', 'modules', 'dynamicImport'
]
}]
}
},
{
'files': ['*.md'],
'rules': {
'import/unambiguous': 0,
'import/no-commonjs': 0,
'import/no-unresolved': ['error', {
'ignore': ['jsonpath-plus']
}],
'no-undef': 0,
'no-unused-vars': ['error', {
'varsIgnorePattern': 'json|result'
}],
'node/no-missing-require': ['error', {
'allowModules': ['jsonpath-plus']
}],
'node/no-missing-import': ['error', {
'allowModules': ['jsonpath-plus']
}]
}
},
{
'files': ['test/**'],
'extends': [
'plugin:chai-expect/recommended',
'plugin:chai-friendly/recommended'
],
'globals': {
'assert': 'readonly',
'expect': 'readonly',
'jsonpath': 'readonly'
},
'env': {'mocha': true},
'rules': {
'quotes': 0,
'import/unambiguous': 0,
// Todo: Reenable
'max-len': 0
}
}
],
'rules': {
'indent': ['error', 4, {'outerIIFEBody': 0}],
'promise/prefer-await-to-callbacks': 0,
'quote-props': 0,
'require-jsdoc': 0,
// Reenable when no longer having problems
'unicorn/no-unsafe-regex': 0
}
};
# CHANGES for jsonpath-plus
## 4.0.0 (2020-04-09)
- Breaking change/fix: Disallow `resultType` from being lower-cased
(broke `parentProperty`)
- Breaking change: Expect Node >= 10
- Build: As per latest rollup
- Linting: Check hidden files; update as per latest ash-nazg
- Docs: Update coverage badge
- npm: Update devDeps
## 3.0.0 (2020-01-13)

@@ -4,0 +14,0 @@

function _typeof(obj) {
"@babel/helpers - typeof";
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {

@@ -52,3 +54,3 @@ _typeof = function (obj) {

function isNativeReflectConstruct() {
function _isNativeReflectConstruct() {
if (typeof Reflect === "undefined" || !Reflect.construct) return false;

@@ -67,3 +69,3 @@ if (Reflect.construct.sham) return false;

function _construct(Parent, args, Class) {
if (isNativeReflectConstruct()) {
if (_isNativeReflectConstruct()) {
_construct = Reflect.construct;

@@ -138,22 +140,107 @@ } else {

function _createSuper(Derived) {
return function () {
var Super = _getPrototypeOf(Derived),
result;
if (_isNativeReflectConstruct()) {
var NewTarget = _getPrototypeOf(this).constructor;
result = Reflect.construct(Super, arguments, NewTarget);
} else {
result = Super.apply(this, arguments);
}
return _possibleConstructorReturn(this, result);
};
}
function _toConsumableArray(arr) {
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread();
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
}
function _arrayWithoutHoles(arr) {
if (Array.isArray(arr)) {
for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
return arr2;
}
if (Array.isArray(arr)) return _arrayLikeToArray(arr);
}
function _iterableToArray(iter) {
if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter);
if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter);
}
function _unsupportedIterableToArray(o, minLen) {
if (!o) return;
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
var n = Object.prototype.toString.call(o).slice(8, -1);
if (n === "Object" && o.constructor) n = o.constructor.name;
if (n === "Map" || n === "Set") return Array.from(n);
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
}
function _arrayLikeToArray(arr, len) {
if (len == null || len > arr.length) len = arr.length;
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
return arr2;
}
function _nonIterableSpread() {
throw new TypeError("Invalid attempt to spread non-iterable instance");
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 _createForOfIteratorHelper(o) {
if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) {
if (Array.isArray(o) || (o = _unsupportedIterableToArray(o))) {
var i = 0;
var F = function () {};
return {
s: F,
n: function () {
if (i >= o.length) return {
done: true
};
return {
done: false,
value: o[i++]
};
},
e: function (e) {
throw e;
},
f: F
};
}
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 it,
normalCompletion = true,
didErr = false,
err;
return {
s: function () {
it = o[Symbol.iterator]();
},
n: function () {
var step = it.next();
normalCompletion = step.done;
return step;
},
e: function (e) {
didErr = true;
err = e;
},
f: function () {
try {
if (!normalCompletion && it.return != null) it.return();
} finally {
if (didErr) throw err;
}
}
};
}
/* eslint-disable prefer-named-capture-group */

@@ -222,3 +309,3 @@ // Disabled `prefer-named-capture-group` due to https://github.com/babel/babel/issues/8951#issuecomment-508045524

if (!/function/.exec(fString)) {
if (!/function/.test(fString)) {
fString = 'function ' + fString;

@@ -277,7 +364,7 @@ }

var NewError =
/*#__PURE__*/
function (_Error) {
var NewError = /*#__PURE__*/function (_Error) {
_inherits(NewError, _Error);
var _super = _createSuper(NewError);
/**

@@ -291,3 +378,3 @@ * @param {any} value The evaluated scalar value

_this = _possibleConstructorReturn(this, _getPrototypeOf(NewError).call(this, 'JSONPath should not be called with "new" (it prevents return ' + 'of (unwrapped) scalar values)'));
_this = _super.call(this, 'JSONPath should not be called with "new" (it prevents return ' + 'of (unwrapped) scalar values)');
_this.avoidNew = true;

@@ -300,3 +387,3 @@ _this.value = value;

return NewError;
}(_wrapNativeSuper(Error));
}( /*#__PURE__*/_wrapNativeSuper(Error));
/**

@@ -388,3 +475,3 @@ * @typedef {PlainObject} ReturnObject

this.path = opts.path || expr;
this.resultType = opts.resultType && opts.resultType.toLowerCase() || 'value';
this.resultType = opts.resultType || 'value';
this.flatten = opts.flatten || false;

@@ -439,11 +526,12 @@ this.wrap = hasOwnProp.call(opts, 'wrap') ? opts.wrap : true;

if (expr && _typeof(expr) === 'object' && !Array.isArray(expr)) {
if (!expr.path) {
if (!expr.path && expr.path !== '') {
throw new TypeError('You must supply a "path" property when providing an object ' + 'argument to JSONPath.evaluate().');
}
if (!('json' in expr)) {
if (!hasOwnProp.call(expr, 'json')) {
throw new TypeError('You must supply a "json" property when providing an object ' + 'argument to JSONPath.evaluate().');
}
json = hasOwnProp.call(expr, 'json') ? expr.json : json;
var _expr = expr;
json = _expr.json;
flatten = hasOwnProp.call(expr, 'flatten') ? expr.flatten : flatten;

@@ -468,3 +556,3 @@ this.currResultType = hasOwnProp.call(expr, 'resultType') ? expr.resultType : this.currResultType;

if (!expr || !json) {
if (!expr && expr !== '' || !json) {
return undefined;

@@ -516,5 +604,8 @@ }

case 'all':
ea.pointer = JSONPath.toPointer(ea.path);
ea.path = typeof ea.path === 'string' ? ea.path : JSONPath.toPathString(ea.path);
return ea;
{
var path = Array.isArray(ea.path) ? ea.path : JSONPath.toPathArray(ea.path);
ea.pointer = JSONPath.toPointer(path);
ea.path = typeof ea.path === 'string' ? ea.path : JSONPath.toPathString(ea.path);
return ea;
}

@@ -628,7 +719,7 @@ case 'value':

this._hasParentSelector = true;
return path.length ? {
return {
path: path.slice(0, -1),
expr: x,
isParentSelector: true
} : [];
};
} else if (loc === '~') {

@@ -701,5 +792,11 @@ // property name

case 'integer':
if (Number.isFinite(val) && !(val % 1)) {
addType = true;
}
break;
case 'number':
// eslint-disable-next-line valid-typeof
if (_typeof(val) === valueType && isFinite(val)) {
if (Number.isFinite(val)) {
addType = true;

@@ -711,3 +808,3 @@ }

case 'nonFinite':
if (typeof val === 'number' && !isFinite(val)) {
if (typeof val === 'number' && !Number.isFinite(val)) {
addType = true;

@@ -737,9 +834,2 @@ }

case 'integer':
if (val === Number(val) && isFinite(val) && !(val % 1)) {
addType = true;
}
break;
case 'null':

@@ -772,8 +862,8 @@ if (val === null) {

var parts = loc.split(',');
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
var _iterator = _createForOfIteratorHelper(parts),
_step;
try {
for (var _iterator = parts[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
for (_iterator.s(); !(_step = _iterator.n()).done;) {
var part = _step.value;

@@ -784,14 +874,5 @@ addRet(this._trace(unshift(part, x), val, path, parent, parentPropName, callback, true));

} catch (err) {
_didIteratorError = true;
_iteratorError = err;
_iterator.e(err);
} finally {
try {
if (!_iteratorNormalCompletion && _iterator["return"] != null) {
_iterator["return"]();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
_iterator.f();
}

@@ -837,8 +918,6 @@ } else if (!literalPriority && val && hasOwnProp.call(val, loc)) {

}
} else if (_typeof(val) === 'object') {
for (var m in val) {
if (hasOwnProp.call(val, m)) {
f(m, loc, expr, val, path, parent, parentPropName, callback);
}
}
} else if (val && _typeof(val) === 'object') {
Object.keys(val).forEach(function (m) {
f(m, loc, expr, val, path, parent, parentPropName, callback);
});
}

@@ -854,5 +933,5 @@ };

parts = loc.split(':'),
step = parts[2] && parseInt(parts[2]) || 1;
var start = parts[0] && parseInt(parts[0]) || 0,
end = parts[1] && parseInt(parts[1]) || len;
step = parts[2] && Number.parseInt(parts[2]) || 1;
var start = parts[0] && Number.parseInt(parts[0]) || 0,
end = parts[1] && Number.parseInt(parts[1]) || len;
start = start < 0 ? Math.max(0, start + len) : Math.min(len, start);

@@ -859,0 +938,0 @@ end = end < 0 ? Math.max(0, end + len) : Math.min(len, end);

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

function t(r){return(t="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})(r)}function r(t){return(r=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function e(t,r){return(e=Object.setPrototypeOf||function(t,r){return t.__proto__=r,t})(t,r)}function n(){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 a(t,r,u){return(a=n()?Reflect.construct:function(t,r,n){var a=[null];a.push.apply(a,r);var u=new(Function.bind.apply(t,a));return n&&e(u,n.prototype),u}).apply(null,arguments)}function u(t){var n="function"==typeof Map?new Map:void 0;return(u=function(t){if(null===t||(u=t,-1===Function.toString.call(u).indexOf("[native code]")))return t;var u;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==n){if(n.has(t))return n.get(t);n.set(t,o)}function o(){return a(t,arguments,r(this).constructor)}return o.prototype=Object.create(t.prototype,{constructor:{value:o,enumerable:!1,writable:!0,configurable:!0}}),e(o,t)})(t)}function o(t,r){return!r||"object"!=typeof r&&"function"!=typeof r?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):r}function i(t){return function(t){if(Array.isArray(t)){for(var r=0,e=new Array(t.length);r<t.length;r++)e[r]=t[r];return e}}(t)||function(t){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t))return Array.from(t)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}var c=Object.prototype.hasOwnProperty;f.nodeVMSupported=function(){try{return"[object process]"===Object.prototype.toString.call(global.process)}catch(t){return!1}}();var l=f.nodeVMSupported?require("vm"):{runInNewContext:function(t,r){var e=Object.keys(r),n=[];!function(t,r,e){for(var n=t.length,a=0;a<n;a++){e(t[a])&&r.push(t.splice(a--,1)[0])}}(e,n,(function(t){return"function"==typeof r[t]}));var u=e.map((function(t,e){return r[t]}));(t=n.reduce((function(t,e){var n=r[e].toString();return/function/.exec(n)||(n="function "+n),"var "+e+"="+n+";"+t}),"")+t).match(/(["'])use strict\1/)||e.includes("arguments")||(t="var arguments = undefined;"+t);var o=(t=t.replace(/;[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]*$/,"")).lastIndexOf(";"),c=o>-1?t.slice(0,o+1)+" return "+t.slice(o+1):" return "+t;return a(Function,i(e).concat([c])).apply(void 0,i(u))}};function p(t,r){return(t=t.slice()).push(r),t}function s(t,r){return(r=r.slice()).unshift(t),r}var h=function(t){function n(t){var e;return function(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this,n),(e=o(this,r(n).call(this,'JSONPath should not be called with "new" (it prevents return of (unwrapped) scalar values)'))).avoidNew=!0,e.value=t,e.name="NewError",e}return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(r&&r.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),r&&e(t,r)}(n,u(Error)),n}();function f(r,e,n,a,u){if(!(this instanceof f))try{return new f(r,e,n,a,u)}catch(t){if(!t.avoidNew)throw t;return t.value}"string"==typeof r&&(u=a,a=n,n=e,e=r,r=null);var o=r&&"object"===t(r);if(r=r||{},this.json=r.json||n,this.path=r.path||e,this.resultType=r.resultType&&r.resultType.toLowerCase()||"value",this.flatten=r.flatten||!1,this.wrap=!c.call(r,"wrap")||r.wrap,this.sandbox=r.sandbox||{},this.preventEval=r.preventEval||!1,this.parent=r.parent||null,this.parentProperty=r.parentProperty||null,this.callback=r.callback||a||null,this.otherTypeCallback=r.otherTypeCallback||u||function(){throw new TypeError("You must supply an otherTypeCallback callback option with the @other() operator.")},!1!==r.autostart){var i={path:o?r.path:e};o?"json"in r&&(i.json=r.json):i.json=n;var l=this.evaluate(i);if(!l||"object"!==t(l))throw new h(l);return l}}f.prototype.evaluate=function(r,e,n,a){var u=this,o=this.parent,i=this.parentProperty,l=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,e=e||this.json,(r=r||this.path)&&"object"===t(r)&&!Array.isArray(r)){if(!r.path)throw new TypeError('You must supply a "path" property when providing an object argument to JSONPath.evaluate().');if(!("json"in r))throw new TypeError('You must supply a "json" property when providing an object argument to JSONPath.evaluate().');e=c.call(r,"json")?r.json:e,l=c.call(r,"flatten")?r.flatten:l,this.currResultType=c.call(r,"resultType")?r.resultType:this.currResultType,this.currSandbox=c.call(r,"sandbox")?r.sandbox:this.currSandbox,p=c.call(r,"wrap")?r.wrap:p,this.currPreventEval=c.call(r,"preventEval")?r.preventEval:this.currPreventEval,n=c.call(r,"callback")?r.callback:n,this.currOtherTypeCallback=c.call(r,"otherTypeCallback")?r.otherTypeCallback:this.currOtherTypeCallback,o=c.call(r,"parent")?r.parent:o,i=c.call(r,"parentProperty")?r.parentProperty:i,r=r.path}if(o=o||null,i=i||null,Array.isArray(r)&&(r=f.toPathString(r)),r&&e){this._obj=e;var s=f.toPathArray(r);"$"===s[0]&&s.length>1&&s.shift(),this._hasParentSelector=null;var h=this._trace(s,e,["$"],o,i,n).filter((function(t){return t&&!t.isParentSelector}));return h.length?p||1!==h.length||h[0].hasArrExpr?h.reduce((function(t,r){var e=u._getPreferredOutput(r);return l&&Array.isArray(e)?t=t.concat(e):t.push(e),t}),[]):this._getPreferredOutput(h[0]):p?[]:void 0}},f.prototype._getPreferredOutput=function(t){var r=this.currResultType;switch(r){default:throw new TypeError("Unknown result type");case"all":return t.pointer=f.toPointer(t.path),t.path="string"==typeof t.path?t.path:f.toPathString(t.path),t;case"value":case"parent":case"parentProperty":return t[r];case"path":return f.toPathString(t[r]);case"pointer":return f.toPointer(t.path)}},f.prototype._handleCallback=function(t,r,e){if(r){var n=this._getPreferredOutput(t);t.path="string"==typeof t.path?t.path:f.toPathString(t.path),r(n,e,t)}},f.prototype._trace=function(r,e,n,a,u,o,i,l){var h,f=this;if(!r.length)return h={path:n,value:e,parent:a,parentProperty:u,hasArrExpr:i},this._handleCallback(h,o,"value"),h;var F=r[0],y=r.slice(1),v=[];function b(t){Array.isArray(t)?t.forEach((function(t){v.push(t)})):v.push(t)}if(("string"!=typeof F||l)&&e&&c.call(e,F))b(this._trace(y,e[F],p(n,F),e,F,o,i));else if("*"===F)this._walk(F,y,e,n,a,u,o,(function(t,r,e,n,a,u,o,i){b(f._trace(s(t,e),n,a,u,o,i,!0,!0))}));else if(".."===F)b(this._trace(y,e,n,a,u,o,i)),this._walk(F,y,e,n,a,u,o,(function(r,e,n,a,u,o,i,c){"object"===t(a[r])&&b(f._trace(s(e,n),a[r],p(u,r),a,r,c,!0))}));else{if("^"===F)return this._hasParentSelector=!0,n.length?{path:n.slice(0,-1),expr:y,isParentSelector:!0}:[];if("~"===F)return h={path:p(n,F),value:u,parent:a,parentProperty:null},this._handleCallback(h,o,"property"),h;if("$"===F)b(this._trace(y,e,n,null,null,o,i));else if(/^(\x2D?[0-9]*):(\x2D?[0-9]*):?([0-9]*)$/.test(F))b(this._slice(F,y,e,n,a,u,o));else if(0===F.indexOf("?(")){if(this.currPreventEval)throw new Error("Eval [?(expr)] prevented in JSONPath expression.");this._walk(F,y,e,n,a,u,o,(function(t,r,e,n,a,u,o,i){f._eval(r.replace(/^\?\(((?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*?)\)$/,"$1"),n[t],t,a,u,o)&&b(f._trace(s(t,e),n,a,u,o,i,!0))}))}else if("("===F[0]){if(this.currPreventEval)throw new Error("Eval [(expr)] prevented in JSONPath expression.");b(this._trace(s(this._eval(F,e,n[n.length-1],n.slice(0,-1),a,u),y),e,n,a,u,o,i))}else if("@"===F[0]){var D=!1,g=F.slice(1,-2);switch(g){default:throw new TypeError("Unknown value type "+g);case"scalar":e&&["object","function"].includes(t(e))||(D=!0);break;case"boolean":case"string":case"undefined":case"function":t(e)===g&&(D=!0);break;case"number":t(e)===g&&isFinite(e)&&(D=!0);break;case"nonFinite":"number"!=typeof e||isFinite(e)||(D=!0);break;case"object":e&&t(e)===g&&(D=!0);break;case"array":Array.isArray(e)&&(D=!0);break;case"other":D=this.currOtherTypeCallback(e,n,a,u);break;case"integer":e!==Number(e)||!isFinite(e)||e%1||(D=!0);break;case"null":null===e&&(D=!0)}if(D)return h={path:n,value:e,parent:a,parentProperty:u},this._handleCallback(h,o,"value"),h}else if("`"===F[0]&&e&&c.call(e,F.slice(1))){var d=F.slice(1);b(this._trace(y,e[d],p(n,d),e,d,o,i,!0))}else if(F.includes(",")){var _=F.split(","),w=!0,P=!1,x=void 0;try{for(var E,S=_[Symbol.iterator]();!(w=(E=S.next()).done);w=!0){var j=E.value;b(this._trace(s(j,y),e,n,a,u,o,!0))}}catch(t){P=!0,x=t}finally{try{w||null==S.return||S.return()}finally{if(P)throw x}}}else!l&&e&&c.call(e,F)&&b(this._trace(y,e[F],p(n,F),e,F,o,i,!0))}if(this._hasParentSelector)for(var m=0;m<v.length;m++){var C=v[m];if(C&&C.isParentSelector){var k=f._trace(C.expr,e,C.path,a,u,o,i);if(Array.isArray(k)){v[m]=k[0];for(var A=k.length,O=1;O<A;O++)m++,v.splice(m,0,k[O])}else v[m]=k}}return v},f.prototype._walk=function(r,e,n,a,u,o,i,l){if(Array.isArray(n))for(var p=n.length,s=0;s<p;s++)l(s,r,e,n,a,u,o,i);else if("object"===t(n))for(var h in n)c.call(n,h)&&l(h,r,e,n,a,u,o,i)},f.prototype._slice=function(t,r,e,n,a,u,o){if(Array.isArray(e)){var i=e.length,c=t.split(":"),l=c[2]&&parseInt(c[2])||1,p=c[0]&&parseInt(c[0])||0,h=c[1]&&parseInt(c[1])||i;p=p<0?Math.max(0,p+i):Math.min(i,p),h=h<0?Math.max(0,h+i):Math.min(i,h);for(var f=[],F=p;F<h;F+=l){this._trace(s(F,r),e,n,a,u,o,!0).forEach((function(t){f.push(t)}))}return f}},f.prototype._eval=function(t,r,e,n,a,u){if(!this._obj||!r)return!1;t.includes("@parentProperty")&&(this.currSandbox._$_parentProperty=u,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=e,t=t.replace(/@property/g,"_$_property")),t.includes("@path")&&(this.currSandbox._$_path=f.toPathString(n.concat([e])),t=t.replace(/@path/g,"_$_path")),t.includes("@root")&&(this.currSandbox._$_root=this.json,t=t.replace(/@root/g,"_$_root")),t.match(/@([\t-\r \)\.\[\xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF])/)&&(this.currSandbox._$_v=r,t=t.replace(/@([\t-\r \)\.\[\xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF])/g,"_$_v$1"));try{return l.runInNewContext(t,this.currSandbox)}catch(r){throw console.log(r),new Error("jsonPath: "+r.message+": "+t)}},f.cache={},f.toPathString=function(t){for(var r=t,e=r.length,n="$",a=1;a<e;a++)/^(~|\^|@(?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*?\(\))$/.test(r[a])||(n+=/^[\*0-9]+$/.test(r[a])?"["+r[a]+"]":"['"+r[a]+"']");return n},f.toPointer=function(t){for(var r=t,e=r.length,n="",a=1;a<e;a++)/^(~|\^|@(?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*?\(\))$/.test(r[a])||(n+="/"+r[a].toString().replace(/~/g,"~0").replace(/\//g,"~1"));return n},f.toPathArray=function(t){var r=f.cache;if(r[t])return r[t].concat();var e=[],n=t.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])*?\))['\]]/g,(function(t,r){return"[#"+(e.push(r)-1)+"]"})).replace(/\['((?:[\0-&\(-\\\^-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*)'\]/g,(function(t,r){return"['"+r.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(t,r){return";"+r.split("").join(";")+";"})).replace(/;;;|;;/g,";..;").replace(/;$|'?\]|'$/g,"").split(";").map((function(t){var r=t.match(/#([0-9]+)/);return r&&r[1]?e[r[1]]:t}));return r[t]=n,r[t]};export{f as JSONPath};
function t(r){return(t="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})(r)}function r(t){return(r=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function e(t,r){return(e=Object.setPrototypeOf||function(t,r){return t.__proto__=r,t})(t,r)}function n(){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 a(t,r,u){return(a=n()?Reflect.construct:function(t,r,n){var a=[null];a.push.apply(a,r);var u=new(Function.bind.apply(t,a));return n&&e(u,n.prototype),u}).apply(null,arguments)}function u(t){var n="function"==typeof Map?new Map:void 0;return(u=function(t){if(null===t||(u=t,-1===Function.toString.call(u).indexOf("[native code]")))return t;var u;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==n){if(n.has(t))return n.get(t);n.set(t,o)}function o(){return a(t,arguments,r(this).constructor)}return o.prototype=Object.create(t.prototype,{constructor:{value:o,enumerable:!1,writable:!0,configurable:!0}}),e(o,t)})(t)}function o(t,r){return!r||"object"!=typeof r&&"function"!=typeof r?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):r}function i(t){return function(t){if(Array.isArray(t))return l(t)}(t)||function(t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t))return Array.from(t)}(t)||c(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 c(t,r){if(t){if("string"==typeof t)return l(t,r);var e=Object.prototype.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(e):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?l(t,r):void 0}}function l(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=new Array(r);e<r;e++)n[e]=t[e];return n}var s=Object.prototype.hasOwnProperty;F.nodeVMSupported=function(){try{return"[object process]"===Object.prototype.toString.call(global.process)}catch(t){return!1}}();var p=F.nodeVMSupported?require("vm"):{runInNewContext:function(t,r){var e=Object.keys(r),n=[];!function(t,r,e){for(var n=t.length,a=0;a<n;a++){e(t[a])&&r.push(t.splice(a--,1)[0])}}(e,n,(function(t){return"function"==typeof r[t]}));var u=e.map((function(t,e){return r[t]}));(t=n.reduce((function(t,e){var n=r[e].toString();return/function/.test(n)||(n="function "+n),"var "+e+"="+n+";"+t}),"")+t).match(/(["'])use strict\1/)||e.includes("arguments")||(t="var arguments = undefined;"+t);var o=(t=t.replace(/;[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]*$/,"")).lastIndexOf(";"),c=o>-1?t.slice(0,o+1)+" return "+t.slice(o+1):" return "+t;return a(Function,i(e).concat([c])).apply(void 0,i(u))}};function h(t,r){return(t=t.slice()).push(r),t}function f(t,r){return(r=r.slice()).unshift(t),r}var y=function(t){!function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(r&&r.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),r&&e(t,r)}(c,u(Error));var a,i=(a=c,function(){var t,e=r(a);if(n()){var u=r(this).constructor;t=Reflect.construct(e,arguments,u)}else t=e.apply(this,arguments);return o(this,t)});function c(t){var r;return function(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this,c),(r=i.call(this,'JSONPath should not be called with "new" (it prevents return of (unwrapped) scalar values)')).avoidNew=!0,r.value=t,r.name="NewError",r}return c}();function F(r,e,n,a,u){if(!(this instanceof F))try{return new F(r,e,n,a,u)}catch(t){if(!t.avoidNew)throw t;return t.value}"string"==typeof r&&(u=a,a=n,n=e,e=r,r=null);var o=r&&"object"===t(r);if(r=r||{},this.json=r.json||n,this.path=r.path||e,this.resultType=r.resultType||"value",this.flatten=r.flatten||!1,this.wrap=!s.call(r,"wrap")||r.wrap,this.sandbox=r.sandbox||{},this.preventEval=r.preventEval||!1,this.parent=r.parent||null,this.parentProperty=r.parentProperty||null,this.callback=r.callback||a||null,this.otherTypeCallback=r.otherTypeCallback||u||function(){throw new TypeError("You must supply an otherTypeCallback callback option with the @other() operator.")},!1!==r.autostart){var i={path:o?r.path:e};o?"json"in r&&(i.json=r.json):i.json=n;var c=this.evaluate(i);if(!c||"object"!==t(c))throw new y(c);return c}}F.prototype.evaluate=function(r,e,n,a){var u=this,o=this.parent,i=this.parentProperty,c=this.flatten,l=this.wrap;if(this.currResultType=this.resultType,this.currPreventEval=this.preventEval,this.currSandbox=this.sandbox,n=n||this.callback,this.currOtherTypeCallback=a||this.otherTypeCallback,e=e||this.json,(r=r||this.path)&&"object"===t(r)&&!Array.isArray(r)){if(!r.path&&""!==r.path)throw new TypeError('You must supply a "path" property when providing an object argument to JSONPath.evaluate().');if(!s.call(r,"json"))throw new TypeError('You must supply a "json" property when providing an object argument to JSONPath.evaluate().');e=r.json,c=s.call(r,"flatten")?r.flatten:c,this.currResultType=s.call(r,"resultType")?r.resultType:this.currResultType,this.currSandbox=s.call(r,"sandbox")?r.sandbox:this.currSandbox,l=s.call(r,"wrap")?r.wrap:l,this.currPreventEval=s.call(r,"preventEval")?r.preventEval:this.currPreventEval,n=s.call(r,"callback")?r.callback:n,this.currOtherTypeCallback=s.call(r,"otherTypeCallback")?r.otherTypeCallback:this.currOtherTypeCallback,o=s.call(r,"parent")?r.parent:o,i=s.call(r,"parentProperty")?r.parentProperty:i,r=r.path}if(o=o||null,i=i||null,Array.isArray(r)&&(r=F.toPathString(r)),(r||""===r)&&e){this._obj=e;var p=F.toPathArray(r);"$"===p[0]&&p.length>1&&p.shift(),this._hasParentSelector=null;var h=this._trace(p,e,["$"],o,i,n).filter((function(t){return t&&!t.isParentSelector}));return h.length?l||1!==h.length||h[0].hasArrExpr?h.reduce((function(t,r){var e=u._getPreferredOutput(r);return c&&Array.isArray(e)?t=t.concat(e):t.push(e),t}),[]):this._getPreferredOutput(h[0]):l?[]:void 0}},F.prototype._getPreferredOutput=function(t){var r=this.currResultType;switch(r){default:throw new TypeError("Unknown result type");case"all":var e=Array.isArray(t.path)?t.path:F.toPathArray(t.path);return t.pointer=F.toPointer(e),t.path="string"==typeof t.path?t.path:F.toPathString(t.path),t;case"value":case"parent":case"parentProperty":return t[r];case"path":return F.toPathString(t[r]);case"pointer":return F.toPointer(t.path)}},F.prototype._handleCallback=function(t,r,e){if(r){var n=this._getPreferredOutput(t);t.path="string"==typeof t.path?t.path:F.toPathString(t.path),r(n,e,t)}},F.prototype._trace=function(r,e,n,a,u,o,i,l){var p,y=this;if(!r.length)return p={path:n,value:e,parent:a,parentProperty:u,hasArrExpr:i},this._handleCallback(p,o,"value"),p;var F=r[0],v=r.slice(1),b=[];function d(t){Array.isArray(t)?t.forEach((function(t){b.push(t)})):b.push(t)}if(("string"!=typeof F||l)&&e&&s.call(e,F))d(this._trace(v,e[F],h(n,F),e,F,o,i));else if("*"===F)this._walk(F,v,e,n,a,u,o,(function(t,r,e,n,a,u,o,i){d(y._trace(f(t,e),n,a,u,o,i,!0,!0))}));else if(".."===F)d(this._trace(v,e,n,a,u,o,i)),this._walk(F,v,e,n,a,u,o,(function(r,e,n,a,u,o,i,c){"object"===t(a[r])&&d(y._trace(f(e,n),a[r],h(u,r),a,r,c,!0))}));else{if("^"===F)return this._hasParentSelector=!0,{path:n.slice(0,-1),expr:v,isParentSelector:!0};if("~"===F)return p={path:h(n,F),value:u,parent:a,parentProperty:null},this._handleCallback(p,o,"property"),p;if("$"===F)d(this._trace(v,e,n,null,null,o,i));else if(/^(\x2D?[0-9]*):(\x2D?[0-9]*):?([0-9]*)$/.test(F))d(this._slice(F,v,e,n,a,u,o));else if(0===F.indexOf("?(")){if(this.currPreventEval)throw new Error("Eval [?(expr)] prevented in JSONPath expression.");this._walk(F,v,e,n,a,u,o,(function(t,r,e,n,a,u,o,i){y._eval(r.replace(/^\?\(((?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*?)\)$/,"$1"),n[t],t,a,u,o)&&d(y._trace(f(t,e),n,a,u,o,i,!0))}))}else if("("===F[0]){if(this.currPreventEval)throw new Error("Eval [(expr)] prevented in JSONPath expression.");d(this._trace(f(this._eval(F,e,n[n.length-1],n.slice(0,-1),a,u),v),e,n,a,u,o,i))}else if("@"===F[0]){var D=!1,g=F.slice(1,-2);switch(g){default:throw new TypeError("Unknown value type "+g);case"scalar":e&&["object","function"].includes(t(e))||(D=!0);break;case"boolean":case"string":case"undefined":case"function":t(e)===g&&(D=!0);break;case"integer":!Number.isFinite(e)||e%1||(D=!0);break;case"number":Number.isFinite(e)&&(D=!0);break;case"nonFinite":"number"!=typeof e||Number.isFinite(e)||(D=!0);break;case"object":e&&t(e)===g&&(D=!0);break;case"array":Array.isArray(e)&&(D=!0);break;case"other":D=this.currOtherTypeCallback(e,n,a,u);break;case"null":null===e&&(D=!0)}if(D)return p={path:n,value:e,parent:a,parentProperty:u},this._handleCallback(p,o,"value"),p}else if("`"===F[0]&&e&&s.call(e,F.slice(1))){var _=F.slice(1);d(this._trace(v,e[_],h(n,_),e,_,o,i,!0))}else if(F.includes(",")){var w,m=function(t){if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(t=c(t))){var r=0,e=function(){};return{s:e,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:e}}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 n,a,u=!0,o=!1;return{s:function(){n=t[Symbol.iterator]()},n:function(){var t=n.next();return u=t.done,t},e:function(t){o=!0,a=t},f:function(){try{u||null==n.return||n.return()}finally{if(o)throw a}}}}(F.split(","));try{for(m.s();!(w=m.n()).done;){var P=w.value;d(this._trace(f(P,v),e,n,a,u,o,!0))}}catch(t){m.e(t)}finally{m.f()}}else!l&&e&&s.call(e,F)&&d(this._trace(v,e[F],h(n,F),e,F,o,i,!0))}if(this._hasParentSelector)for(var S=0;S<b.length;S++){var x=b[S];if(x&&x.isParentSelector){var E=y._trace(x.expr,e,x.path,a,u,o,i);if(Array.isArray(E)){b[S]=E[0];for(var j=E.length,A=1;A<j;A++)S++,b.splice(S,0,E[A])}else b[S]=E}}return b},F.prototype._walk=function(r,e,n,a,u,o,i,c){if(Array.isArray(n))for(var l=n.length,s=0;s<l;s++)c(s,r,e,n,a,u,o,i);else n&&"object"===t(n)&&Object.keys(n).forEach((function(t){c(t,r,e,n,a,u,o,i)}))},F.prototype._slice=function(t,r,e,n,a,u,o){if(Array.isArray(e)){var i=e.length,c=t.split(":"),l=c[2]&&Number.parseInt(c[2])||1,s=c[0]&&Number.parseInt(c[0])||0,p=c[1]&&Number.parseInt(c[1])||i;s=s<0?Math.max(0,s+i):Math.min(i,s),p=p<0?Math.max(0,p+i):Math.min(i,p);for(var h=[],y=s;y<p;y+=l){this._trace(f(y,r),e,n,a,u,o,!0).forEach((function(t){h.push(t)}))}return h}},F.prototype._eval=function(t,r,e,n,a,u){if(!this._obj||!r)return!1;t.includes("@parentProperty")&&(this.currSandbox._$_parentProperty=u,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=e,t=t.replace(/@property/g,"_$_property")),t.includes("@path")&&(this.currSandbox._$_path=F.toPathString(n.concat([e])),t=t.replace(/@path/g,"_$_path")),t.includes("@root")&&(this.currSandbox._$_root=this.json,t=t.replace(/@root/g,"_$_root")),t.match(/@([\t-\r \)\.\[\xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF])/)&&(this.currSandbox._$_v=r,t=t.replace(/@([\t-\r \)\.\[\xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF])/g,"_$_v$1"));try{return p.runInNewContext(t,this.currSandbox)}catch(r){throw console.log(r),new Error("jsonPath: "+r.message+": "+t)}},F.cache={},F.toPathString=function(t){for(var r=t,e=r.length,n="$",a=1;a<e;a++)/^(~|\^|@(?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*?\(\))$/.test(r[a])||(n+=/^[\*0-9]+$/.test(r[a])?"["+r[a]+"]":"['"+r[a]+"']");return n},F.toPointer=function(t){for(var r=t,e=r.length,n="",a=1;a<e;a++)/^(~|\^|@(?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*?\(\))$/.test(r[a])||(n+="/"+r[a].toString().replace(/~/g,"~0").replace(/\//g,"~1"));return n},F.toPathArray=function(t){var r=F.cache;if(r[t])return r[t].concat();var e=[],n=t.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])*?\))['\]]/g,(function(t,r){return"[#"+(e.push(r)-1)+"]"})).replace(/\['((?:[\0-&\(-\\\^-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*)'\]/g,(function(t,r){return"['"+r.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(t,r){return";"+r.split("").join(";")+";"})).replace(/;;;|;;/g,";..;").replace(/;$|'?\]|'$/g,"").split(";").map((function(t){var r=t.match(/#([0-9]+)/);return r&&r[1]?e[r[1]]:t}));return r[t]=n,r[t]};export{F as JSONPath};
//# sourceMappingURL=index-es.min.js.map

@@ -8,2 +8,4 @@ (function (global, factory) {

function _typeof(obj) {
"@babel/helpers - typeof";
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {

@@ -59,3 +61,3 @@ _typeof = function (obj) {

function isNativeReflectConstruct() {
function _isNativeReflectConstruct() {
if (typeof Reflect === "undefined" || !Reflect.construct) return false;

@@ -74,3 +76,3 @@ if (Reflect.construct.sham) return false;

function _construct(Parent, args, Class) {
if (isNativeReflectConstruct()) {
if (_isNativeReflectConstruct()) {
_construct = Reflect.construct;

@@ -145,22 +147,107 @@ } else {

function _createSuper(Derived) {
return function () {
var Super = _getPrototypeOf(Derived),
result;
if (_isNativeReflectConstruct()) {
var NewTarget = _getPrototypeOf(this).constructor;
result = Reflect.construct(Super, arguments, NewTarget);
} else {
result = Super.apply(this, arguments);
}
return _possibleConstructorReturn(this, result);
};
}
function _toConsumableArray(arr) {
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread();
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
}
function _arrayWithoutHoles(arr) {
if (Array.isArray(arr)) {
for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
return arr2;
}
if (Array.isArray(arr)) return _arrayLikeToArray(arr);
}
function _iterableToArray(iter) {
if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter);
if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter);
}
function _unsupportedIterableToArray(o, minLen) {
if (!o) return;
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
var n = Object.prototype.toString.call(o).slice(8, -1);
if (n === "Object" && o.constructor) n = o.constructor.name;
if (n === "Map" || n === "Set") return Array.from(n);
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
}
function _arrayLikeToArray(arr, len) {
if (len == null || len > arr.length) len = arr.length;
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
return arr2;
}
function _nonIterableSpread() {
throw new TypeError("Invalid attempt to spread non-iterable instance");
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 _createForOfIteratorHelper(o) {
if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) {
if (Array.isArray(o) || (o = _unsupportedIterableToArray(o))) {
var i = 0;
var F = function () {};
return {
s: F,
n: function () {
if (i >= o.length) return {
done: true
};
return {
done: false,
value: o[i++]
};
},
e: function (e) {
throw e;
},
f: F
};
}
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 it,
normalCompletion = true,
didErr = false,
err;
return {
s: function () {
it = o[Symbol.iterator]();
},
n: function () {
var step = it.next();
normalCompletion = step.done;
return step;
},
e: function (e) {
didErr = true;
err = e;
},
f: function () {
try {
if (!normalCompletion && it.return != null) it.return();
} finally {
if (didErr) throw err;
}
}
};
}
/* eslint-disable prefer-named-capture-group */

@@ -229,3 +316,3 @@ // Disabled `prefer-named-capture-group` due to https://github.com/babel/babel/issues/8951#issuecomment-508045524

if (!/function/.exec(fString)) {
if (!/function/.test(fString)) {
fString = 'function ' + fString;

@@ -284,7 +371,7 @@ }

var NewError =
/*#__PURE__*/
function (_Error) {
var NewError = /*#__PURE__*/function (_Error) {
_inherits(NewError, _Error);
var _super = _createSuper(NewError);
/**

@@ -298,3 +385,3 @@ * @param {any} value The evaluated scalar value

_this = _possibleConstructorReturn(this, _getPrototypeOf(NewError).call(this, 'JSONPath should not be called with "new" (it prevents return ' + 'of (unwrapped) scalar values)'));
_this = _super.call(this, 'JSONPath should not be called with "new" (it prevents return ' + 'of (unwrapped) scalar values)');
_this.avoidNew = true;

@@ -307,3 +394,3 @@ _this.value = value;

return NewError;
}(_wrapNativeSuper(Error));
}( /*#__PURE__*/_wrapNativeSuper(Error));
/**

@@ -395,3 +482,3 @@ * @typedef {PlainObject} ReturnObject

this.path = opts.path || expr;
this.resultType = opts.resultType && opts.resultType.toLowerCase() || 'value';
this.resultType = opts.resultType || 'value';
this.flatten = opts.flatten || false;

@@ -446,11 +533,12 @@ this.wrap = hasOwnProp.call(opts, 'wrap') ? opts.wrap : true;

if (expr && _typeof(expr) === 'object' && !Array.isArray(expr)) {
if (!expr.path) {
if (!expr.path && expr.path !== '') {
throw new TypeError('You must supply a "path" property when providing an object ' + 'argument to JSONPath.evaluate().');
}
if (!('json' in expr)) {
if (!hasOwnProp.call(expr, 'json')) {
throw new TypeError('You must supply a "json" property when providing an object ' + 'argument to JSONPath.evaluate().');
}
json = hasOwnProp.call(expr, 'json') ? expr.json : json;
var _expr = expr;
json = _expr.json;
flatten = hasOwnProp.call(expr, 'flatten') ? expr.flatten : flatten;

@@ -475,3 +563,3 @@ this.currResultType = hasOwnProp.call(expr, 'resultType') ? expr.resultType : this.currResultType;

if (!expr || !json) {
if (!expr && expr !== '' || !json) {
return undefined;

@@ -523,5 +611,8 @@ }

case 'all':
ea.pointer = JSONPath.toPointer(ea.path);
ea.path = typeof ea.path === 'string' ? ea.path : JSONPath.toPathString(ea.path);
return ea;
{
var path = Array.isArray(ea.path) ? ea.path : JSONPath.toPathArray(ea.path);
ea.pointer = JSONPath.toPointer(path);
ea.path = typeof ea.path === 'string' ? ea.path : JSONPath.toPathString(ea.path);
return ea;
}

@@ -635,7 +726,7 @@ case 'value':

this._hasParentSelector = true;
return path.length ? {
return {
path: path.slice(0, -1),
expr: x,
isParentSelector: true
} : [];
};
} else if (loc === '~') {

@@ -708,5 +799,11 @@ // property name

case 'integer':
if (Number.isFinite(val) && !(val % 1)) {
addType = true;
}
break;
case 'number':
// eslint-disable-next-line valid-typeof
if (_typeof(val) === valueType && isFinite(val)) {
if (Number.isFinite(val)) {
addType = true;

@@ -718,3 +815,3 @@ }

case 'nonFinite':
if (typeof val === 'number' && !isFinite(val)) {
if (typeof val === 'number' && !Number.isFinite(val)) {
addType = true;

@@ -744,9 +841,2 @@ }

case 'integer':
if (val === Number(val) && isFinite(val) && !(val % 1)) {
addType = true;
}
break;
case 'null':

@@ -779,8 +869,8 @@ if (val === null) {

var parts = loc.split(',');
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
var _iterator = _createForOfIteratorHelper(parts),
_step;
try {
for (var _iterator = parts[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
for (_iterator.s(); !(_step = _iterator.n()).done;) {
var part = _step.value;

@@ -791,14 +881,5 @@ addRet(this._trace(unshift(part, x), val, path, parent, parentPropName, callback, true));

} catch (err) {
_didIteratorError = true;
_iteratorError = err;
_iterator.e(err);
} finally {
try {
if (!_iteratorNormalCompletion && _iterator["return"] != null) {
_iterator["return"]();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
_iterator.f();
}

@@ -844,8 +925,6 @@ } else if (!literalPriority && val && hasOwnProp.call(val, loc)) {

}
} else if (_typeof(val) === 'object') {
for (var m in val) {
if (hasOwnProp.call(val, m)) {
f(m, loc, expr, val, path, parent, parentPropName, callback);
}
}
} else if (val && _typeof(val) === 'object') {
Object.keys(val).forEach(function (m) {
f(m, loc, expr, val, path, parent, parentPropName, callback);
});
}

@@ -861,5 +940,5 @@ };

parts = loc.split(':'),
step = parts[2] && parseInt(parts[2]) || 1;
var start = parts[0] && parseInt(parts[0]) || 0,
end = parts[1] && parseInt(parts[1]) || len;
step = parts[2] && Number.parseInt(parts[2]) || 1;
var start = parts[0] && Number.parseInt(parts[0]) || 0,
end = parts[1] && Number.parseInt(parts[1]) || len;
start = start < 0 ? Math.max(0, start + len) : Math.min(len, start);

@@ -866,0 +945,0 @@ end = end < 0 ? Math.max(0, end + len) : Math.min(len, end);

@@ -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=t||self).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(){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 u(t,e,r){return(u=a()?Reflect.construct:function(t,e,r){var a=[null];a.push.apply(a,e);var u=new(Function.bind.apply(t,a));return r&&n(u,r.prototype),u}).apply(null,arguments)}function o(t){var e="function"==typeof Map?new Map:void 0;return(o=function(t){if(null===t||(a=t,-1===Function.toString.call(a).indexOf("[native code]")))return t;var a;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,o)}function o(){return u(t,arguments,r(this).constructor)}return o.prototype=Object.create(t.prototype,{constructor:{value:o,enumerable:!1,writable:!0,configurable:!0}}),n(o,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}function c(t){return function(t){if(Array.isArray(t)){for(var e=0,r=new Array(t.length);e<t.length;e++)r[e]=t[e];return r}}(t)||function(t){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t))return Array.from(t)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}var l=Object.prototype.hasOwnProperty;F.nodeVMSupported=function(){try{return"[object process]"===Object.prototype.toString.call(global.process)}catch(t){return!1}}();var p=F.nodeVMSupported?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=r.map((function(t,r){return e[t]}));(t=n.reduce((function(t,r){var n=e[r].toString();return/function/.exec(n)||(n="function "+n),"var "+r+"="+n+";"+t}),"")+t).match(/(["'])use strict\1/)||r.includes("arguments")||(t="var arguments = undefined;"+t);var o=(t=t.replace(/;[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]*$/,"")).lastIndexOf(";"),i=o>-1?t.slice(0,o+1)+" return "+t.slice(o+1):" return "+t;return u(Function,c(r).concat([i])).apply(void 0,c(a))}};function s(t,e){return(t=t.slice()).push(e),t}function h(t,e){return(e=e.slice()).unshift(t),e}var f=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.name="NewError",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,t),e}(o(Error));function F(t,r,n,a,u){if(!(this instanceof F))try{return new F(t,r,n,a,u)}catch(t){if(!t.avoidNew)throw t;return t.value}"string"==typeof t&&(u=a,a=n,n=r,r=t,t=null);var o=t&&"object"===e(t);if(t=t||{},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=!l.call(t,"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||u||function(){throw new TypeError("You must supply an otherTypeCallback callback option with the @other() operator.")},!1!==t.autostart){var i={path:o?t.path:r};o?"json"in t&&(i.json=t.json):i.json=n;var c=this.evaluate(i);if(!c||"object"!==e(c))throw new f(c);return c}}F.prototype.evaluate=function(t,r,n,a){var u=this,o=this.parent,i=this.parentProperty,c=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)&&!Array.isArray(t)){if(!t.path)throw new TypeError('You must supply a "path" property when providing an object argument to JSONPath.evaluate().');if(!("json"in t))throw new TypeError('You must supply a "json" property when providing an object argument to JSONPath.evaluate().');r=l.call(t,"json")?t.json:r,c=l.call(t,"flatten")?t.flatten:c,this.currResultType=l.call(t,"resultType")?t.resultType:this.currResultType,this.currSandbox=l.call(t,"sandbox")?t.sandbox:this.currSandbox,p=l.call(t,"wrap")?t.wrap:p,this.currPreventEval=l.call(t,"preventEval")?t.preventEval:this.currPreventEval,n=l.call(t,"callback")?t.callback:n,this.currOtherTypeCallback=l.call(t,"otherTypeCallback")?t.otherTypeCallback:this.currOtherTypeCallback,o=l.call(t,"parent")?t.parent:o,i=l.call(t,"parentProperty")?t.parentProperty:i,t=t.path}if(o=o||null,i=i||null,Array.isArray(t)&&(t=F.toPathString(t)),t&&r){this._obj=r;var s=F.toPathArray(t);"$"===s[0]&&s.length>1&&s.shift(),this._hasParentSelector=null;var h=this._trace(s,r,["$"],o,i,n).filter((function(t){return t&&!t.isParentSelector}));return h.length?p||1!==h.length||h[0].hasArrExpr?h.reduce((function(t,e){var r=u._getPreferredOutput(e);return c&&Array.isArray(r)?t=t.concat(r):t.push(r),t}),[]):this._getPreferredOutput(h[0]):p?[]:void 0}},F.prototype._getPreferredOutput=function(t){var e=this.currResultType;switch(e){default:throw new TypeError("Unknown result type");case"all":return t.pointer=F.toPointer(t.path),t.path="string"==typeof t.path?t.path:F.toPathString(t.path),t;case"value":case"parent":case"parentProperty":return t[e];case"path":return F.toPathString(t[e]);case"pointer":return F.toPointer(t.path)}},F.prototype._handleCallback=function(t,e,r){if(e){var n=this._getPreferredOutput(t);t.path="string"==typeof t.path?t.path:F.toPathString(t.path),e(n,r,t)}},F.prototype._trace=function(t,r,n,a,u,o,i,c){var p,f=this;if(!t.length)return p={path:n,value:r,parent:a,parentProperty:u,hasArrExpr:i},this._handleCallback(p,o,"value"),p;var F=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 F||c)&&r&&l.call(r,F))b(this._trace(y,r[F],s(n,F),r,F,o,i));else if("*"===F)this._walk(F,y,r,n,a,u,o,(function(t,e,r,n,a,u,o,i){b(f._trace(h(t,r),n,a,u,o,i,!0,!0))}));else if(".."===F)b(this._trace(y,r,n,a,u,o,i)),this._walk(F,y,r,n,a,u,o,(function(t,r,n,a,u,o,i,c){"object"===e(a[t])&&b(f._trace(h(r,n),a[t],s(u,t),a,t,c,!0))}));else{if("^"===F)return this._hasParentSelector=!0,n.length?{path:n.slice(0,-1),expr:y,isParentSelector:!0}:[];if("~"===F)return p={path:s(n,F),value:u,parent:a,parentProperty:null},this._handleCallback(p,o,"property"),p;if("$"===F)b(this._trace(y,r,n,null,null,o,i));else if(/^(\x2D?[0-9]*):(\x2D?[0-9]*):?([0-9]*)$/.test(F))b(this._slice(F,y,r,n,a,u,o));else if(0===F.indexOf("?(")){if(this.currPreventEval)throw new Error("Eval [?(expr)] prevented in JSONPath expression.");this._walk(F,y,r,n,a,u,o,(function(t,e,r,n,a,u,o,i){f._eval(e.replace(/^\?\(((?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*?)\)$/,"$1"),n[t],t,a,u,o)&&b(f._trace(h(t,r),n,a,u,o,i,!0))}))}else if("("===F[0]){if(this.currPreventEval)throw new Error("Eval [(expr)] prevented in JSONPath expression.");b(this._trace(h(this._eval(F,r,n[n.length-1],n.slice(0,-1),a,u),y),r,n,a,u,o,i))}else if("@"===F[0]){var D=!1,d=F.slice(1,-2);switch(d){default:throw new TypeError("Unknown value type "+d);case"scalar":r&&["object","function"].includes(e(r))||(D=!0);break;case"boolean":case"string":case"undefined":case"function":e(r)===d&&(D=!0);break;case"number":e(r)===d&&isFinite(r)&&(D=!0);break;case"nonFinite":"number"!=typeof r||isFinite(r)||(D=!0);break;case"object":r&&e(r)===d&&(D=!0);break;case"array":Array.isArray(r)&&(D=!0);break;case"other":D=this.currOtherTypeCallback(r,n,a,u);break;case"integer":r!==Number(r)||!isFinite(r)||r%1||(D=!0);break;case"null":null===r&&(D=!0)}if(D)return p={path:n,value:r,parent:a,parentProperty:u},this._handleCallback(p,o,"value"),p}else if("`"===F[0]&&r&&l.call(r,F.slice(1))){var g=F.slice(1);b(this._trace(y,r[g],s(n,g),r,g,o,i,!0))}else if(F.includes(",")){var _=F.split(","),w=!0,P=!1,x=void 0;try{for(var S,E=_[Symbol.iterator]();!(w=(S=E.next()).done);w=!0){var j=S.value;b(this._trace(h(j,y),r,n,a,u,o,!0))}}catch(t){P=!0,x=t}finally{try{w||null==E.return||E.return()}finally{if(P)throw x}}}else!c&&r&&l.call(r,F)&&b(this._trace(y,r[F],s(n,F),r,F,o,i,!0))}if(this._hasParentSelector)for(var m=0;m<v.length;m++){var C=v[m];if(C&&C.isParentSelector){var k=f._trace(C.expr,r,C.path,a,u,o,i);if(Array.isArray(k)){v[m]=k[0];for(var A=k.length,O=1;O<A;O++)m++,v.splice(m,0,k[O])}else v[m]=k}}return v},F.prototype._walk=function(t,r,n,a,u,o,i,c){if(Array.isArray(n))for(var p=n.length,s=0;s<p;s++)c(s,t,r,n,a,u,o,i);else if("object"===e(n))for(var h in n)l.call(n,h)&&c(h,t,r,n,a,u,o,i)},F.prototype._slice=function(t,e,r,n,a,u,o){if(Array.isArray(r)){var i=r.length,c=t.split(":"),l=c[2]&&parseInt(c[2])||1,p=c[0]&&parseInt(c[0])||0,s=c[1]&&parseInt(c[1])||i;p=p<0?Math.max(0,p+i):Math.min(i,p),s=s<0?Math.max(0,s+i):Math.min(i,s);for(var f=[],F=p;F<s;F+=l){this._trace(h(F,e),r,n,a,u,o,!0).forEach((function(t){f.push(t)}))}return f}},F.prototype._eval=function(t,e,r,n,a,u){if(!this._obj||!e)return!1;t.includes("@parentProperty")&&(this.currSandbox._$_parentProperty=u,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=F.toPathString(n.concat([r])),t=t.replace(/@path/g,"_$_path")),t.includes("@root")&&(this.currSandbox._$_root=this.json,t=t.replace(/@root/g,"_$_root")),t.match(/@([\t-\r \)\.\[\xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF])/)&&(this.currSandbox._$_v=e,t=t.replace(/@([\t-\r \)\.\[\xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF])/g,"_$_v$1"));try{return p.runInNewContext(t,this.currSandbox)}catch(e){throw console.log(e),new Error("jsonPath: "+e.message+": "+t)}},F.cache={},F.toPathString=function(t){for(var e=t,r=e.length,n="$",a=1;a<r;a++)/^(~|\^|@(?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*?\(\))$/.test(e[a])||(n+=/^[\*0-9]+$/.test(e[a])?"["+e[a]+"]":"['"+e[a]+"']");return n},F.toPointer=function(t){for(var e=t,r=e.length,n="",a=1;a<r;a++)/^(~|\^|@(?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*?\(\))$/.test(e[a])||(n+="/"+e[a].toString().replace(/~/g,"~0").replace(/\//g,"~1"));return n},F.toPathArray=function(t){var e=F.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(/['\[](\??\((?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*?\))['\]]/g,(function(t,e){return"[#"+(r.push(e)-1)+"]"})).replace(/\['((?:[\0-&\(-\\\^-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*)'\]/g,(function(t,e){return"['"+e.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(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=F,Object.defineProperty(t,"__esModule",{value:!0})}));
!function(t,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r((t=t||self).JSONPath={})}(this,(function(t){"use strict";function r(t){return(r="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 e(t){return(e=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function n(t,r){return(n=Object.setPrototypeOf||function(t,r){return t.__proto__=r,t})(t,r)}function a(){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 u(t,r,e){return(u=a()?Reflect.construct:function(t,r,e){var a=[null];a.push.apply(a,r);var u=new(Function.bind.apply(t,a));return e&&n(u,e.prototype),u}).apply(null,arguments)}function o(t){var r="function"==typeof Map?new Map:void 0;return(o=function(t){if(null===t||(a=t,-1===Function.toString.call(a).indexOf("[native code]")))return t;var a;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==r){if(r.has(t))return r.get(t);r.set(t,o)}function o(){return u(t,arguments,e(this).constructor)}return o.prototype=Object.create(t.prototype,{constructor:{value:o,enumerable:!1,writable:!0,configurable:!0}}),n(o,t)})(t)}function i(t,r){return!r||"object"!=typeof r&&"function"!=typeof r?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):r}function c(t){return function(t){if(Array.isArray(t))return s(t)}(t)||function(t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t))return Array.from(t)}(t)||l(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 l(t,r){if(t){if("string"==typeof t)return s(t,r);var e=Object.prototype.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(e):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?s(t,r):void 0}}function s(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=new Array(r);e<r;e++)n[e]=t[e];return n}var p=Object.prototype.hasOwnProperty;b.nodeVMSupported=function(){try{return"[object process]"===Object.prototype.toString.call(global.process)}catch(t){return!1}}();var h=b.nodeVMSupported?require("vm"):{runInNewContext:function(t,r){var e=Object.keys(r),n=[];!function(t,r,e){for(var n=t.length,a=0;a<n;a++){e(t[a])&&r.push(t.splice(a--,1)[0])}}(e,n,(function(t){return"function"==typeof r[t]}));var a=e.map((function(t,e){return r[t]}));(t=n.reduce((function(t,e){var n=r[e].toString();return/function/.test(n)||(n="function "+n),"var "+e+"="+n+";"+t}),"")+t).match(/(["'])use strict\1/)||e.includes("arguments")||(t="var arguments = undefined;"+t);var o=(t=t.replace(/;[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]*$/,"")).lastIndexOf(";"),i=o>-1?t.slice(0,o+1)+" return "+t.slice(o+1):" return "+t;return u(Function,c(e).concat([i])).apply(void 0,c(a))}};function f(t,r){return(t=t.slice()).push(r),t}function y(t,r){return(r=r.slice()).unshift(t),r}var F=function(t){!function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(r&&r.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),r&&n(t,r)}(o,t);var r,u=(r=o,function(){var t,n=e(r);if(a()){var u=e(this).constructor;t=Reflect.construct(n,arguments,u)}else t=n.apply(this,arguments);return i(this,t)});function o(t){var r;return function(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this,o),(r=u.call(this,'JSONPath should not be called with "new" (it prevents return of (unwrapped) scalar values)')).avoidNew=!0,r.value=t,r.name="NewError",r}return o}(o(Error));function b(t,e,n,a,u){if(!(this instanceof b))try{return new b(t,e,n,a,u)}catch(t){if(!t.avoidNew)throw t;return t.value}"string"==typeof t&&(u=a,a=n,n=e,e=t,t=null);var o=t&&"object"===r(t);if(t=t||{},this.json=t.json||n,this.path=t.path||e,this.resultType=t.resultType||"value",this.flatten=t.flatten||!1,this.wrap=!p.call(t,"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||u||function(){throw new TypeError("You must supply an otherTypeCallback callback option with the @other() operator.")},!1!==t.autostart){var i={path:o?t.path:e};o?"json"in t&&(i.json=t.json):i.json=n;var c=this.evaluate(i);if(!c||"object"!==r(c))throw new F(c);return c}}b.prototype.evaluate=function(t,e,n,a){var u=this,o=this.parent,i=this.parentProperty,c=this.flatten,l=this.wrap;if(this.currResultType=this.resultType,this.currPreventEval=this.preventEval,this.currSandbox=this.sandbox,n=n||this.callback,this.currOtherTypeCallback=a||this.otherTypeCallback,e=e||this.json,(t=t||this.path)&&"object"===r(t)&&!Array.isArray(t)){if(!t.path&&""!==t.path)throw new TypeError('You must supply a "path" property when providing an object argument to JSONPath.evaluate().');if(!p.call(t,"json"))throw new TypeError('You must supply a "json" property when providing an object argument to JSONPath.evaluate().');e=t.json,c=p.call(t,"flatten")?t.flatten:c,this.currResultType=p.call(t,"resultType")?t.resultType:this.currResultType,this.currSandbox=p.call(t,"sandbox")?t.sandbox:this.currSandbox,l=p.call(t,"wrap")?t.wrap:l,this.currPreventEval=p.call(t,"preventEval")?t.preventEval:this.currPreventEval,n=p.call(t,"callback")?t.callback:n,this.currOtherTypeCallback=p.call(t,"otherTypeCallback")?t.otherTypeCallback:this.currOtherTypeCallback,o=p.call(t,"parent")?t.parent:o,i=p.call(t,"parentProperty")?t.parentProperty:i,t=t.path}if(o=o||null,i=i||null,Array.isArray(t)&&(t=b.toPathString(t)),(t||""===t)&&e){this._obj=e;var s=b.toPathArray(t);"$"===s[0]&&s.length>1&&s.shift(),this._hasParentSelector=null;var h=this._trace(s,e,["$"],o,i,n).filter((function(t){return t&&!t.isParentSelector}));return h.length?l||1!==h.length||h[0].hasArrExpr?h.reduce((function(t,r){var e=u._getPreferredOutput(r);return c&&Array.isArray(e)?t=t.concat(e):t.push(e),t}),[]):this._getPreferredOutput(h[0]):l?[]:void 0}},b.prototype._getPreferredOutput=function(t){var r=this.currResultType;switch(r){default:throw new TypeError("Unknown result type");case"all":var e=Array.isArray(t.path)?t.path:b.toPathArray(t.path);return t.pointer=b.toPointer(e),t.path="string"==typeof t.path?t.path:b.toPathString(t.path),t;case"value":case"parent":case"parentProperty":return t[r];case"path":return b.toPathString(t[r]);case"pointer":return b.toPointer(t.path)}},b.prototype._handleCallback=function(t,r,e){if(r){var n=this._getPreferredOutput(t);t.path="string"==typeof t.path?t.path:b.toPathString(t.path),r(n,e,t)}},b.prototype._trace=function(t,e,n,a,u,o,i,c){var s,h=this;if(!t.length)return s={path:n,value:e,parent:a,parentProperty:u,hasArrExpr:i},this._handleCallback(s,o,"value"),s;var F=t[0],b=t.slice(1),v=[];function d(t){Array.isArray(t)?t.forEach((function(t){v.push(t)})):v.push(t)}if(("string"!=typeof F||c)&&e&&p.call(e,F))d(this._trace(b,e[F],f(n,F),e,F,o,i));else if("*"===F)this._walk(F,b,e,n,a,u,o,(function(t,r,e,n,a,u,o,i){d(h._trace(y(t,e),n,a,u,o,i,!0,!0))}));else if(".."===F)d(this._trace(b,e,n,a,u,o,i)),this._walk(F,b,e,n,a,u,o,(function(t,e,n,a,u,o,i,c){"object"===r(a[t])&&d(h._trace(y(e,n),a[t],f(u,t),a,t,c,!0))}));else{if("^"===F)return this._hasParentSelector=!0,{path:n.slice(0,-1),expr:b,isParentSelector:!0};if("~"===F)return s={path:f(n,F),value:u,parent:a,parentProperty:null},this._handleCallback(s,o,"property"),s;if("$"===F)d(this._trace(b,e,n,null,null,o,i));else if(/^(\x2D?[0-9]*):(\x2D?[0-9]*):?([0-9]*)$/.test(F))d(this._slice(F,b,e,n,a,u,o));else if(0===F.indexOf("?(")){if(this.currPreventEval)throw new Error("Eval [?(expr)] prevented in JSONPath expression.");this._walk(F,b,e,n,a,u,o,(function(t,r,e,n,a,u,o,i){h._eval(r.replace(/^\?\(((?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*?)\)$/,"$1"),n[t],t,a,u,o)&&d(h._trace(y(t,e),n,a,u,o,i,!0))}))}else if("("===F[0]){if(this.currPreventEval)throw new Error("Eval [(expr)] prevented in JSONPath expression.");d(this._trace(y(this._eval(F,e,n[n.length-1],n.slice(0,-1),a,u),b),e,n,a,u,o,i))}else if("@"===F[0]){var D=!1,g=F.slice(1,-2);switch(g){default:throw new TypeError("Unknown value type "+g);case"scalar":e&&["object","function"].includes(r(e))||(D=!0);break;case"boolean":case"string":case"undefined":case"function":r(e)===g&&(D=!0);break;case"integer":!Number.isFinite(e)||e%1||(D=!0);break;case"number":Number.isFinite(e)&&(D=!0);break;case"nonFinite":"number"!=typeof e||Number.isFinite(e)||(D=!0);break;case"object":e&&r(e)===g&&(D=!0);break;case"array":Array.isArray(e)&&(D=!0);break;case"other":D=this.currOtherTypeCallback(e,n,a,u);break;case"null":null===e&&(D=!0)}if(D)return s={path:n,value:e,parent:a,parentProperty:u},this._handleCallback(s,o,"value"),s}else if("`"===F[0]&&e&&p.call(e,F.slice(1))){var _=F.slice(1);d(this._trace(b,e[_],f(n,_),e,_,o,i,!0))}else if(F.includes(",")){var w,m=function(t){if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(t=l(t))){var r=0,e=function(){};return{s:e,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:e}}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 n,a,u=!0,o=!1;return{s:function(){n=t[Symbol.iterator]()},n:function(){var t=n.next();return u=t.done,t},e:function(t){o=!0,a=t},f:function(){try{u||null==n.return||n.return()}finally{if(o)throw a}}}}(F.split(","));try{for(m.s();!(w=m.n()).done;){var P=w.value;d(this._trace(y(P,b),e,n,a,u,o,!0))}}catch(t){m.e(t)}finally{m.f()}}else!c&&e&&p.call(e,F)&&d(this._trace(b,e[F],f(n,F),e,F,o,i,!0))}if(this._hasParentSelector)for(var S=0;S<v.length;S++){var x=v[S];if(x&&x.isParentSelector){var E=h._trace(x.expr,e,x.path,a,u,o,i);if(Array.isArray(E)){v[S]=E[0];for(var j=E.length,A=1;A<j;A++)S++,v.splice(S,0,E[A])}else v[S]=E}}return v},b.prototype._walk=function(t,e,n,a,u,o,i,c){if(Array.isArray(n))for(var l=n.length,s=0;s<l;s++)c(s,t,e,n,a,u,o,i);else n&&"object"===r(n)&&Object.keys(n).forEach((function(r){c(r,t,e,n,a,u,o,i)}))},b.prototype._slice=function(t,r,e,n,a,u,o){if(Array.isArray(e)){var i=e.length,c=t.split(":"),l=c[2]&&Number.parseInt(c[2])||1,s=c[0]&&Number.parseInt(c[0])||0,p=c[1]&&Number.parseInt(c[1])||i;s=s<0?Math.max(0,s+i):Math.min(i,s),p=p<0?Math.max(0,p+i):Math.min(i,p);for(var h=[],f=s;f<p;f+=l){this._trace(y(f,r),e,n,a,u,o,!0).forEach((function(t){h.push(t)}))}return h}},b.prototype._eval=function(t,r,e,n,a,u){if(!this._obj||!r)return!1;t.includes("@parentProperty")&&(this.currSandbox._$_parentProperty=u,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=e,t=t.replace(/@property/g,"_$_property")),t.includes("@path")&&(this.currSandbox._$_path=b.toPathString(n.concat([e])),t=t.replace(/@path/g,"_$_path")),t.includes("@root")&&(this.currSandbox._$_root=this.json,t=t.replace(/@root/g,"_$_root")),t.match(/@([\t-\r \)\.\[\xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF])/)&&(this.currSandbox._$_v=r,t=t.replace(/@([\t-\r \)\.\[\xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF])/g,"_$_v$1"));try{return h.runInNewContext(t,this.currSandbox)}catch(r){throw console.log(r),new Error("jsonPath: "+r.message+": "+t)}},b.cache={},b.toPathString=function(t){for(var r=t,e=r.length,n="$",a=1;a<e;a++)/^(~|\^|@(?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*?\(\))$/.test(r[a])||(n+=/^[\*0-9]+$/.test(r[a])?"["+r[a]+"]":"['"+r[a]+"']");return n},b.toPointer=function(t){for(var r=t,e=r.length,n="",a=1;a<e;a++)/^(~|\^|@(?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*?\(\))$/.test(r[a])||(n+="/"+r[a].toString().replace(/~/g,"~0").replace(/\//g,"~1"));return n},b.toPathArray=function(t){var r=b.cache;if(r[t])return r[t].concat();var e=[],n=t.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])*?\))['\]]/g,(function(t,r){return"[#"+(e.push(r)-1)+"]"})).replace(/\['((?:[\0-&\(-\\\^-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*)'\]/g,(function(t,r){return"['"+r.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(t,r){return";"+r.split("").join(";")+";"})).replace(/;;;|;;/g,";..;").replace(/;$|'?\]|'$/g,"").split(";").map((function(t){var r=t.match(/#([0-9]+)/);return r&&r[1]?e[r[1]]:t}));return r[t]=n,r[t]},t.JSONPath=b,Object.defineProperty(t,"__esModule",{value:!0})}));
//# sourceMappingURL=index-umd.min.js.map
{
"author": "Stefan Goessner",
"name": "jsonpath-plus",
"version": "3.0.0",
"version": "4.0.0",
"main": "dist/index-umd.js",

@@ -43,3 +43,3 @@ "module": "dist/index-es.js",

"engines": {
"node": ">=8.0"
"node": ">=10.0"
},

@@ -51,22 +51,22 @@ "react-native": {

"devDependencies": {
"@babel/core": "^7.8.0",
"@babel/preset-env": "^7.8.2",
"@babel/core": "^7.9.0",
"@babel/preset-env": "^7.9.0",
"@mysticatea/eslint-plugin": "^13.0.0",
"babel-eslint": "^10.0.3",
"babel-eslint": "^10.1.0",
"chai": "^4.2.0",
"core-js-bundle": "^3.6.3",
"coveradge": "^0.2.0",
"core-js-bundle": "^3.6.4",
"coveradge": "^0.5.0",
"eslint": "^6.8.0",
"eslint-config-ash-nazg": "^16.4.0",
"eslint-config-standard": "^14.1.0",
"eslint-plugin-array-func": "^3.1.3",
"eslint-config-ash-nazg": "^18.0.0",
"eslint-config-standard": "^14.1.1",
"eslint-plugin-array-func": "^3.1.4",
"eslint-plugin-chai-expect": "^2.1.0",
"eslint-plugin-chai-friendly": "^0.5.0",
"eslint-plugin-compat": "^3.3.0",
"eslint-plugin-compat": "^3.5.1",
"eslint-plugin-eslint-comments": "^3.1.2",
"eslint-plugin-html": "^6.0.0",
"eslint-plugin-import": "^2.20.0",
"eslint-plugin-jsdoc": "^20.3.0",
"eslint-plugin-markdown": "^1.0.1",
"eslint-plugin-no-unsanitized": "^3.0.2",
"eslint-plugin-import": "^2.20.1",
"eslint-plugin-jsdoc": "^22.1.0",
"eslint-plugin-markdown": "^1.0.2",
"eslint-plugin-no-unsanitized": "^3.1.0",
"eslint-plugin-no-use-extend-native": "^0.4.1",

@@ -77,18 +77,19 @@ "eslint-plugin-node": "^11.0.0",

"eslint-plugin-standard": "^4.0.1",
"eslint-plugin-unicorn": "^15.0.1",
"eslint-plugin-unicorn": "^18.0.0",
"esm": "^3.2.25",
"mocha": "^7.0.0",
"mocha-badge-generator": "^0.4.0",
"license-badger": "^0.13.0",
"mocha": "^7.1.1",
"mocha-badge-generator": "^0.5.2",
"mocha-multi-reporters": "git+https://github.com/brettz9/mocha-multi-reporters.git#missing-reporter",
"node-static": "^0.7.11",
"nyc": "^15.0.0",
"open-cli": "^5.0.0",
"open-cli": "^6.0.1",
"remark-cli": "^7.0.1",
"remark-lint-code-block-style": "^1.0.3",
"remark-lint-ordered-list-marker-value": "^1.0.4",
"rollup": "1.29.0",
"rollup-plugin-babel": "^4.3.3",
"rollup-plugin-terser": "^5.2.0",
"typedoc": "^0.16.1",
"typescript": "^3.7.4"
"remark-lint-code-block-style": "^1.0.4",
"remark-lint-ordered-list-marker-value": "^1.0.5",
"rollup": "2.2.0",
"rollup-plugin-babel": "^4.4.0",
"rollup-plugin-terser": "^5.3.0",
"typedoc": "^0.17.3",
"typescript": "^3.8.3"
},

@@ -121,2 +122,6 @@ "keywords": [

"scripts": {
"prepublishOnly": "npm run license-badges",
"license-badge": "license-badger --corrections --uncategorizedLicenseTemplate \"\\${license} (\\${name} (\\${version}))\" --filteredTypes=nonempty --textTemplate \"License types\n(project, deps, and bundled devDeps)\" --packageJson --production badges/licenses-badge.svg",
"license-badge-dev": "license-badger --corrections --filteredTypes=nonempty --textTemplate \"License types\n(all devDeps)\" --allDevelopment badges/licenses-badge-dev.svg",
"license-badges": "npm run license-badge && npm run license-badge-dev",
"remark": "remark -q -f .",

@@ -127,3 +132,3 @@ "typescript": "tsc src/jsonpath.d.ts",

"coverage": "open-cli http://localhost:8084/coverage/ && npm start",
"coverage-badge": "coveradge --color brightgreen badges/coverage-badge.svg",
"coverage-badge": "coveradge badges/coverage-badge.svg",
"mocha": "mocha --require esm --require test-helpers/node-env.js --reporter-options configFile=mocha-multi-reporters.json test",

@@ -130,0 +135,0 @@ "test": "npm run rollup && npm run mocha",

@@ -12,4 +12,7 @@ [![npm](https://img.shields.io/npm/v/jsonpath-plus.svg)](https://www.npmjs.com/package/jsonpath-plus)

[![License](https://img.shields.io/npm/l/intl-dom.svg)](LICENSE-MIT.txt)
<!--[![License](https://img.shields.io/npm/l/JSONPath.svg)](LICENSE-MIT.txt)-->
[![Licenses badge](https://raw.githubusercontent.com/s3u/JSONPath/master/badges/licenses-badge.svg?sanitize=true)](badges/licenses-badge.svg)
<small>(see also [licenses for dev. deps.](https://raw.githubusercontent.com/s3u/JSONPath/master/badges/licenses-badge-dev.svg?sanitize=true))</small>
# JSONPath Plus [![build status](https://secure.travis-ci.org/s3u/JSONPath.png)](http://travis-ci.org/s3u/JSONPath)

@@ -316,3 +319,3 @@

//book\[price<10] | $..book\[?(@.price<10)] | Filter all books cheaper than 10 |
| //\*\[name() = 'price' and . != 8.95] | $..\*\[?(@property === 'price' && @ !== 8.95)] | Obtain all property values of objects whose property is price and which does not equal 8.95 |
| //\*\[name() = 'price' and . != 8.95] | $..\*\[?(@property === 'price' && @ !== 8.95)] | Obtain all property values of objects whose property is price and which does not equal 8.95 | With the bare `@` allowing filtering objects by property value (not necessarily within arrays), you can add `^` after the expression to get at the object possessing the filtered properties
/ | $ | The root of the JSON object (i.e., the whole object itself) | To get a literal `$` (by itself or anywhere in the path), you must use the backtick escape

@@ -319,0 +322,0 @@ //\*/\*\|//\*/\*/text() | $..* | All Elements (and text) beneath root in an XML document. All members of a JSON structure beneath the root. |

@@ -223,4 +223,3 @@ /* eslint-disable prefer-named-capture-group */

this.path = opts.path || expr;
this.resultType = (opts.resultType && opts.resultType.toLowerCase()) ||
'value';
this.resultType = opts.resultType || 'value';
this.flatten = opts.flatten || false;

@@ -537,5 +536,9 @@ this.wrap = hasOwnProp.call(opts, 'wrap') ? opts.wrap : true;

break;
case 'integer':
if (Number.isFinite(val) && !(val % 1)) {
addType = true;
}
break;
case 'number':
// eslint-disable-next-line valid-typeof
if (typeof val === valueType && isFinite(val)) {
if (Number.isFinite(val)) {
addType = true;

@@ -545,3 +548,3 @@ }

case 'nonFinite':
if (typeof val === 'number' && !isFinite(val)) {
if (typeof val === 'number' && !Number.isFinite(val)) {
addType = true;

@@ -566,7 +569,2 @@ }

break;
case 'integer':
if (val === Number(val) && isFinite(val) && !(val % 1)) {
addType = true;
}
break;
case 'null':

@@ -655,5 +653,5 @@ if (val === null) {

const len = val.length, parts = loc.split(':'),
step = (parts[2] && parseInt(parts[2])) || 1;
let start = (parts[0] && parseInt(parts[0])) || 0,
end = (parts[1] && parseInt(parts[1])) || len;
step = (parts[2] && Number.parseInt(parts[2])) || 1;
let start = (parts[0] && Number.parseInt(parts[0])) || 0,
end = (parts[1] && Number.parseInt(parts[1])) || len;
start = (start < 0) ? Math.max(0, start + len) : Math.min(len, start);

@@ -660,0 +658,0 @@ end = (end < 0) ? Math.max(0, end + len) : Math.min(len, end);

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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