Skip to content

Commit 799e448

Browse files
committed
chore: update devDeps.; linting
1 parent 8c5173a commit 799e448

19 files changed

Lines changed: 1471 additions & 1752 deletions

‎badges/coverage-badge.svg‎

Lines changed: 1 addition & 1 deletion
Loading

‎badges/licenses-badge-dev.svg‎

Lines changed: 1 addition & 1 deletion
Loading

‎badges/licenses-badge.svg‎

Lines changed: 1 addition & 1 deletion
Loading

‎badges/tests-badge.svg‎

Lines changed: 1 addition & 1 deletion
Loading

‎demo/index.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ const updateResults = () => {
8686
path: jsonpathEl.value,
8787
json,
8888
eval: /** @type {'safe'|'native'|boolean} */ (
89-
$i('#eval').value === 'false' ? false : $i('#eval').value
89+
($i('#eval').value !== 'false') && $i('#eval').value
9090
),
9191
ignoreEvalErrors: $i('#ignoreEvalErrors').value === 'true'
9292
});

‎dist/index-browser-esm.js‎

Lines changed: 42 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1372,10 +1372,7 @@ const SafeEval = {
13721372
* @returns {UnknownResult}
13731373
*/
13741374
evalConditionalExpression(ast, subs) {
1375-
if (SafeEval.evalAst(ast.test, subs)) {
1376-
return SafeEval.evalAst(ast.consequent, subs);
1377-
}
1378-
return SafeEval.evalAst(ast.alternate, subs);
1375+
return SafeEval.evalAst(ast.test, subs) ? SafeEval.evalAst(ast.consequent, subs) : SafeEval.evalAst(ast.alternate, subs);
13791376
},
13801377
/**
13811378
* @param {jsep.Identifier} ast
@@ -1810,11 +1807,11 @@ class JSONPathClass {
18101807
this.json = opts.json || obj;
18111808
this.path = opts.path || expr;
18121809
this.resultType = opts.resultType || 'value';
1813-
this.flatten = Object.hasOwn(opts, 'flatten') ? opts.flatten : false;
1814-
this.wrap = Object.hasOwn(opts, 'wrap') ? opts.wrap : true;
1810+
this.flatten = Object.hasOwn(opts, 'flatten') && opts.flatten;
1811+
this.wrap = !Object.hasOwn(opts, 'wrap') || opts.wrap;
18151812
this.sandbox = opts.sandbox || {};
18161813
this.eval = opts.eval === undefined ? 'safe' : opts.eval;
1817-
this.ignoreEvalErrors = typeof opts.ignoreEvalErrors === 'undefined' ? false : opts.ignoreEvalErrors;
1814+
this.ignoreEvalErrors = typeof opts.ignoreEvalErrors !== 'undefined' && opts.ignoreEvalErrors;
18181815
this.parent = Object.hasOwn(opts, 'parent') ? opts.parent : null;
18191816
this.parentProperty = Object.hasOwn(opts, 'parentProperty') ? opts.parentProperty : null;
18201817
this.callback = opts.callback || (/** @type {JSONPathCallback} */
@@ -1823,28 +1820,29 @@ class JSONPathClass {
18231820
throw new TypeError('You must supply an otherTypeCallback callback option ' + 'with the @other() operator.');
18241821
};
18251822
this.customTypes = opts.customTypes || {};
1826-
if (opts.autostart !== false) {
1827-
const args = /** @type {JSONPathOptions} */{
1828-
path: optObj ? opts.path : expr
1829-
};
1830-
if (!optObj && obj !== undefined) {
1831-
args.json = obj;
1832-
} else if ('json' in opts) {
1833-
args.json = opts.json;
1834-
}
1835-
const ret = this.evaluate(args);
1836-
if (!ret || typeof ret !== 'object') {
1837-
const err = /** @type {Error & {value: UnknownResult}} */
1838-
new Error('JSONPath should not be called with "new" (it ' + 'prevents return of (unwrapped) scalar values)');
1839-
err.value = ret;
1840-
throw err;
1841-
}
1842-
1843-
// eslint-disable-next-line @stylistic/max-len -- Long
1844-
// @ts-expect-error - Constructor returns evaluate result for legacy API
1845-
// eslint-disable-next-line no-constructor-return -- Legacy API
1846-
return ret;
1823+
if (opts.autostart === false) {
1824+
return;
1825+
}
1826+
const args = /** @type {JSONPathOptions} */{
1827+
path: optObj ? opts.path : expr
1828+
};
1829+
if (!optObj && obj !== undefined) {
1830+
args.json = obj;
1831+
} else if ('json' in opts) {
1832+
args.json = opts.json;
18471833
}
1834+
const ret = this.evaluate(args);
1835+
if (!ret || typeof ret !== 'object') {
1836+
const err = /** @type {Error & {value: UnknownResult}} */
1837+
new Error('JSONPath should not be called with "new" (it ' + 'prevents return of (unwrapped) scalar values)');
1838+
err.value = ret;
1839+
throw err;
1840+
}
1841+
1842+
// @ts-expect-error - Constructor returns evaluate result for legacy API
1843+
// eslint-disable-next-line @stylistic/max-len -- Long
1844+
// eslint-disable-next-line consistent-return, no-constructor-return -- Legacy API
1845+
return ret;
18481846
}
18491847

18501848
// PUBLIC METHODS
@@ -2211,7 +2209,6 @@ class JSONPathClass {
22112209
addType = true;
22122210
}
22132211
break;
2214-
/* c8 ignore next 2 */
22152212
default:
22162213
if (this.currCustomTypes && Object.hasOwn(this.currCustomTypes, valueType)) {
22172214
addType = this.currCustomTypes[valueType](val, path, parent, parentPropName) || false;
@@ -2252,22 +2249,23 @@ class JSONPathClass {
22522249
if (this._hasParentSelector) {
22532250
for (let t = 0; t < ret.length; t++) {
22542251
const rett = ret[t];
2255-
if (rett && rett.isParentSelector) {
2256-
const exprToUse = /** @type {ExpressionArray} */
2257-
rett.expr;
2258-
const pathToUse = /** @type {ExpressionArray} */
2259-
rett.path;
2260-
const tmp = this._trace(exprToUse, val, pathToUse, parent, parentPropName, callback, hasArrExpr);
2261-
if (Array.isArray(tmp)) {
2262-
ret[t] = tmp[0];
2263-
const tl = tmp.length;
2264-
for (let tt = 1; tt < tl; tt++) {
2265-
t++;
2266-
ret.splice(t, 0, tmp[tt]);
2267-
}
2268-
} else {
2269-
ret[t] = tmp;
2252+
if (!rett || !rett.isParentSelector) {
2253+
continue;
2254+
}
2255+
const exprToUse = /** @type {ExpressionArray} */
2256+
rett.expr;
2257+
const pathToUse = /** @type {ExpressionArray} */
2258+
rett.path;
2259+
const tmp = this._trace(exprToUse, val, pathToUse, parent, parentPropName, callback, hasArrExpr);
2260+
if (Array.isArray(tmp)) {
2261+
ret[t] = tmp[0];
2262+
const tl = tmp.length;
2263+
for (let tt = 1; tt < tl; tt++) {
2264+
t++;
2265+
ret.splice(t, 0, tmp[tt]);
22702266
}
2267+
} else {
2268+
ret[t] = tmp;
22712269
}
22722270
}
22732271
}

‎dist/index-browser-esm.min.js‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎dist/index-browser-esm.min.js.map‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)