jsonpath-plus
Advanced tools
Comparing version 0.19.0 to 0.20.0
@@ -1,3 +0,14 @@ | ||
# jsonpath-plus changes | ||
# CHANGES for jsonpath-plus | ||
## 0.20.0 (June 4, 2019) | ||
- Build: Add `browserslist` for Babel builds | ||
- Linting: Conform to ESLint updates (jsdoc) | ||
- Testing: Switch from end-of-lifed nodeunit to Mocha | ||
- Testing: Add performance test to browser, but bump duration | ||
- npm: Update devDeps; add core-js-bundle to peerDependencies | ||
- npm: Ignore some unneeded files | ||
- Bump Node version in Travis to avoid erring with object rest | ||
in eslint-plugin-node routine | ||
## 0.19.0 (May 16, 2019) | ||
@@ -4,0 +15,0 @@ |
@@ -136,3 +136,4 @@ function _typeof(obj) { | ||
/* eslint-disable no-eval */ | ||
/* eslint-disable no-eval, jsdoc/check-types */ | ||
// Todo: Reenable jsdoc/check-types once PR merged: https://github.com/gajus/eslint-plugin-jsdoc/pull/270 | ||
var globalEval = eval; // eslint-disable-next-line import/no-commonjs | ||
@@ -144,6 +145,16 @@ | ||
/** | ||
* @typedef {null|boolean|number|string|PlainObject|GenericArray} JSONObject | ||
*/ | ||
/** | ||
* @callback ConditionCallback | ||
* @param item | ||
* @returns {boolean} | ||
*/ | ||
/** | ||
* Copy items out of one array into another. | ||
* @param {Array} source Array with items to copy | ||
* @param {Array} target Array to which to copy | ||
* @param {Function} conditionCb Callback passed the current item; will move | ||
* @param {ConditionCallback} conditionCb Callback passed the current item; will move | ||
* item if evaluates to `true` | ||
@@ -168,4 +179,4 @@ * @returns {undefined} | ||
* @param {string} expr Expression to evaluate | ||
* @param {Object} context Object whose items will be added to evaluation | ||
* @returns {*} Result of evaluated code | ||
* @param {PlainObject} context Object whose items will be added to evaluation | ||
* @returns {Any} Result of evaluated code | ||
*/ | ||
@@ -198,3 +209,3 @@ runInNewContext: function runInNewContext(expr, context) { | ||
* @param {Array} arr Array to copy and into which to push | ||
* @param {*} item Array item to add (to end) | ||
* @param {Any} item Array item to add (to end) | ||
* @returns {Array} Copy of the original array | ||
@@ -210,3 +221,3 @@ */ | ||
* Copies array and then unshifts item into it. | ||
* @param {*} item Array item to add (to beginning) | ||
* @param {Any} item Array item to add (to beginning) | ||
* @param {Array} arr Array to copy and into which to unshift | ||
@@ -234,3 +245,3 @@ * @returns {Array} Copy of the original array | ||
/** | ||
* @param {*} value The evaluated scalar value | ||
* @param {Any} value The evaluated scalar value | ||
*/ | ||
@@ -252,8 +263,31 @@ function NewError(value) { | ||
/** | ||
* @param {Object} [opts] If present, must be an object | ||
* @typedef {PlainObject} ReturnObject | ||
* @property {string} path | ||
* @property {JSONObject} value | ||
* @property {PlainObject|GenericArray} parent | ||
* @property {string} parentProperty | ||
*/ | ||
/** | ||
* @callback JSONPathCallback | ||
* @param {string|PlainObject} preferredOutput | ||
* @param {"value"|"property"} type | ||
* @param {ReturnObject} fullRetObj | ||
*/ | ||
/** | ||
* @callback OtherTypeCallback | ||
* @param {JSONObject} val | ||
* @param {string} path | ||
* @param {PlainObject|GenericArray} parent | ||
* @param {string} parentPropName | ||
*/ | ||
/** | ||
* @param {PlainObject} [opts] If present, must be an object | ||
* @param {string} expr JSON path to evaluate | ||
* @param {JSON} obj JSON object to evaluate against | ||
* @param {Function} callback Passed 3 arguments: 1) desired payload per `resultType`, | ||
* @param {JSONPathCallback} callback Passed 3 arguments: 1) desired payload per `resultType`, | ||
* 2) `"value"|"property"`, 3) Full returned object with all payloads | ||
* @param {Function} otherTypeCallback If `@other()` is at the end of one's query, this | ||
* @param {OtherTypeCallback} otherTypeCallback If `@other()` is at the end of one's query, this | ||
* will be invoked with the value of the item, its path, its parent, and its parent's | ||
@@ -433,3 +467,15 @@ * property name, and it should return a boolean indicating whether the supplied value | ||
}; | ||
/** | ||
* | ||
* @param {string} expr | ||
* @param {JSONObject} val | ||
* @param {string} path | ||
* @param {PlainObject|GenericArray} parent | ||
* @param {string} parentPropName | ||
* @param {JSONPathCallback} callback | ||
* @param {boolean} literalPriority | ||
* @returns {ReturnObject|ReturnObject[]} | ||
*/ | ||
JSONPath.prototype._trace = function (expr, val, path, parent, parentPropName, callback, literalPriority) { | ||
@@ -458,2 +504,7 @@ // No expr to follow? return path and value as the result of this trace branch | ||
var ret = []; | ||
/** | ||
* | ||
* @param {ReturnObject|ReturnObject[]} elems | ||
* @returns {void} | ||
*/ | ||
@@ -667,3 +718,2 @@ function addRet(elems) { | ||
if (this._hasParentSelector) { | ||
// eslint-disable-next-line unicorn/no-for-loop | ||
for (var t = 0; t < ret.length; t++) { | ||
@@ -670,0 +720,0 @@ var rett = ret[t]; |
@@ -142,3 +142,4 @@ (function (global, factory) { | ||
/* eslint-disable no-eval */ | ||
/* eslint-disable no-eval, jsdoc/check-types */ | ||
// Todo: Reenable jsdoc/check-types once PR merged: https://github.com/gajus/eslint-plugin-jsdoc/pull/270 | ||
var globalEval = eval; // eslint-disable-next-line import/no-commonjs | ||
@@ -150,6 +151,16 @@ | ||
/** | ||
* @typedef {null|boolean|number|string|PlainObject|GenericArray} JSONObject | ||
*/ | ||
/** | ||
* @callback ConditionCallback | ||
* @param item | ||
* @returns {boolean} | ||
*/ | ||
/** | ||
* Copy items out of one array into another. | ||
* @param {Array} source Array with items to copy | ||
* @param {Array} target Array to which to copy | ||
* @param {Function} conditionCb Callback passed the current item; will move | ||
* @param {ConditionCallback} conditionCb Callback passed the current item; will move | ||
* item if evaluates to `true` | ||
@@ -174,4 +185,4 @@ * @returns {undefined} | ||
* @param {string} expr Expression to evaluate | ||
* @param {Object} context Object whose items will be added to evaluation | ||
* @returns {*} Result of evaluated code | ||
* @param {PlainObject} context Object whose items will be added to evaluation | ||
* @returns {Any} Result of evaluated code | ||
*/ | ||
@@ -204,3 +215,3 @@ runInNewContext: function runInNewContext(expr, context) { | ||
* @param {Array} arr Array to copy and into which to push | ||
* @param {*} item Array item to add (to end) | ||
* @param {Any} item Array item to add (to end) | ||
* @returns {Array} Copy of the original array | ||
@@ -216,3 +227,3 @@ */ | ||
* Copies array and then unshifts item into it. | ||
* @param {*} item Array item to add (to beginning) | ||
* @param {Any} item Array item to add (to beginning) | ||
* @param {Array} arr Array to copy and into which to unshift | ||
@@ -240,3 +251,3 @@ * @returns {Array} Copy of the original array | ||
/** | ||
* @param {*} value The evaluated scalar value | ||
* @param {Any} value The evaluated scalar value | ||
*/ | ||
@@ -258,8 +269,31 @@ function NewError(value) { | ||
/** | ||
* @param {Object} [opts] If present, must be an object | ||
* @typedef {PlainObject} ReturnObject | ||
* @property {string} path | ||
* @property {JSONObject} value | ||
* @property {PlainObject|GenericArray} parent | ||
* @property {string} parentProperty | ||
*/ | ||
/** | ||
* @callback JSONPathCallback | ||
* @param {string|PlainObject} preferredOutput | ||
* @param {"value"|"property"} type | ||
* @param {ReturnObject} fullRetObj | ||
*/ | ||
/** | ||
* @callback OtherTypeCallback | ||
* @param {JSONObject} val | ||
* @param {string} path | ||
* @param {PlainObject|GenericArray} parent | ||
* @param {string} parentPropName | ||
*/ | ||
/** | ||
* @param {PlainObject} [opts] If present, must be an object | ||
* @param {string} expr JSON path to evaluate | ||
* @param {JSON} obj JSON object to evaluate against | ||
* @param {Function} callback Passed 3 arguments: 1) desired payload per `resultType`, | ||
* @param {JSONPathCallback} callback Passed 3 arguments: 1) desired payload per `resultType`, | ||
* 2) `"value"|"property"`, 3) Full returned object with all payloads | ||
* @param {Function} otherTypeCallback If `@other()` is at the end of one's query, this | ||
* @param {OtherTypeCallback} otherTypeCallback If `@other()` is at the end of one's query, this | ||
* will be invoked with the value of the item, its path, its parent, and its parent's | ||
@@ -439,3 +473,15 @@ * property name, and it should return a boolean indicating whether the supplied value | ||
}; | ||
/** | ||
* | ||
* @param {string} expr | ||
* @param {JSONObject} val | ||
* @param {string} path | ||
* @param {PlainObject|GenericArray} parent | ||
* @param {string} parentPropName | ||
* @param {JSONPathCallback} callback | ||
* @param {boolean} literalPriority | ||
* @returns {ReturnObject|ReturnObject[]} | ||
*/ | ||
JSONPath.prototype._trace = function (expr, val, path, parent, parentPropName, callback, literalPriority) { | ||
@@ -464,2 +510,7 @@ // No expr to follow? return path and value as the result of this trace branch | ||
var ret = []; | ||
/** | ||
* | ||
* @param {ReturnObject|ReturnObject[]} elems | ||
* @returns {void} | ||
*/ | ||
@@ -673,3 +724,2 @@ function addRet(elems) { | ||
if (this._hasParentSelector) { | ||
// eslint-disable-next-line unicorn/no-for-loop | ||
for (var t = 0; t < ret.length; t++) { | ||
@@ -676,0 +726,0 @@ var rett = ret[t]; |
{ | ||
"author": "Stefan Goessner", | ||
"name": "jsonpath-plus", | ||
"version": "0.19.0", | ||
"version": "0.20.0", | ||
"main": "dist/index-umd.js", | ||
@@ -47,22 +47,27 @@ "module": "dist/index-es.js", | ||
}, | ||
"peerDependencies": { | ||
"core-js-bundle": "^3.1.3" | ||
}, | ||
"dependencies": {}, | ||
"devDependencies": { | ||
"@babel/core": "^7.4.4", | ||
"@babel/preset-env": "^7.4.4", | ||
"@babel/core": "^7.4.5", | ||
"@babel/preset-env": "^7.4.5", | ||
"@mysticatea/eslint-plugin": "^10.0.3", | ||
"chai": "^4.2.0", | ||
"core-js-bundle": "^3.1.3", | ||
"eslint": "^5.16.0", | ||
"eslint-config-ash-nazg": "^4.0.0", | ||
"eslint-config-ash-nazg": "^6.1.1", | ||
"eslint-config-standard": "^12.0.0", | ||
"eslint-plugin-compat": "^3.1.1", | ||
"eslint-plugin-eslint-comments": "^3.1.1", | ||
"eslint-plugin-import": "^2.17.2", | ||
"eslint-plugin-jsdoc": "^5.0.2", | ||
"eslint-plugin-import": "^2.17.3", | ||
"eslint-plugin-jsdoc": "^7.2.3", | ||
"eslint-plugin-markdown": "^1.0.0", | ||
"eslint-plugin-no-use-extend-native": "^0.4.0", | ||
"eslint-plugin-node": "^9.0.1", | ||
"eslint-plugin-node": "^9.1.0", | ||
"eslint-plugin-promise": "^4.1.1", | ||
"eslint-plugin-standard": "^4.0.0", | ||
"eslint-plugin-unicorn": "^8.0.2", | ||
"eslint-plugin-unicorn": "^9.0.0", | ||
"mocha": "^6.1.4", | ||
"node-static": "^0.7.11", | ||
"nodeunit": "0.11.3", | ||
"open-cli": "^5.0.0", | ||
@@ -72,6 +77,6 @@ "remark-cli": "^6.0.1", | ||
"remark-lint-ordered-list-marker-value": "^1.0.2", | ||
"rollup": "1.12.1", | ||
"rollup": "1.13.1", | ||
"rollup-plugin-babel": "^4.3.2", | ||
"rollup-plugin-terser": "^4.0.4", | ||
"typescript": "^3.4.5" | ||
"rollup-plugin-terser": "^5.0.0", | ||
"typescript": "^3.5.1" | ||
}, | ||
@@ -82,2 +87,5 @@ "keywords": [ | ||
], | ||
"browserslist": [ | ||
"cover 100%" | ||
], | ||
"scripts": { | ||
@@ -87,4 +95,4 @@ "remark": "remark -q -f .", | ||
"eslint": "eslint --ext js,md .", | ||
"nodeunit": "nodeunit test", | ||
"test": "npm run eslint && npm run rollup && npm run nodeunit", | ||
"mocha": "mocha --require test-helpers/node-env.js test", | ||
"test": "npm run eslint && npm run rollup && npm run mocha", | ||
"browser-test": "npm run eslint && npm run rollup && open-cli http://localhost:8084/test/ && static -p 8084", | ||
@@ -91,0 +99,0 @@ "start": "npm run browser-test" |
@@ -13,5 +13,2 @@ # JSONPath Plus [![build status](https://secure.travis-ci.org/s3u/JSONPath.png)](http://travis-ci.org/s3u/JSONPath) | ||
* **Compliant** with the original jsonpath spec | ||
* Consistently **performant** per | ||
[json-querying-performance-testing](https://github.com/andykais/json-querying-performance-testing>) | ||
benchmarking, particularly for large data sets. | ||
* Convenient **additions or elaborations** not provided in the original spec: | ||
@@ -43,2 +40,5 @@ * `^` for grabbing the **parent** of a matching item | ||
## Benchmarking | ||
`jsonpath-plus` is consistently performant with both large and small datasets compared to other json querying libraries per [json-querying-performance-testing](https://github.com/andykais/json-querying-performance-testing). You can verify these findings by [running the project yourself](https://github.com/andykais/json-querying-performance-testing#how-to-run) and adding more perf cases. | ||
## Install | ||
@@ -45,0 +45,0 @@ |
@@ -1,3 +0,4 @@ | ||
/* eslint-disable no-eval */ | ||
/* eslint-disable no-eval, jsdoc/check-types */ | ||
// Todo: Reenable jsdoc/check-types once PR merged: https://github.com/gajus/eslint-plugin-jsdoc/pull/270 | ||
const globalEval = eval; | ||
@@ -11,6 +12,16 @@ // eslint-disable-next-line import/no-commonjs | ||
/** | ||
* @typedef {null|boolean|number|string|PlainObject|GenericArray} JSONObject | ||
*/ | ||
/** | ||
* @callback ConditionCallback | ||
* @param item | ||
* @returns {boolean} | ||
*/ | ||
/** | ||
* Copy items out of one array into another. | ||
* @param {Array} source Array with items to copy | ||
* @param {Array} target Array to which to copy | ||
* @param {Function} conditionCb Callback passed the current item; will move | ||
* @param {ConditionCallback} conditionCb Callback passed the current item; will move | ||
* item if evaluates to `true` | ||
@@ -34,4 +45,4 @@ * @returns {undefined} | ||
* @param {string} expr Expression to evaluate | ||
* @param {Object} context Object whose items will be added to evaluation | ||
* @returns {*} Result of evaluated code | ||
* @param {PlainObject} context Object whose items will be added to evaluation | ||
* @returns {Any} Result of evaluated code | ||
*/ | ||
@@ -65,3 +76,3 @@ runInNewContext (expr, context) { | ||
* @param {Array} arr Array to copy and into which to push | ||
* @param {*} item Array item to add (to end) | ||
* @param {Any} item Array item to add (to end) | ||
* @returns {Array} Copy of the original array | ||
@@ -76,3 +87,3 @@ */ | ||
* Copies array and then unshifts item into it. | ||
* @param {*} item Array item to add (to beginning) | ||
* @param {Any} item Array item to add (to beginning) | ||
* @param {Array} arr Array to copy and into which to unshift | ||
@@ -93,3 +104,3 @@ * @returns {Array} Copy of the original array | ||
/** | ||
* @param {*} value The evaluated scalar value | ||
* @param {Any} value The evaluated scalar value | ||
*/ | ||
@@ -105,8 +116,31 @@ constructor (value) { | ||
/** | ||
* @param {Object} [opts] If present, must be an object | ||
* @typedef {PlainObject} ReturnObject | ||
* @property {string} path | ||
* @property {JSONObject} value | ||
* @property {PlainObject|GenericArray} parent | ||
* @property {string} parentProperty | ||
*/ | ||
/** | ||
* @callback JSONPathCallback | ||
* @param {string|PlainObject} preferredOutput | ||
* @param {"value"|"property"} type | ||
* @param {ReturnObject} fullRetObj | ||
*/ | ||
/** | ||
* @callback OtherTypeCallback | ||
* @param {JSONObject} val | ||
* @param {string} path | ||
* @param {PlainObject|GenericArray} parent | ||
* @param {string} parentPropName | ||
*/ | ||
/** | ||
* @param {PlainObject} [opts] If present, must be an object | ||
* @param {string} expr JSON path to evaluate | ||
* @param {JSON} obj JSON object to evaluate against | ||
* @param {Function} callback Passed 3 arguments: 1) desired payload per `resultType`, | ||
* @param {JSONPathCallback} callback Passed 3 arguments: 1) desired payload per `resultType`, | ||
* 2) `"value"|"property"`, 3) Full returned object with all payloads | ||
* @param {Function} otherTypeCallback If `@other()` is at the end of one's query, this | ||
* @param {OtherTypeCallback} otherTypeCallback If `@other()` is at the end of one's query, this | ||
* will be invoked with the value of the item, its path, its parent, and its parent's | ||
@@ -261,2 +295,13 @@ * property name, and it should return a boolean indicating whether the supplied value | ||
/** | ||
* | ||
* @param {string} expr | ||
* @param {JSONObject} val | ||
* @param {string} path | ||
* @param {PlainObject|GenericArray} parent | ||
* @param {string} parentPropName | ||
* @param {JSONPathCallback} callback | ||
* @param {boolean} literalPriority | ||
* @returns {ReturnObject|ReturnObject[]} | ||
*/ | ||
JSONPath.prototype._trace = function ( | ||
@@ -279,2 +324,7 @@ expr, val, path, parent, parentPropName, callback, literalPriority | ||
const ret = []; | ||
/** | ||
* | ||
* @param {ReturnObject|ReturnObject[]} elems | ||
* @returns {void} | ||
*/ | ||
function addRet (elems) { | ||
@@ -419,3 +469,2 @@ if (Array.isArray(elems)) { | ||
if (this._hasParentSelector) { | ||
// eslint-disable-next-line unicorn/no-for-loop | ||
for (let t = 0; t < ret.length; t++) { | ||
@@ -422,0 +471,0 @@ const rett = ret[t]; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
202803
2254
1
28
13