diff --git a/CHANGES.md b/CHANGES.md index 27cb38c..8380ecd 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -2,7 +2,13 @@ ## 6.0.0 (2021-06-24) -- Enhancement: Create as true ESM module +- Breaking enhancement: Create as true ESM module +- Breaking change: Utilize `.cjs` extension for UMD and CJS builds (very + old browsers might not support, but needed with the change given that + Webpack may complain if there even exists CJS within what it thinks is + an ESM file, the ".js", our default) +- Breaking change: Utilize `.js` extension instead of `.mjs` for now default + ESM builds ## 5.1.0 (2021-06-24) diff --git a/demo/index.html b/demo/index.html index f37b859..1a45098 100644 --- a/demo/index.html +++ b/demo/index.html @@ -26,7 +26,7 @@

JSONPath Demo (To demo on Node instead, see the + diff --git a/demo/node-import-test.mjs b/demo/node-import-test.js similarity index 95% rename from demo/node-import-test.mjs rename to demo/node-import-test.js index de8c652..5e5cb0e 100644 --- a/demo/node-import-test.mjs +++ b/demo/node-import-test.js @@ -1,4 +1,4 @@ -import {JSONPath} from '../dist/index-node-esm.mjs'; +import {JSONPath} from '../dist/index-node-esm.js'; /* eslint-disable quotes, quote-props */ const json = { diff --git a/dist/index-browser-umd.js b/dist/index-browser-umd.cjs similarity index 100% rename from dist/index-browser-umd.js rename to dist/index-browser-umd.cjs diff --git a/dist/index-browser-umd.min.js b/dist/index-browser-umd.min.cjs similarity index 99% rename from dist/index-browser-umd.min.js rename to dist/index-browser-umd.min.cjs index 2767af5..fb6ba76 100644 --- a/dist/index-browser-umd.min.js +++ b/dist/index-browser-umd.min.cjs @@ -1,2 +1,2 @@ !function(t,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r((t="undefined"!=typeof globalThis?globalThis: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 Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function o(t,r,e){return(o=a()?Reflect.construct:function(t,r,e){var a=[null];a.push.apply(a,r);var o=new(Function.bind.apply(t,a));return e&&n(o,e.prototype),o}).apply(null,arguments)}function u(t){var r="function"==typeof Map?new Map:void 0;return(u=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,u)}function u(){return o(t,arguments,e(this).constructor)}return u.prototype=Object.create(t.prototype,{constructor:{value:u,enumerable:!1,writable:!0,configurable:!0}}),n(u,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&&null!=t[Symbol.iterator]||null!=t["@@iterator"])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(t):"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);e1&&s.shift(),this._hasParentSelector=null;var f=this._trace(s,e,["$"],u,i,n).filter((function(t){return t&&!t.isParentSelector}));return f.length?l||1!==f.length||f[0].hasArrExpr?f.reduce((function(t,r){var e=o._getPreferredOutput(r);return c&&Array.isArray(e)?t=t.concat(e):t.push(e),t}),[]):this._getPreferredOutput(f[0]):l?[]:void 0}},v.prototype._getPreferredOutput=function(t){var r=this.currResultType;switch(r){case"all":var e=Array.isArray(t.path)?t.path:v.toPathArray(t.path);return t.pointer=v.toPointer(e),t.path="string"==typeof t.path?t.path:v.toPathString(t.path),t;case"value":case"parent":case"parentProperty":return t[r];case"path":return v.toPathString(t[r]);case"pointer":return v.toPointer(t.path);default:throw new TypeError("Unknown result type")}},v.prototype._handleCallback=function(t,r,e){if(r){var n=this._getPreferredOutput(t);t.path="string"==typeof t.path?t.path:v.toPathString(t.path),r(n,e,t)}},v.prototype._trace=function(t,e,n,a,o,u,i,c){var s,y=this;if(!t.length)return s={path:n,value:e,parent:a,parentProperty:o,hasArrExpr:i},this._handleCallback(s,u,"value"),s;var v=t[0],b=t.slice(1),F=[];function d(t){Array.isArray(t)?t.forEach((function(t){F.push(t)})):F.push(t)}if(("string"!=typeof v||c)&&e&&p.call(e,v))d(this._trace(b,e[v],f(n,v),e,v,u,i));else if("*"===v)this._walk(v,b,e,n,a,o,u,(function(t,r,e,n,a,o,u,i){d(y._trace(h(t,e),n,a,o,u,i,!0,!0))}));else if(".."===v)d(this._trace(b,e,n,a,o,u,i)),this._walk(v,b,e,n,a,o,u,(function(t,e,n,a,o,u,i,c){"object"===r(a[t])&&d(y._trace(h(e,n),a[t],f(o,t),a,t,c,!0))}));else{if("^"===v)return this._hasParentSelector=!0,{path:n.slice(0,-1),expr:b,isParentSelector:!0};if("~"===v)return s={path:f(n,v),value:o,parent:a,parentProperty:null},this._handleCallback(s,u,"property"),s;if("$"===v)d(this._trace(b,e,n,null,null,u,i));else if(/^(\x2D?[0-9]*):(\x2D?[0-9]*):?([0-9]*)$/.test(v))d(this._slice(v,b,e,n,a,o,u));else if(0===v.indexOf("?(")){if(this.currPreventEval)throw new Error("Eval [?(expr)] prevented in JSONPath expression.");this._walk(v,b,e,n,a,o,u,(function(t,r,e,n,a,o,u,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,o,u)&&d(y._trace(h(t,e),n,a,o,u,i,!0))}))}else if("("===v[0]){if(this.currPreventEval)throw new Error("Eval [(expr)] prevented in JSONPath expression.");d(this._trace(h(this._eval(v,e,n[n.length-1],n.slice(0,-1),a,o),b),e,n,a,o,u,i))}else if("@"===v[0]){var g=!1,_=v.slice(1,-2);switch(_){case"scalar":e&&["object","function"].includes(r(e))||(g=!0);break;case"boolean":case"string":case"undefined":case"function":r(e)===_&&(g=!0);break;case"integer":!Number.isFinite(e)||e%1||(g=!0);break;case"number":Number.isFinite(e)&&(g=!0);break;case"nonFinite":"number"!=typeof e||Number.isFinite(e)||(g=!0);break;case"object":e&&r(e)===_&&(g=!0);break;case"array":Array.isArray(e)&&(g=!0);break;case"other":g=this.currOtherTypeCallback(e,n,a,o);break;case"null":null===e&&(g=!0);break;default:throw new TypeError("Unknown value type "+_)}if(g)return s={path:n,value:e,parent:a,parentProperty:o},this._handleCallback(s,u,"value"),s}else if("`"===v[0]&&e&&p.call(e,v.slice(1))){var w=v.slice(1);d(this._trace(b,e[w],f(n,w),e,w,u,i,!0))}else if(v.includes(",")){var m,P=function(t,r){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=l(t))||r&&t&&"number"==typeof t.length){e&&(t=e);var n=0,a=function(){};return{s:a,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,u=!0,i=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return u=t.done,t},e:function(t){i=!0,o=t},f:function(){try{u||null==e.return||e.return()}finally{if(i)throw o}}}}(v.split(","));try{for(P.s();!(m=P.n()).done;){var D=m.value;d(this._trace(h(D,b),e,n,a,o,u,!0))}}catch(t){P.e(t)}finally{P.f()}}else!c&&e&&p.call(e,v)&&d(this._trace(b,e[v],f(n,v),e,v,u,i,!0))}if(this._hasParentSelector)for(var x=0;x-1?t.slice(0,i+1)+" return "+t.slice(i+1):" return "+t;return o(Function,c(e).concat([l])).apply(void 0,c(a))}},t.JSONPath=v,Object.defineProperty(t,"__esModule",{value:!0})})); -//# sourceMappingURL=index-browser-umd.min.js.map +//# sourceMappingURL=index-browser-umd.min.cjs.map diff --git a/dist/index-browser-umd.min.cjs.map b/dist/index-browser-umd.min.cjs.map new file mode 100644 index 0000000..5081b88 --- /dev/null +++ b/dist/index-browser-umd.min.cjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index-browser-umd.min.cjs","sources":["../src/jsonpath.js","../src/jsonpath-browser.js"],"sourcesContent":["const {hasOwnProperty: hasOwnProp} = Object.prototype;\n\n/**\n* @typedef {null|boolean|number|string|PlainObject|GenericArray} JSONObject\n*/\n\n/**\n * Copies array and then pushes item into it.\n * @param {GenericArray} arr Array to copy and into which to push\n * @param {any} item Array item to add (to end)\n * @returns {GenericArray} Copy of the original array\n */\nfunction push (arr, item) {\n arr = arr.slice();\n arr.push(item);\n return arr;\n}\n/**\n * Copies array and then unshifts item into it.\n * @param {any} item Array item to add (to beginning)\n * @param {GenericArray} arr Array to copy and into which to unshift\n * @returns {GenericArray} Copy of the original array\n */\nfunction unshift (item, arr) {\n arr = arr.slice();\n arr.unshift(item);\n return arr;\n}\n\n/**\n * Caught when JSONPath is used without `new` but rethrown if with `new`\n * @extends Error\n */\nclass NewError extends Error {\n /**\n * @param {any} value The evaluated scalar value\n */\n constructor (value) {\n super(\n 'JSONPath should not be called with \"new\" (it prevents return ' +\n 'of (unwrapped) scalar values)'\n );\n this.avoidNew = true;\n this.value = value;\n this.name = 'NewError';\n }\n}\n\n/**\n* @typedef {PlainObject} ReturnObject\n* @property {string} path\n* @property {JSONObject} value\n* @property {PlainObject|GenericArray} parent\n* @property {string} parentProperty\n*/\n\n/**\n* @callback JSONPathCallback\n* @param {string|PlainObject} preferredOutput\n* @param {\"value\"|\"property\"} type\n* @param {ReturnObject} fullRetObj\n* @returns {void}\n*/\n\n/**\n* @callback OtherTypeCallback\n* @param {JSONObject} val\n* @param {string} path\n* @param {PlainObject|GenericArray} parent\n* @param {string} parentPropName\n* @returns {boolean}\n*/\n\n/* eslint-disable max-len -- Can make multiline type after https://github.com/syavorsky/comment-parser/issues/109 */\n/**\n * @typedef {PlainObject} JSONPathOptions\n * @property {JSON} json\n * @property {string|string[]} path\n * @property {\"value\"|\"path\"|\"pointer\"|\"parent\"|\"parentProperty\"|\"all\"} [resultType=\"value\"]\n * @property {boolean} [flatten=false]\n * @property {boolean} [wrap=true]\n * @property {PlainObject} [sandbox={}]\n * @property {boolean} [preventEval=false]\n * @property {PlainObject|GenericArray|null} [parent=null]\n * @property {string|null} [parentProperty=null]\n * @property {JSONPathCallback} [callback]\n * @property {OtherTypeCallback} [otherTypeCallback] Defaults to\n * function which throws on encountering `@other`\n * @property {boolean} [autostart=true]\n */\n/* eslint-enable max-len -- Can make multiline type after https://github.com/syavorsky/comment-parser/issues/109 */\n\n/**\n * @param {string|JSONPathOptions} opts If a string, will be treated as `expr`\n * @param {string} [expr] JSON path to evaluate\n * @param {JSON} [obj] JSON object to evaluate against\n * @param {JSONPathCallback} [callback] Passed 3 arguments: 1) desired payload\n * per `resultType`, 2) `\"value\"|\"property\"`, 3) Full returned object with\n * all payloads\n * @param {OtherTypeCallback} [otherTypeCallback] If `@other()` is at the end\n * of one's query, this will be invoked with the value of the item, its\n * path, its parent, and its parent's property name, and it should return\n * a boolean indicating whether the supplied value belongs to the \"other\"\n * type or not (or it may handle transformations and return `false`).\n * @returns {JSONPath}\n * @class\n */\nfunction JSONPath (opts, expr, obj, callback, otherTypeCallback) {\n // eslint-disable-next-line no-restricted-syntax\n if (!(this instanceof JSONPath)) {\n try {\n return new JSONPath(opts, expr, obj, callback, otherTypeCallback);\n } catch (e) {\n if (!e.avoidNew) {\n throw e;\n }\n return e.value;\n }\n }\n\n if (typeof opts === 'string') {\n otherTypeCallback = callback;\n callback = obj;\n obj = expr;\n expr = opts;\n opts = null;\n }\n const optObj = opts && typeof opts === 'object';\n opts = opts || {};\n this.json = opts.json || obj;\n this.path = opts.path || expr;\n this.resultType = opts.resultType || 'value';\n this.flatten = opts.flatten || false;\n this.wrap = hasOwnProp.call(opts, 'wrap') ? opts.wrap : true;\n this.sandbox = opts.sandbox || {};\n this.preventEval = opts.preventEval || false;\n this.parent = opts.parent || null;\n this.parentProperty = opts.parentProperty || null;\n this.callback = opts.callback || callback || null;\n this.otherTypeCallback = opts.otherTypeCallback ||\n otherTypeCallback ||\n function () {\n throw new TypeError(\n 'You must supply an otherTypeCallback callback option ' +\n 'with the @other() operator.'\n );\n };\n\n if (opts.autostart !== false) {\n const args = {\n path: (optObj ? opts.path : expr)\n };\n if (!optObj) {\n args.json = obj;\n } else if ('json' in opts) {\n args.json = opts.json;\n }\n const ret = this.evaluate(args);\n if (!ret || typeof ret !== 'object') {\n throw new NewError(ret);\n }\n return ret;\n }\n}\n\n// PUBLIC METHODS\nJSONPath.prototype.evaluate = function (\n expr, json, callback, otherTypeCallback\n) {\n let currParent = this.parent,\n currParentProperty = this.parentProperty;\n let {flatten, wrap} = this;\n\n this.currResultType = this.resultType;\n this.currPreventEval = this.preventEval;\n this.currSandbox = this.sandbox;\n callback = callback || this.callback;\n this.currOtherTypeCallback = otherTypeCallback || this.otherTypeCallback;\n\n json = json || this.json;\n expr = expr || this.path;\n if (expr && typeof expr === 'object' && !Array.isArray(expr)) {\n if (!expr.path && expr.path !== '') {\n throw new TypeError(\n 'You must supply a \"path\" property when providing an object ' +\n 'argument to JSONPath.evaluate().'\n );\n }\n if (!(hasOwnProp.call(expr, 'json'))) {\n throw new TypeError(\n 'You must supply a \"json\" property when providing an object ' +\n 'argument to JSONPath.evaluate().'\n );\n }\n ({json} = expr);\n flatten = hasOwnProp.call(expr, 'flatten') ? expr.flatten : flatten;\n this.currResultType = hasOwnProp.call(expr, 'resultType')\n ? expr.resultType\n : this.currResultType;\n this.currSandbox = hasOwnProp.call(expr, 'sandbox')\n ? expr.sandbox\n : this.currSandbox;\n wrap = hasOwnProp.call(expr, 'wrap') ? expr.wrap : wrap;\n this.currPreventEval = hasOwnProp.call(expr, 'preventEval')\n ? expr.preventEval\n : this.currPreventEval;\n callback = hasOwnProp.call(expr, 'callback') ? expr.callback : callback;\n this.currOtherTypeCallback = hasOwnProp.call(expr, 'otherTypeCallback')\n ? expr.otherTypeCallback\n : this.currOtherTypeCallback;\n currParent = hasOwnProp.call(expr, 'parent') ? expr.parent : currParent;\n currParentProperty = hasOwnProp.call(expr, 'parentProperty')\n ? expr.parentProperty\n : currParentProperty;\n expr = expr.path;\n }\n currParent = currParent || null;\n currParentProperty = currParentProperty || null;\n\n if (Array.isArray(expr)) {\n expr = JSONPath.toPathString(expr);\n }\n if ((!expr && expr !== '') || !json) {\n return undefined;\n }\n\n const exprList = JSONPath.toPathArray(expr);\n if (exprList[0] === '$' && exprList.length > 1) { exprList.shift(); }\n this._hasParentSelector = null;\n const result = this\n ._trace(\n exprList, json, ['$'], currParent, currParentProperty, callback\n )\n .filter(function (ea) { return ea && !ea.isParentSelector; });\n\n if (!result.length) { return wrap ? [] : undefined; }\n if (!wrap && result.length === 1 && !result[0].hasArrExpr) {\n return this._getPreferredOutput(result[0]);\n }\n return result.reduce((rslt, ea) => {\n const valOrPath = this._getPreferredOutput(ea);\n if (flatten && Array.isArray(valOrPath)) {\n rslt = rslt.concat(valOrPath);\n } else {\n rslt.push(valOrPath);\n }\n return rslt;\n }, []);\n};\n\n// PRIVATE METHODS\n\nJSONPath.prototype._getPreferredOutput = function (ea) {\n const resultType = this.currResultType;\n switch (resultType) {\n case 'all': {\n const path = Array.isArray(ea.path)\n ? ea.path\n : JSONPath.toPathArray(ea.path);\n ea.pointer = JSONPath.toPointer(path);\n ea.path = typeof ea.path === 'string'\n ? ea.path\n : JSONPath.toPathString(ea.path);\n return ea;\n } case 'value': case 'parent': case 'parentProperty':\n return ea[resultType];\n case 'path':\n return JSONPath.toPathString(ea[resultType]);\n case 'pointer':\n return JSONPath.toPointer(ea.path);\n default:\n throw new TypeError('Unknown result type');\n }\n};\n\nJSONPath.prototype._handleCallback = function (fullRetObj, callback, type) {\n if (callback) {\n const preferredOutput = this._getPreferredOutput(fullRetObj);\n fullRetObj.path = typeof fullRetObj.path === 'string'\n ? fullRetObj.path\n : JSONPath.toPathString(fullRetObj.path);\n // eslint-disable-next-line node/callback-return\n callback(preferredOutput, type, fullRetObj);\n }\n};\n\n/**\n *\n * @param {string} expr\n * @param {JSONObject} val\n * @param {string} path\n * @param {PlainObject|GenericArray} parent\n * @param {string} parentPropName\n * @param {JSONPathCallback} callback\n * @param {boolean} hasArrExpr\n * @param {boolean} literalPriority\n * @returns {ReturnObject|ReturnObject[]}\n */\nJSONPath.prototype._trace = function (\n expr, val, path, parent, parentPropName, callback, hasArrExpr,\n literalPriority\n) {\n // No expr to follow? return path and value as the result of\n // this trace branch\n let retObj;\n if (!expr.length) {\n retObj = {\n path,\n value: val,\n parent,\n parentProperty: parentPropName,\n hasArrExpr\n };\n this._handleCallback(retObj, callback, 'value');\n return retObj;\n }\n\n const loc = expr[0], x = expr.slice(1);\n\n // We need to gather the return value of recursive trace calls in order to\n // do the parent sel computation.\n const ret = [];\n /**\n *\n * @param {ReturnObject|ReturnObject[]} elems\n * @returns {void}\n */\n function addRet (elems) {\n if (Array.isArray(elems)) {\n // This was causing excessive stack size in Node (with or\n // without Babel) against our performance test:\n // `ret.push(...elems);`\n elems.forEach((t) => {\n ret.push(t);\n });\n } else {\n ret.push(elems);\n }\n }\n if ((typeof loc !== 'string' || literalPriority) && val &&\n hasOwnProp.call(val, loc)\n ) { // simple case--directly follow property\n addRet(this._trace(x, val[loc], push(path, loc), val, loc, callback,\n hasArrExpr));\n // eslint-disable-next-line unicorn/prefer-switch -- Part of larger `if`\n } else if (loc === '*') { // all child properties\n this._walk(\n loc, x, val, path, parent, parentPropName, callback,\n (m, l, _x, v, p, par, pr, cb) => {\n addRet(this._trace(unshift(m, _x), v, p, par, pr, cb,\n true, true));\n }\n );\n } else if (loc === '..') { // all descendent parent properties\n // Check remaining expression with val's immediate children\n addRet(\n this._trace(x, val, path, parent, parentPropName, callback,\n hasArrExpr)\n );\n this._walk(\n loc, x, val, path, parent, parentPropName, callback,\n (m, l, _x, v, p, par, pr, cb) => {\n // We don't join m and x here because we only want parents,\n // not scalar values\n if (typeof v[m] === 'object') {\n // Keep going with recursive descent on val's\n // object children\n addRet(this._trace(\n unshift(l, _x), v[m], push(p, m), v, m, cb, true\n ));\n }\n }\n );\n // The parent sel computation is handled in the frame above using the\n // ancestor object of val\n } else if (loc === '^') {\n // This is not a final endpoint, so we do not invoke the callback here\n this._hasParentSelector = true;\n return {\n path: path.slice(0, -1),\n expr: x,\n isParentSelector: true\n };\n } else if (loc === '~') { // property name\n retObj = {\n path: push(path, loc),\n value: parentPropName,\n parent,\n parentProperty: null\n };\n this._handleCallback(retObj, callback, 'property');\n return retObj;\n } else if (loc === '$') { // root only\n addRet(this._trace(x, val, path, null, null, callback, hasArrExpr));\n } else if ((/^(-?\\d*):(-?\\d*):?(\\d*)$/u).test(loc)) { // [start:end:step] Python slice syntax\n addRet(\n this._slice(loc, x, val, path, parent, parentPropName, callback)\n );\n } else if (loc.indexOf('?(') === 0) { // [?(expr)] (filtering)\n if (this.currPreventEval) {\n throw new Error('Eval [?(expr)] prevented in JSONPath expression.');\n }\n this._walk(\n loc, x, val, path, parent, parentPropName, callback,\n (m, l, _x, v, p, par, pr, cb) => {\n if (this._eval(l.replace(/^\\?\\((.*?)\\)$/u, '$1'), v[m], m, p, par, pr)) {\n addRet(this._trace(unshift(m, _x), v, p, par, pr, cb,\n true));\n }\n }\n );\n } else if (loc[0] === '(') { // [(expr)] (dynamic property/index)\n if (this.currPreventEval) {\n throw new Error('Eval [(expr)] prevented in JSONPath expression.');\n }\n // As this will resolve to a property name (but we don't know it\n // yet), property and parent information is relative to the\n // parent of the property to which this expression will resolve\n addRet(this._trace(unshift(\n this._eval(\n loc, val, path[path.length - 1],\n path.slice(0, -1), parent, parentPropName\n ),\n x\n ), val, path, parent, parentPropName, callback, hasArrExpr));\n } else if (loc[0] === '@') { // value type: @boolean(), etc.\n let addType = false;\n const valueType = loc.slice(1, -2);\n switch (valueType) {\n case 'scalar':\n if (!val || !(['object', 'function'].includes(typeof val))) {\n addType = true;\n }\n break;\n case 'boolean': case 'string': case 'undefined': case 'function':\n // eslint-disable-next-line valid-typeof\n if (typeof val === valueType) {\n addType = true;\n }\n break;\n case 'integer':\n if (Number.isFinite(val) && !(val % 1)) {\n addType = true;\n }\n break;\n case 'number':\n if (Number.isFinite(val)) {\n addType = true;\n }\n break;\n case 'nonFinite':\n if (typeof val === 'number' && !Number.isFinite(val)) {\n addType = true;\n }\n break;\n case 'object':\n // eslint-disable-next-line valid-typeof\n if (val && typeof val === valueType) {\n addType = true;\n }\n break;\n case 'array':\n if (Array.isArray(val)) {\n addType = true;\n }\n break;\n case 'other':\n addType = this.currOtherTypeCallback(\n val, path, parent, parentPropName\n );\n break;\n case 'null':\n if (val === null) {\n addType = true;\n }\n break;\n /* c8 ignore next 2 */\n default:\n throw new TypeError('Unknown value type ' + valueType);\n }\n if (addType) {\n retObj = {path, value: val, parent, parentProperty: parentPropName};\n this._handleCallback(retObj, callback, 'value');\n return retObj;\n }\n // `-escaped property\n } else if (loc[0] === '`' && val && hasOwnProp.call(val, loc.slice(1))) {\n const locProp = loc.slice(1);\n addRet(this._trace(\n x, val[locProp], push(path, locProp), val, locProp, callback,\n hasArrExpr, true\n ));\n } else if (loc.includes(',')) { // [name1,name2,...]\n const parts = loc.split(',');\n for (const part of parts) {\n addRet(this._trace(\n unshift(part, x), val, path, parent, parentPropName, callback,\n true\n ));\n }\n // simple case--directly follow property\n } else if (\n !literalPriority && val && hasOwnProp.call(val, loc)\n ) {\n addRet(\n this._trace(x, val[loc], push(path, loc), val, loc, callback,\n hasArrExpr, true)\n );\n }\n\n // We check the resulting values for parent selections. For parent\n // selections we discard the value object and continue the trace with the\n // current val object\n if (this._hasParentSelector) {\n for (let t = 0; t < ret.length; t++) {\n const rett = ret[t];\n if (rett && rett.isParentSelector) {\n const tmp = this._trace(\n rett.expr, val, rett.path, parent, parentPropName, callback,\n hasArrExpr\n );\n if (Array.isArray(tmp)) {\n ret[t] = tmp[0];\n const tl = tmp.length;\n for (let tt = 1; tt < tl; tt++) {\n t++;\n ret.splice(t, 0, tmp[tt]);\n }\n } else {\n ret[t] = tmp;\n }\n }\n }\n }\n return ret;\n};\n\nJSONPath.prototype._walk = function (\n loc, expr, val, path, parent, parentPropName, callback, f\n) {\n if (Array.isArray(val)) {\n const n = val.length;\n for (let i = 0; i < n; i++) {\n f(i, loc, expr, val, path, parent, parentPropName, callback);\n }\n } else if (val && typeof val === 'object') {\n Object.keys(val).forEach((m) => {\n f(m, loc, expr, val, path, parent, parentPropName, callback);\n });\n }\n};\n\nJSONPath.prototype._slice = function (\n loc, expr, val, path, parent, parentPropName, callback\n) {\n if (!Array.isArray(val)) { return undefined; }\n const len = val.length, parts = loc.split(':'),\n step = (parts[2] && Number.parseInt(parts[2])) || 1;\n let start = (parts[0] && Number.parseInt(parts[0])) || 0,\n end = (parts[1] && Number.parseInt(parts[1])) || len;\n start = (start < 0) ? Math.max(0, start + len) : Math.min(len, start);\n end = (end < 0) ? Math.max(0, end + len) : Math.min(len, end);\n const ret = [];\n for (let i = start; i < end; i += step) {\n const tmp = this._trace(\n unshift(i, expr), val, path, parent, parentPropName, callback, true\n );\n // Should only be possible to be an array here since first part of\n // ``unshift(i, expr)` passed in above would not be empty, nor `~`,\n // nor begin with `@` (as could return objects)\n // This was causing excessive stack size in Node (with or\n // without Babel) against our performance test: `ret.push(...tmp);`\n tmp.forEach((t) => {\n ret.push(t);\n });\n }\n return ret;\n};\n\nJSONPath.prototype._eval = function (\n code, _v, _vname, path, parent, parentPropName\n) {\n if (code.includes('@parentProperty')) {\n this.currSandbox._$_parentProperty = parentPropName;\n code = code.replace(/@parentProperty/gu, '_$_parentProperty');\n }\n if (code.includes('@parent')) {\n this.currSandbox._$_parent = parent;\n code = code.replace(/@parent/gu, '_$_parent');\n }\n if (code.includes('@property')) {\n this.currSandbox._$_property = _vname;\n code = code.replace(/@property/gu, '_$_property');\n }\n if (code.includes('@path')) {\n this.currSandbox._$_path = JSONPath.toPathString(path.concat([_vname]));\n code = code.replace(/@path/gu, '_$_path');\n }\n if (code.includes('@root')) {\n this.currSandbox._$_root = this.json;\n code = code.replace(/@root/gu, '_$_root');\n }\n if ((/@([.\\s)[])/u).test(code)) {\n this.currSandbox._$_v = _v;\n code = code.replace(/@([.\\s)[])/gu, '_$_v$1');\n }\n try {\n return this.vm.runInNewContext(code, this.currSandbox);\n } catch (e) {\n // eslint-disable-next-line no-console\n console.log(e);\n throw new Error('jsonPath: ' + e.message + ': ' + code);\n }\n};\n\n// PUBLIC CLASS PROPERTIES AND METHODS\n\n// Could store the cache object itself\nJSONPath.cache = {};\n\n/**\n * @param {string[]} pathArr Array to convert\n * @returns {string} The path string\n */\nJSONPath.toPathString = function (pathArr) {\n const x = pathArr, n = x.length;\n let p = '$';\n for (let i = 1; i < n; i++) {\n if (!(/^(~|\\^|@.*?\\(\\))$/u).test(x[i])) {\n p += (/^[0-9*]+$/u).test(x[i]) ? ('[' + x[i] + ']') : (\"['\" + x[i] + \"']\");\n }\n }\n return p;\n};\n\n/**\n * @param {string} pointer JSON Path\n * @returns {string} JSON Pointer\n */\nJSONPath.toPointer = function (pointer) {\n const x = pointer, n = x.length;\n let p = '';\n for (let i = 1; i < n; i++) {\n if (!(/^(~|\\^|@.*?\\(\\))$/u).test(x[i])) {\n p += '/' + x[i].toString()\n .replace(/~/gu, '~0')\n .replace(/\\//gu, '~1');\n }\n }\n return p;\n};\n\n/**\n * @param {string} expr Expression to convert\n * @returns {string[]}\n */\nJSONPath.toPathArray = function (expr) {\n const {cache} = JSONPath;\n if (cache[expr]) { return cache[expr].concat(); }\n const subx = [];\n const normalized = expr\n // Properties\n .replace(\n /@(?:null|boolean|number|string|integer|undefined|nonFinite|scalar|array|object|function|other)\\(\\)/gu,\n ';$&;'\n )\n // Parenthetical evaluations (filtering and otherwise), directly\n // within brackets or single quotes\n .replace(/[['](\\??\\(.*?\\))[\\]']/gu, function ($0, $1) {\n return '[#' + (subx.push($1) - 1) + ']';\n })\n // Escape periods and tildes within properties\n .replace(/\\[['\"]([^'\\]]*)['\"]\\]/gu, function ($0, prop) {\n return \"['\" + prop\n .replace(/\\./gu, '%@%')\n .replace(/~/gu, '%%@@%%') +\n \"']\";\n })\n // Properties operator\n .replace(/~/gu, ';~;')\n // Split by property boundaries\n .replace(/['\"]?\\.['\"]?(?![^[]*\\])|\\[['\"]?/gu, ';')\n // Reinsert periods within properties\n .replace(/%@%/gu, '.')\n // Reinsert tildes within properties\n .replace(/%%@@%%/gu, '~')\n // Parent\n .replace(/(?:;)?(\\^+)(?:;)?/gu, function ($0, ups) {\n return ';' + ups.split('').join(';') + ';';\n })\n // Descendents\n .replace(/;;;|;;/gu, ';..;')\n // Remove trailing\n .replace(/;$|'?\\]|'$/gu, '');\n\n const exprList = normalized.split(';').map(function (exp) {\n const match = exp.match(/#(\\d+)/u);\n return !match || !match[1] ? exp : subx[match[1]];\n });\n cache[expr] = exprList;\n return cache[expr].concat();\n};\n\nexport {JSONPath};\n","import {JSONPath} from './jsonpath.js';\n\n/**\n* @callback ConditionCallback\n* @param {any} item\n* @returns {boolean}\n*/\n\n/**\n * Copy items out of one array into another.\n * @param {GenericArray} source Array with items to copy\n * @param {GenericArray} target Array to which to copy\n * @param {ConditionCallback} conditionCb Callback passed the current item;\n * will move item if evaluates to `true`\n * @returns {void}\n */\nconst moveToAnotherArray = function (source, target, conditionCb) {\n const il = source.length;\n for (let i = 0; i < il; i++) {\n const item = source[i];\n if (conditionCb(item)) {\n target.push(source.splice(i--, 1)[0]);\n }\n }\n};\n\nJSONPath.prototype.vm = {\n /**\n * @param {string} expr Expression to evaluate\n * @param {PlainObject} context Object whose items will be added\n * to evaluation\n * @returns {any} Result of evaluated code\n */\n runInNewContext (expr, context) {\n const keys = Object.keys(context);\n const funcs = [];\n moveToAnotherArray(keys, funcs, (key) => {\n return typeof context[key] === 'function';\n });\n const values = keys.map((vr, i) => {\n return context[vr];\n });\n\n const funcString = funcs.reduce((s, func) => {\n let fString = context[func].toString();\n if (!(/function/u).test(fString)) {\n fString = 'function ' + fString;\n }\n return 'var ' + func + '=' + fString + ';' + s;\n }, '');\n\n expr = funcString + expr;\n\n // Mitigate http://perfectionkills.com/global-eval-what-are-the-options/#new_function\n if (!(/(['\"])use strict\\1/u).test(expr) &&\n !keys.includes('arguments')\n ) {\n expr = 'var arguments = undefined;' + expr;\n }\n\n // Remove last semi so `return` will be inserted before\n // the previous one instead, allowing for the return\n // of a bare ending expression\n expr = expr.replace(/;\\s*$/u, '');\n\n // Insert `return`\n const lastStatementEnd = expr.lastIndexOf(';');\n const code = (lastStatementEnd > -1\n ? expr.slice(0, lastStatementEnd + 1) +\n ' return ' + expr.slice(lastStatementEnd + 1)\n : ' return ' + expr);\n\n // eslint-disable-next-line no-new-func\n return (new Function(...keys, code))(...values);\n }\n};\n\nexport {JSONPath};\n"],"names":["hasOwnProp","Object","prototype","hasOwnProperty","push","arr","item","slice","unshift","NewError","value","avoidNew","name","Error","JSONPath","opts","expr","obj","callback","otherTypeCallback","this","e","optObj","_typeof","json","path","resultType","flatten","wrap","call","sandbox","preventEval","parent","parentProperty","TypeError","autostart","args","ret","evaluate","currParent","currParentProperty","currResultType","currPreventEval","currSandbox","currOtherTypeCallback","Array","isArray","toPathString","exprList","toPathArray","length","shift","_hasParentSelector","result","_trace","filter","ea","isParentSelector","hasArrExpr","reduce","rslt","valOrPath","_this2","_getPreferredOutput","concat","undefined","pointer","toPointer","_handleCallback","fullRetObj","type","preferredOutput","val","parentPropName","literalPriority","retObj","loc","x","addRet","elems","forEach","t","_walk","m","l","_x","v","p","par","pr","cb","_this3","test","_slice","indexOf","_eval","replace","addType","valueType","includes","Number","isFinite","locProp","split","part","rett","tmp","tl","tt","splice","f","n","i","keys","len","parts","step","parseInt","start","end","Math","max","min","code","_v","_vname","_$_parentProperty","_$_parent","_$_property","_$_path","_$_root","_$_v","vm","runInNewContext","console","log","message","cache","pathArr","toString","subx","$0","$1","prop","ups","join","map","exp","match","context","funcs","source","target","conditionCb","il","moveToAnotherArray","key","values","vr","funcString","s","func","fString","lastStatementEnd","lastIndexOf","_construct","Function"],"mappings":"mhFAAA,IAAuBA,EAAcC,OAAOC,UAArCC,eAYP,SAASC,EAAMC,EAAKC,UAChBD,EAAMA,EAAIE,SACNH,KAAKE,GACFD,EAQX,SAASG,EAASF,EAAMD,UACpBA,EAAMA,EAAIE,SACNC,QAAQF,GACLD,MAOLI,oaAIWC,oIAEL,+FAGCC,UAAW,IACXD,MAAQA,IACRE,KAAO,yBAXGC,QA0EvB,SAASC,EAAUC,EAAMC,EAAMC,EAAKC,EAAUC,QAEpCC,gBAAgBN,cAEP,IAAIA,EAASC,EAAMC,EAAMC,EAAKC,EAAUC,GACjD,MAAOE,OACAA,EAAEV,eACGU,SAEHA,EAAEX,MAIG,iBAATK,IACPI,EAAoBD,EACpBA,EAAWD,EACXA,EAAMD,EACNA,EAAOD,EACPA,EAAO,UAELO,EAASP,GAAwB,WAAhBQ,EAAOR,MAC9BA,EAAOA,GAAQ,QACVS,KAAOT,EAAKS,MAAQP,OACpBQ,KAAOV,EAAKU,MAAQT,OACpBU,WAAaX,EAAKW,YAAc,aAChCC,QAAUZ,EAAKY,UAAW,OAC1B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.js.map deleted file mode 100644 index 10244e9..0000000 --- a/dist/index-browser-umd.min.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index-browser-umd.min.js","sources":["../src/jsonpath.js","../src/jsonpath-browser.js"],"sourcesContent":["const {hasOwnProperty: hasOwnProp} = Object.prototype;\n\n/**\n* @typedef {null|boolean|number|string|PlainObject|GenericArray} JSONObject\n*/\n\n/**\n * Copies array and then pushes item into it.\n * @param {GenericArray} arr Array to copy and into which to push\n * @param {any} item Array item to add (to end)\n * @returns {GenericArray} Copy of the original array\n */\nfunction push (arr, item) {\n arr = arr.slice();\n arr.push(item);\n return arr;\n}\n/**\n * Copies array and then unshifts item into it.\n * @param {any} item Array item to add (to beginning)\n * @param {GenericArray} arr Array to copy and into which to unshift\n * @returns {GenericArray} Copy of the original array\n */\nfunction unshift (item, arr) {\n arr = arr.slice();\n arr.unshift(item);\n return arr;\n}\n\n/**\n * Caught when JSONPath is used without `new` but rethrown if with `new`\n * @extends Error\n */\nclass NewError extends Error {\n /**\n * @param {any} value The evaluated scalar value\n */\n constructor (value) {\n super(\n 'JSONPath should not be called with \"new\" (it prevents return ' +\n 'of (unwrapped) scalar values)'\n );\n this.avoidNew = true;\n this.value = value;\n this.name = 'NewError';\n }\n}\n\n/**\n* @typedef {PlainObject} ReturnObject\n* @property {string} path\n* @property {JSONObject} value\n* @property {PlainObject|GenericArray} parent\n* @property {string} parentProperty\n*/\n\n/**\n* @callback JSONPathCallback\n* @param {string|PlainObject} preferredOutput\n* @param {\"value\"|\"property\"} type\n* @param {ReturnObject} fullRetObj\n* @returns {void}\n*/\n\n/**\n* @callback OtherTypeCallback\n* @param {JSONObject} val\n* @param {string} path\n* @param {PlainObject|GenericArray} parent\n* @param {string} parentPropName\n* @returns {boolean}\n*/\n\n/* eslint-disable max-len -- Can make multiline type after https://github.com/syavorsky/comment-parser/issues/109 */\n/**\n * @typedef {PlainObject} JSONPathOptions\n * @property {JSON} json\n * @property {string|string[]} path\n * @property {\"value\"|\"path\"|\"pointer\"|\"parent\"|\"parentProperty\"|\"all\"} [resultType=\"value\"]\n * @property {boolean} [flatten=false]\n * @property {boolean} [wrap=true]\n * @property {PlainObject} [sandbox={}]\n * @property {boolean} [preventEval=false]\n * @property {PlainObject|GenericArray|null} [parent=null]\n * @property {string|null} [parentProperty=null]\n * @property {JSONPathCallback} [callback]\n * @property {OtherTypeCallback} [otherTypeCallback] Defaults to\n * function which throws on encountering `@other`\n * @property {boolean} [autostart=true]\n */\n/* eslint-enable max-len -- Can make multiline type after https://github.com/syavorsky/comment-parser/issues/109 */\n\n/**\n * @param {string|JSONPathOptions} opts If a string, will be treated as `expr`\n * @param {string} [expr] JSON path to evaluate\n * @param {JSON} [obj] JSON object to evaluate against\n * @param {JSONPathCallback} [callback] Passed 3 arguments: 1) desired payload\n * per `resultType`, 2) `\"value\"|\"property\"`, 3) Full returned object with\n * all payloads\n * @param {OtherTypeCallback} [otherTypeCallback] If `@other()` is at the end\n * of one's query, this will be invoked with the value of the item, its\n * path, its parent, and its parent's property name, and it should return\n * a boolean indicating whether the supplied value belongs to the \"other\"\n * type or not (or it may handle transformations and return `false`).\n * @returns {JSONPath}\n * @class\n */\nfunction JSONPath (opts, expr, obj, callback, otherTypeCallback) {\n // eslint-disable-next-line no-restricted-syntax\n if (!(this instanceof JSONPath)) {\n try {\n return new JSONPath(opts, expr, obj, callback, otherTypeCallback);\n } catch (e) {\n if (!e.avoidNew) {\n throw e;\n }\n return e.value;\n }\n }\n\n if (typeof opts === 'string') {\n otherTypeCallback = callback;\n callback = obj;\n obj = expr;\n expr = opts;\n opts = null;\n }\n const optObj = opts && typeof opts === 'object';\n opts = opts || {};\n this.json = opts.json || obj;\n this.path = opts.path || expr;\n this.resultType = opts.resultType || 'value';\n this.flatten = opts.flatten || false;\n this.wrap = hasOwnProp.call(opts, 'wrap') ? opts.wrap : true;\n this.sandbox = opts.sandbox || {};\n this.preventEval = opts.preventEval || false;\n this.parent = opts.parent || null;\n this.parentProperty = opts.parentProperty || null;\n this.callback = opts.callback || callback || null;\n this.otherTypeCallback = opts.otherTypeCallback ||\n otherTypeCallback ||\n function () {\n throw new TypeError(\n 'You must supply an otherTypeCallback callback option ' +\n 'with the @other() operator.'\n );\n };\n\n if (opts.autostart !== false) {\n const args = {\n path: (optObj ? opts.path : expr)\n };\n if (!optObj) {\n args.json = obj;\n } else if ('json' in opts) {\n args.json = opts.json;\n }\n const ret = this.evaluate(args);\n if (!ret || typeof ret !== 'object') {\n throw new NewError(ret);\n }\n return ret;\n }\n}\n\n// PUBLIC METHODS\nJSONPath.prototype.evaluate = function (\n expr, json, callback, otherTypeCallback\n) {\n let currParent = this.parent,\n currParentProperty = this.parentProperty;\n let {flatten, wrap} = this;\n\n this.currResultType = this.resultType;\n this.currPreventEval = this.preventEval;\n this.currSandbox = this.sandbox;\n callback = callback || this.callback;\n this.currOtherTypeCallback = otherTypeCallback || this.otherTypeCallback;\n\n json = json || this.json;\n expr = expr || this.path;\n if (expr && typeof expr === 'object' && !Array.isArray(expr)) {\n if (!expr.path && expr.path !== '') {\n throw new TypeError(\n 'You must supply a \"path\" property when providing an object ' +\n 'argument to JSONPath.evaluate().'\n );\n }\n if (!(hasOwnProp.call(expr, 'json'))) {\n throw new TypeError(\n 'You must supply a \"json\" property when providing an object ' +\n 'argument to JSONPath.evaluate().'\n );\n }\n ({json} = expr);\n flatten = hasOwnProp.call(expr, 'flatten') ? expr.flatten : flatten;\n this.currResultType = hasOwnProp.call(expr, 'resultType')\n ? expr.resultType\n : this.currResultType;\n this.currSandbox = hasOwnProp.call(expr, 'sandbox')\n ? expr.sandbox\n : this.currSandbox;\n wrap = hasOwnProp.call(expr, 'wrap') ? expr.wrap : wrap;\n this.currPreventEval = hasOwnProp.call(expr, 'preventEval')\n ? expr.preventEval\n : this.currPreventEval;\n callback = hasOwnProp.call(expr, 'callback') ? expr.callback : callback;\n this.currOtherTypeCallback = hasOwnProp.call(expr, 'otherTypeCallback')\n ? expr.otherTypeCallback\n : this.currOtherTypeCallback;\n currParent = hasOwnProp.call(expr, 'parent') ? expr.parent : currParent;\n currParentProperty = hasOwnProp.call(expr, 'parentProperty')\n ? expr.parentProperty\n : currParentProperty;\n expr = expr.path;\n }\n currParent = currParent || null;\n currParentProperty = currParentProperty || null;\n\n if (Array.isArray(expr)) {\n expr = JSONPath.toPathString(expr);\n }\n if ((!expr && expr !== '') || !json) {\n return undefined;\n }\n\n const exprList = JSONPath.toPathArray(expr);\n if (exprList[0] === '$' && exprList.length > 1) { exprList.shift(); }\n this._hasParentSelector = null;\n const result = this\n ._trace(\n exprList, json, ['$'], currParent, currParentProperty, callback\n )\n .filter(function (ea) { return ea && !ea.isParentSelector; });\n\n if (!result.length) { return wrap ? [] : undefined; }\n if (!wrap && result.length === 1 && !result[0].hasArrExpr) {\n return this._getPreferredOutput(result[0]);\n }\n return result.reduce((rslt, ea) => {\n const valOrPath = this._getPreferredOutput(ea);\n if (flatten && Array.isArray(valOrPath)) {\n rslt = rslt.concat(valOrPath);\n } else {\n rslt.push(valOrPath);\n }\n return rslt;\n }, []);\n};\n\n// PRIVATE METHODS\n\nJSONPath.prototype._getPreferredOutput = function (ea) {\n const resultType = this.currResultType;\n switch (resultType) {\n case 'all': {\n const path = Array.isArray(ea.path)\n ? ea.path\n : JSONPath.toPathArray(ea.path);\n ea.pointer = JSONPath.toPointer(path);\n ea.path = typeof ea.path === 'string'\n ? ea.path\n : JSONPath.toPathString(ea.path);\n return ea;\n } case 'value': case 'parent': case 'parentProperty':\n return ea[resultType];\n case 'path':\n return JSONPath.toPathString(ea[resultType]);\n case 'pointer':\n return JSONPath.toPointer(ea.path);\n default:\n throw new TypeError('Unknown result type');\n }\n};\n\nJSONPath.prototype._handleCallback = function (fullRetObj, callback, type) {\n if (callback) {\n const preferredOutput = this._getPreferredOutput(fullRetObj);\n fullRetObj.path = typeof fullRetObj.path === 'string'\n ? fullRetObj.path\n : JSONPath.toPathString(fullRetObj.path);\n // eslint-disable-next-line node/callback-return\n callback(preferredOutput, type, fullRetObj);\n }\n};\n\n/**\n *\n * @param {string} expr\n * @param {JSONObject} val\n * @param {string} path\n * @param {PlainObject|GenericArray} parent\n * @param {string} parentPropName\n * @param {JSONPathCallback} callback\n * @param {boolean} hasArrExpr\n * @param {boolean} literalPriority\n * @returns {ReturnObject|ReturnObject[]}\n */\nJSONPath.prototype._trace = function (\n expr, val, path, parent, parentPropName, callback, hasArrExpr,\n literalPriority\n) {\n // No expr to follow? return path and value as the result of\n // this trace branch\n let retObj;\n if (!expr.length) {\n retObj = {\n path,\n value: val,\n parent,\n parentProperty: parentPropName,\n hasArrExpr\n };\n this._handleCallback(retObj, callback, 'value');\n return retObj;\n }\n\n const loc = expr[0], x = expr.slice(1);\n\n // We need to gather the return value of recursive trace calls in order to\n // do the parent sel computation.\n const ret = [];\n /**\n *\n * @param {ReturnObject|ReturnObject[]} elems\n * @returns {void}\n */\n function addRet (elems) {\n if (Array.isArray(elems)) {\n // This was causing excessive stack size in Node (with or\n // without Babel) against our performance test:\n // `ret.push(...elems);`\n elems.forEach((t) => {\n ret.push(t);\n });\n } else {\n ret.push(elems);\n }\n }\n if ((typeof loc !== 'string' || literalPriority) && val &&\n hasOwnProp.call(val, loc)\n ) { // simple case--directly follow property\n addRet(this._trace(x, val[loc], push(path, loc), val, loc, callback,\n hasArrExpr));\n // eslint-disable-next-line unicorn/prefer-switch -- Part of larger `if`\n } else if (loc === '*') { // all child properties\n this._walk(\n loc, x, val, path, parent, parentPropName, callback,\n (m, l, _x, v, p, par, pr, cb) => {\n addRet(this._trace(unshift(m, _x), v, p, par, pr, cb,\n true, true));\n }\n );\n } else if (loc === '..') { // all descendent parent properties\n // Check remaining expression with val's immediate children\n addRet(\n this._trace(x, val, path, parent, parentPropName, callback,\n hasArrExpr)\n );\n this._walk(\n loc, x, val, path, parent, parentPropName, callback,\n (m, l, _x, v, p, par, pr, cb) => {\n // We don't join m and x here because we only want parents,\n // not scalar values\n if (typeof v[m] === 'object') {\n // Keep going with recursive descent on val's\n // object children\n addRet(this._trace(\n unshift(l, _x), v[m], push(p, m), v, m, cb, true\n ));\n }\n }\n );\n // The parent sel computation is handled in the frame above using the\n // ancestor object of val\n } else if (loc === '^') {\n // This is not a final endpoint, so we do not invoke the callback here\n this._hasParentSelector = true;\n return {\n path: path.slice(0, -1),\n expr: x,\n isParentSelector: true\n };\n } else if (loc === '~') { // property name\n retObj = {\n path: push(path, loc),\n value: parentPropName,\n parent,\n parentProperty: null\n };\n this._handleCallback(retObj, callback, 'property');\n return retObj;\n } else if (loc === '$') { // root only\n addRet(this._trace(x, val, path, null, null, callback, hasArrExpr));\n } else if ((/^(-?\\d*):(-?\\d*):?(\\d*)$/u).test(loc)) { // [start:end:step] Python slice syntax\n addRet(\n this._slice(loc, x, val, path, parent, parentPropName, callback)\n );\n } else if (loc.indexOf('?(') === 0) { // [?(expr)] (filtering)\n if (this.currPreventEval) {\n throw new Error('Eval [?(expr)] prevented in JSONPath expression.');\n }\n this._walk(\n loc, x, val, path, parent, parentPropName, callback,\n (m, l, _x, v, p, par, pr, cb) => {\n if (this._eval(l.replace(/^\\?\\((.*?)\\)$/u, '$1'), v[m], m, p, par, pr)) {\n addRet(this._trace(unshift(m, _x), v, p, par, pr, cb,\n true));\n }\n }\n );\n } else if (loc[0] === '(') { // [(expr)] (dynamic property/index)\n if (this.currPreventEval) {\n throw new Error('Eval [(expr)] prevented in JSONPath expression.');\n }\n // As this will resolve to a property name (but we don't know it\n // yet), property and parent information is relative to the\n // parent of the property to which this expression will resolve\n addRet(this._trace(unshift(\n this._eval(\n loc, val, path[path.length - 1],\n path.slice(0, -1), parent, parentPropName\n ),\n x\n ), val, path, parent, parentPropName, callback, hasArrExpr));\n } else if (loc[0] === '@') { // value type: @boolean(), etc.\n let addType = false;\n const valueType = loc.slice(1, -2);\n switch (valueType) {\n case 'scalar':\n if (!val || !(['object', 'function'].includes(typeof val))) {\n addType = true;\n }\n break;\n case 'boolean': case 'string': case 'undefined': case 'function':\n // eslint-disable-next-line valid-typeof\n if (typeof val === valueType) {\n addType = true;\n }\n break;\n case 'integer':\n if (Number.isFinite(val) && !(val % 1)) {\n addType = true;\n }\n break;\n case 'number':\n if (Number.isFinite(val)) {\n addType = true;\n }\n break;\n case 'nonFinite':\n if (typeof val === 'number' && !Number.isFinite(val)) {\n addType = true;\n }\n break;\n case 'object':\n // eslint-disable-next-line valid-typeof\n if (val && typeof val === valueType) {\n addType = true;\n }\n break;\n case 'array':\n if (Array.isArray(val)) {\n addType = true;\n }\n break;\n case 'other':\n addType = this.currOtherTypeCallback(\n val, path, parent, parentPropName\n );\n break;\n case 'null':\n if (val === null) {\n addType = true;\n }\n break;\n /* c8 ignore next 2 */\n default:\n throw new TypeError('Unknown value type ' + valueType);\n }\n if (addType) {\n retObj = {path, value: val, parent, parentProperty: parentPropName};\n this._handleCallback(retObj, callback, 'value');\n return retObj;\n }\n // `-escaped property\n } else if (loc[0] === '`' && val && hasOwnProp.call(val, loc.slice(1))) {\n const locProp = loc.slice(1);\n addRet(this._trace(\n x, val[locProp], push(path, locProp), val, locProp, callback,\n hasArrExpr, true\n ));\n } else if (loc.includes(',')) { // [name1,name2,...]\n const parts = loc.split(',');\n for (const part of parts) {\n addRet(this._trace(\n unshift(part, x), val, path, parent, parentPropName, callback,\n true\n ));\n }\n // simple case--directly follow property\n } else if (\n !literalPriority && val && hasOwnProp.call(val, loc)\n ) {\n addRet(\n this._trace(x, val[loc], push(path, loc), val, loc, callback,\n hasArrExpr, true)\n );\n }\n\n // We check the resulting values for parent selections. For parent\n // selections we discard the value object and continue the trace with the\n // current val object\n if (this._hasParentSelector) {\n for (let t = 0; t < ret.length; t++) {\n const rett = ret[t];\n if (rett && rett.isParentSelector) {\n const tmp = this._trace(\n rett.expr, val, rett.path, parent, parentPropName, callback,\n hasArrExpr\n );\n if (Array.isArray(tmp)) {\n ret[t] = tmp[0];\n const tl = tmp.length;\n for (let tt = 1; tt < tl; tt++) {\n t++;\n ret.splice(t, 0, tmp[tt]);\n }\n } else {\n ret[t] = tmp;\n }\n }\n }\n }\n return ret;\n};\n\nJSONPath.prototype._walk = function (\n loc, expr, val, path, parent, parentPropName, callback, f\n) {\n if (Array.isArray(val)) {\n const n = val.length;\n for (let i = 0; i < n; i++) {\n f(i, loc, expr, val, path, parent, parentPropName, callback);\n }\n } else if (val && typeof val === 'object') {\n Object.keys(val).forEach((m) => {\n f(m, loc, expr, val, path, parent, parentPropName, callback);\n });\n }\n};\n\nJSONPath.prototype._slice = function (\n loc, expr, val, path, parent, parentPropName, callback\n) {\n if (!Array.isArray(val)) { return undefined; }\n const len = val.length, parts = loc.split(':'),\n step = (parts[2] && Number.parseInt(parts[2])) || 1;\n let start = (parts[0] && Number.parseInt(parts[0])) || 0,\n end = (parts[1] && Number.parseInt(parts[1])) || len;\n start = (start < 0) ? Math.max(0, start + len) : Math.min(len, start);\n end = (end < 0) ? Math.max(0, end + len) : Math.min(len, end);\n const ret = [];\n for (let i = start; i < end; i += step) {\n const tmp = this._trace(\n unshift(i, expr), val, path, parent, parentPropName, callback, true\n );\n // Should only be possible to be an array here since first part of\n // ``unshift(i, expr)` passed in above would not be empty, nor `~`,\n // nor begin with `@` (as could return objects)\n // This was causing excessive stack size in Node (with or\n // without Babel) against our performance test: `ret.push(...tmp);`\n tmp.forEach((t) => {\n ret.push(t);\n });\n }\n return ret;\n};\n\nJSONPath.prototype._eval = function (\n code, _v, _vname, path, parent, parentPropName\n) {\n if (code.includes('@parentProperty')) {\n this.currSandbox._$_parentProperty = parentPropName;\n code = code.replace(/@parentProperty/gu, '_$_parentProperty');\n }\n if (code.includes('@parent')) {\n this.currSandbox._$_parent = parent;\n code = code.replace(/@parent/gu, '_$_parent');\n }\n if (code.includes('@property')) {\n this.currSandbox._$_property = _vname;\n code = code.replace(/@property/gu, '_$_property');\n }\n if (code.includes('@path')) {\n this.currSandbox._$_path = JSONPath.toPathString(path.concat([_vname]));\n code = code.replace(/@path/gu, '_$_path');\n }\n if (code.includes('@root')) {\n this.currSandbox._$_root = this.json;\n code = code.replace(/@root/gu, '_$_root');\n }\n if ((/@([.\\s)[])/u).test(code)) {\n this.currSandbox._$_v = _v;\n code = code.replace(/@([.\\s)[])/gu, '_$_v$1');\n }\n try {\n return this.vm.runInNewContext(code, this.currSandbox);\n } catch (e) {\n // eslint-disable-next-line no-console\n console.log(e);\n throw new Error('jsonPath: ' + e.message + ': ' + code);\n }\n};\n\n// PUBLIC CLASS PROPERTIES AND METHODS\n\n// Could store the cache object itself\nJSONPath.cache = {};\n\n/**\n * @param {string[]} pathArr Array to convert\n * @returns {string} The path string\n */\nJSONPath.toPathString = function (pathArr) {\n const x = pathArr, n = x.length;\n let p = '$';\n for (let i = 1; i < n; i++) {\n if (!(/^(~|\\^|@.*?\\(\\))$/u).test(x[i])) {\n p += (/^[0-9*]+$/u).test(x[i]) ? ('[' + x[i] + ']') : (\"['\" + x[i] + \"']\");\n }\n }\n return p;\n};\n\n/**\n * @param {string} pointer JSON Path\n * @returns {string} JSON Pointer\n */\nJSONPath.toPointer = function (pointer) {\n const x = pointer, n = x.length;\n let p = '';\n for (let i = 1; i < n; i++) {\n if (!(/^(~|\\^|@.*?\\(\\))$/u).test(x[i])) {\n p += '/' + x[i].toString()\n .replace(/~/gu, '~0')\n .replace(/\\//gu, '~1');\n }\n }\n return p;\n};\n\n/**\n * @param {string} expr Expression to convert\n * @returns {string[]}\n */\nJSONPath.toPathArray = function (expr) {\n const {cache} = JSONPath;\n if (cache[expr]) { return cache[expr].concat(); }\n const subx = [];\n const normalized = expr\n // Properties\n .replace(\n /@(?:null|boolean|number|string|integer|undefined|nonFinite|scalar|array|object|function|other)\\(\\)/gu,\n ';$&;'\n )\n // Parenthetical evaluations (filtering and otherwise), directly\n // within brackets or single quotes\n .replace(/[['](\\??\\(.*?\\))[\\]']/gu, function ($0, $1) {\n return '[#' + (subx.push($1) - 1) + ']';\n })\n // Escape periods and tildes within properties\n .replace(/\\[['\"]([^'\\]]*)['\"]\\]/gu, function ($0, prop) {\n return \"['\" + prop\n .replace(/\\./gu, '%@%')\n .replace(/~/gu, '%%@@%%') +\n \"']\";\n })\n // Properties operator\n .replace(/~/gu, ';~;')\n // Split by property boundaries\n .replace(/['\"]?\\.['\"]?(?![^[]*\\])|\\[['\"]?/gu, ';')\n // Reinsert periods within properties\n .replace(/%@%/gu, '.')\n // Reinsert tildes within properties\n .replace(/%%@@%%/gu, '~')\n // Parent\n .replace(/(?:;)?(\\^+)(?:;)?/gu, function ($0, ups) {\n return ';' + ups.split('').join(';') + ';';\n })\n // Descendents\n .replace(/;;;|;;/gu, ';..;')\n // Remove trailing\n .replace(/;$|'?\\]|'$/gu, '');\n\n const exprList = normalized.split(';').map(function (exp) {\n const match = exp.match(/#(\\d+)/u);\n return !match || !match[1] ? exp : subx[match[1]];\n });\n cache[expr] = exprList;\n return cache[expr].concat();\n};\n\nexport {JSONPath};\n","import {JSONPath} from './jsonpath.js';\n\n/**\n* @callback ConditionCallback\n* @param {any} item\n* @returns {boolean}\n*/\n\n/**\n * Copy items out of one array into another.\n * @param {GenericArray} source Array with items to copy\n * @param {GenericArray} target Array to which to copy\n * @param {ConditionCallback} conditionCb Callback passed the current item;\n * will move item if evaluates to `true`\n * @returns {void}\n */\nconst moveToAnotherArray = function (source, target, conditionCb) {\n const il = source.length;\n for (let i = 0; i < il; i++) {\n const item = source[i];\n if (conditionCb(item)) {\n target.push(source.splice(i--, 1)[0]);\n }\n }\n};\n\nJSONPath.prototype.vm = {\n /**\n * @param {string} expr Expression to evaluate\n * @param {PlainObject} context Object whose items will be added\n * to evaluation\n * @returns {any} Result of evaluated code\n */\n runInNewContext (expr, context) {\n const keys = Object.keys(context);\n const funcs = [];\n moveToAnotherArray(keys, funcs, (key) => {\n return typeof context[key] === 'function';\n });\n const values = keys.map((vr, i) => {\n return context[vr];\n });\n\n const funcString = funcs.reduce((s, func) => {\n let fString = context[func].toString();\n if (!(/function/u).test(fString)) {\n fString = 'function ' + fString;\n }\n return 'var ' + func + '=' + fString + ';' + s;\n }, '');\n\n expr = funcString + expr;\n\n // Mitigate http://perfectionkills.com/global-eval-what-are-the-options/#new_function\n if (!(/(['\"])use strict\\1/u).test(expr) &&\n !keys.includes('arguments')\n ) {\n expr = 'var arguments = undefined;' + expr;\n }\n\n // Remove last semi so `return` will be inserted before\n // the previous one instead, allowing for the return\n // of a bare ending expression\n expr = expr.replace(/;\\s*$/u, '');\n\n // Insert `return`\n const lastStatementEnd = expr.lastIndexOf(';');\n const code = (lastStatementEnd > -1\n ? expr.slice(0, lastStatementEnd + 1) +\n ' return ' + expr.slice(lastStatementEnd + 1)\n : ' return ' + expr);\n\n // eslint-disable-next-line no-new-func\n return (new Function(...keys, code))(...values);\n }\n};\n\nexport {JSONPath};\n"],"names":["hasOwnProp","Object","prototype","hasOwnProperty","push","arr","item","slice","unshift","NewError","value","avoidNew","name","Error","JSONPath","opts","expr","obj","callback","otherTypeCallback","this","e","optObj","_typeof","json","path","resultType","flatten","wrap","call","sandbox","preventEval","parent","parentProperty","TypeError","autostart","args","ret","evaluate","currParent","currParentProperty","currResultType","currPreventEval","currSandbox","currOtherTypeCallback","Array","isArray","toPathString","exprList","toPathArray","length","shift","_hasParentSelector","result","_trace","filter","ea","isParentSelector","hasArrExpr","reduce","rslt","valOrPath","_this2","_getPreferredOutput","concat","undefined","pointer","toPointer","_handleCallback","fullRetObj","type","preferredOutput","val","parentPropName","literalPriority","retObj","loc","x","addRet","elems","forEach","t","_walk","m","l","_x","v","p","par","pr","cb","_this3","test","_slice","indexOf","_eval","replace","addType","valueType","includes","Number","isFinite","locProp","split","part","rett","tmp","tl","tt","splice","f","n","i","keys","len","parts","step","parseInt","start","end","Math","max","min","code","_v","_vname","_$_parentProperty","_$_parent","_$_property","_$_path","_$_root","_$_v","vm","runInNewContext","console","log","message","cache","pathArr","toString","subx","$0","$1","prop","ups","join","map","exp","match","context","funcs","source","target","conditionCb","il","moveToAnotherArray","key","values","vr","funcString","s","func","fString","lastStatementEnd","lastIndexOf","_construct","Function"],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OAAOG,IAAK,GAAG,IAetC2C,CAAmB1C,EAAMqC,GAAO,SAACM,SACE,mBAAjBP,EAAQO,UAEpBC,EAAS5C,EAAKiC,KAAI,SAACY,EAAI9C,UAClBqC,EAAQS,MAGbC,EAAaT,EAAM3F,QAAO,SAACqG,EAAGC,OAC5BC,EAAUb,EAAQY,GAAMtB,iBACtB,WAAa/C,KAAKsE,KACpBA,EAAU,YAAcA,GAErB,OAASD,EAAO,IAAMC,EAAU,IAAMF,IAC9C,IAKG,qBAAuBpE,KAH7B5E,EAAO+I,EAAa/I,IAIfiG,EAAKd,SAAS,eAEfnF,EAAO,6BAA+BA,OASpCmJ,GAHNnJ,EAAOA,EAAKgF,QAAQ,yEAAU,KAGAoE,YAAY,KACpCzC,EAAQwC,GAAoB,EAC5BnJ,EAAKT,MAAM,EAAG4J,EAAmB,GAC/B,WAAanJ,EAAKT,MAAM4J,EAAmB,GAC7C,WAAanJ,SAGZqJ,EAAKC,WAAYrD,WAAMU,oBAAUkC"} \ No newline at end of file diff --git a/dist/index-node-cjs.js b/dist/index-node-cjs.cjs similarity index 100% rename from dist/index-node-cjs.js rename to dist/index-node-cjs.cjs diff --git a/dist/index-node-esm.mjs b/dist/index-node-esm.js similarity index 100% rename from dist/index-node-esm.mjs rename to dist/index-node-esm.js diff --git a/package.json b/package.json index f31fd9d..761a2a7 100644 --- a/package.json +++ b/package.json @@ -8,9 +8,9 @@ "./package.json": "./package.json", ".": { "browser": "./dist/index-browser-esm.js", - "umd": "./dist/index-browser-umd.js", - "import": "./dist/index-node-esm.mjs", - "require": "./dist/index-node-cjs.js", + "umd": "./dist/index-browser-umd.cjs", + "import": "./dist/index-node-esm.js", + "require": "./dist/index-node-cjs.cjs", "default": "./dist/index-browser-esm.js" } }, diff --git a/rollup.config.js b/rollup.config.js index bff11a5..67946e3 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -32,7 +32,7 @@ function getRollupObject ({ file: `dist/index${environment ? `-${environment}` : ''}-${ format }${minifying ? '.min' : ''}.${ - environment === 'node' && format === 'esm' ? 'm' : '' + format === 'esm' ? '' : 'c' }js`, name: 'JSONPath' },