Skip to content

Commit 8ede5d9

Browse files
committed
chore: bump engines and browserslist and use v flag
BREAKING CHANGE: Require Node >= 22; drops older browser version support
1 parent fe892fc commit 8ede5d9

15 files changed

Lines changed: 906 additions & 983 deletions

‎dist/index-browser-esm.js‎

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2110,7 +2110,7 @@ class JSONPathClass {
21102110
} else if (loc === '$') {
21112111
// root only
21122112
addRet(this._trace(x, val, path, null, null, callback, hasArrExpr));
2113-
} else if (/^(-?\d*):(-?\d*):?(\d*)$/u.test(loc)) {
2113+
} else if (/^(-?\d*):(-?\d*):?(\d*)$/v.test(loc)) {
21142114
// [start:end:step] Python slice syntax
21152115
const sliceResult = this._slice(loc, x, val, path, parent, parentPropName, callback);
21162116
if (sliceResult) {
@@ -2121,10 +2121,10 @@ class JSONPathClass {
21212121
if (this.currEval === false) {
21222122
throw new Error('Eval [?(expr)] prevented in JSONPath expression.');
21232123
}
2124-
const safeLoc = loc.replace(/^\?\((.*?)\)$/u, '$1');
2124+
const safeLoc = loc.replace(/^\?\((.*?)\)$/v, '$1');
21252125
// check for a nested filter expression
21262126

2127-
const nested = /@.?([^?]*)[['](\??\(.*?\))(?!.\)\])[\]']/gu.exec(safeLoc);
2127+
const nested = /@.?([^?]*)[\['](\??\(.*?\))(?!.\)\])[\]']/gv.exec(safeLoc);
21282128
if (nested) {
21292129
// find if there are matches in the nested expression
21302130
// add them to the result set if there is at least one match
@@ -2358,7 +2358,7 @@ class JSONPathClass {
23582358
}
23592359
const scriptCacheKey = this.currEval + 'Script:' + code;
23602360
if (!scriptCache.has(scriptCacheKey)) {
2361-
let script = code.replaceAll('@parentProperty', '_$_parentProperty').replaceAll('@parent', '_$_parent').replaceAll('@property', '_$_property').replaceAll('@root', '_$_root').replaceAll(/@([.\s)[])/gu, '_$_v$1');
2361+
let script = code.replaceAll('@parentProperty', '_$_parentProperty').replaceAll('@parent', '_$_parent').replaceAll('@property', '_$_property').replaceAll('@root', '_$_root').replaceAll(/@([.\s\)\[])/gv, '_$_v$1');
23622362
if (containsPath) {
23632363
script = script.replaceAll('@path', '_$_path');
23642364
}
@@ -2454,8 +2454,8 @@ JSONPath.toPathString = function (pathArr) {
24542454
n = x.length;
24552455
let p = '$';
24562456
for (let i = 1; i < n; i++) {
2457-
if (!/^(~|\^|@.*?\(\))$/u.test(x[i])) {
2458-
p += /^[0-9*]+$/u.test(x[i]) ? '[' + x[i] + ']' : "['" + x[i] + "']";
2457+
if (!/^(~|\^|@.*?\(\))$/v.test(x[i])) {
2458+
p += /^[0-9*]+$/v.test(x[i]) ? '[' + x[i] + ']' : "['" + x[i] + "']";
24592459
}
24602460
}
24612461
return p;
@@ -2470,7 +2470,7 @@ JSONPath.toPointer = function (pointer) {
24702470
n = x.length;
24712471
let p = '';
24722472
for (let i = 1; i < n; i++) {
2473-
if (!/^(~|\^|@.*?\(\))$/u.test(x[i])) {
2473+
if (!/^(~|\^|@.*?\(\))$/v.test(x[i])) {
24742474
p += '/' + x[i].toString().replaceAll('~', '~0').replaceAll('/', '~1');
24752475
}
24762476
}
@@ -2489,37 +2489,37 @@ JSONPath.toPathArray = function (expr) {
24892489
const subx = [];
24902490
const normalized = expr
24912491
// Properties
2492-
.replaceAll(/@[\w$-]+\(\)/gu, ';$&;')
2492+
.replaceAll(/@[\w$\-]+\(\)/gv, ';$&;')
24932493
// Parenthetical evaluations (filtering and otherwise), directly
24942494
// within brackets or single quotes
2495-
.replaceAll(/[['](\??\(.*?\))[\]'](?!.\])/gu, function ($0, $1) {
2495+
.replaceAll(/[\['](\??\(.*?\))[\]'](?!.\])/gv, function ($0, $1) {
24962496
return '[#' + (
24972497
// eslint-disable-next-line @stylistic/max-len -- Long
24982498
// eslint-disable-next-line unicorn/no-return-array-push -- Optimization
24992499
subx.push($1) - 1) + ']';
25002500
})
25012501
// Escape periods and tildes within properties
2502-
.replaceAll(/\[['"]([^'\]]*)['"]\]/gu, function ($0, prop) {
2502+
.replaceAll(/\[['"]([^'\]]*)['"]\]/gv, function ($0, prop) {
25032503
return "['" + prop.replaceAll('.', '%@%').replaceAll('~', '%%@@%%') + "']";
25042504
})
25052505
// Properties operator
25062506
.replaceAll('~', ';~;')
25072507
// Split by property boundaries
2508-
.replaceAll(/['"]?\.['"]?(?![^[]*\])|\[['"]?/gu, ';')
2508+
.replaceAll(/['"]?\.['"]?(?![^\[]*\])|\[['"]?/gv, ';')
25092509
// Reinsert periods within properties
25102510
.replaceAll('%@%', '.')
25112511
// Reinsert tildes within properties
25122512
.replaceAll('%%@@%%', '~')
25132513
// Parent
2514-
.replaceAll(/(?:;)?(\^+)(?:;)?/gu, function ($0, ups) {
2514+
.replaceAll(/(?:;)?(\^+)(?:;)?/gv, function ($0, ups) {
25152515
return ';' + ups.split('').join(';') + ';';
25162516
})
25172517
// Descendents
2518-
.replaceAll(/;;;|;;/gu, ';..;')
2518+
.replaceAll(/;;;|;;/gv, ';..;')
25192519
// Remove trailing
2520-
.replaceAll(/;$|'?\]|'$/gu, '');
2520+
.replaceAll(/;$|'?\]|'$/gv, '');
25212521
const exprList = normalized.split(';').map(function (exp) {
2522-
const match = exp.match(/#(\d+)/u);
2522+
const match = exp.match(/#(\d+)/v);
25232523
return !match || !match[1] ? exp : subx[Number(match[1])];
25242524
});
25252525
pathCache.set(expr, exprList);
@@ -2650,22 +2650,22 @@ class Script {
26502650
});
26512651
const funcString = funcs.reduce((s, func) => {
26522652
let fString = context[func].toString();
2653-
if (!/function/u.test(fString)) {
2653+
if (!/function/v.test(fString)) {
26542654
fString = 'function ' + fString;
26552655
}
26562656
return 'var ' + func + '=' + fString + ';' + s;
26572657
}, '');
26582658
expr = funcString + expr;
26592659

26602660
// Mitigate https://perfectionkills.com/global-eval-what-are-the-options/#new_function
2661-
if (!/(['"])use strict\1/u.test(expr) && !keys.includes('arguments')) {
2661+
if (!/(['"])use strict\1/v.test(expr) && !keys.includes('arguments')) {
26622662
expr = 'var arguments = undefined;' + expr;
26632663
}
26642664

26652665
// Remove last semi so `return` will be inserted before
26662666
// the previous one instead, allowing for the return
26672667
// of a bare ending expression
2668-
expr = expr.replace(/;\s*$/u, '');
2668+
expr = expr.replace(/;\s*$/v, '');
26692669

26702670
// Insert `return`
26712671
const lastStatementEnd = expr.lastIndexOf(';');

‎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.

‎dist/index-browser-umd.cjs‎

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2116,7 +2116,7 @@
21162116
} else if (loc === '$') {
21172117
// root only
21182118
addRet(this._trace(x, val, path, null, null, callback, hasArrExpr));
2119-
} else if (/^(-?\d*):(-?\d*):?(\d*)$/u.test(loc)) {
2119+
} else if (/^(-?\d*):(-?\d*):?(\d*)$/v.test(loc)) {
21202120
// [start:end:step] Python slice syntax
21212121
const sliceResult = this._slice(loc, x, val, path, parent, parentPropName, callback);
21222122
if (sliceResult) {
@@ -2127,10 +2127,10 @@
21272127
if (this.currEval === false) {
21282128
throw new Error('Eval [?(expr)] prevented in JSONPath expression.');
21292129
}
2130-
const safeLoc = loc.replace(/^\?\((.*?)\)$/u, '$1');
2130+
const safeLoc = loc.replace(/^\?\((.*?)\)$/v, '$1');
21312131
// check for a nested filter expression
21322132

2133-
const nested = /@.?([^?]*)[['](\??\(.*?\))(?!.\)\])[\]']/gu.exec(safeLoc);
2133+
const nested = /@.?([^?]*)[\['](\??\(.*?\))(?!.\)\])[\]']/gv.exec(safeLoc);
21342134
if (nested) {
21352135
// find if there are matches in the nested expression
21362136
// add them to the result set if there is at least one match
@@ -2364,7 +2364,7 @@
23642364
}
23652365
const scriptCacheKey = this.currEval + 'Script:' + code;
23662366
if (!scriptCache.has(scriptCacheKey)) {
2367-
let script = code.replaceAll('@parentProperty', '_$_parentProperty').replaceAll('@parent', '_$_parent').replaceAll('@property', '_$_property').replaceAll('@root', '_$_root').replaceAll(/@([.\s)[])/gu, '_$_v$1');
2367+
let script = code.replaceAll('@parentProperty', '_$_parentProperty').replaceAll('@parent', '_$_parent').replaceAll('@property', '_$_property').replaceAll('@root', '_$_root').replaceAll(/@([.\s\)\[])/gv, '_$_v$1');
23682368
if (containsPath) {
23692369
script = script.replaceAll('@path', '_$_path');
23702370
}
@@ -2460,8 +2460,8 @@
24602460
n = x.length;
24612461
let p = '$';
24622462
for (let i = 1; i < n; i++) {
2463-
if (!/^(~|\^|@.*?\(\))$/u.test(x[i])) {
2464-
p += /^[0-9*]+$/u.test(x[i]) ? '[' + x[i] + ']' : "['" + x[i] + "']";
2463+
if (!/^(~|\^|@.*?\(\))$/v.test(x[i])) {
2464+
p += /^[0-9*]+$/v.test(x[i]) ? '[' + x[i] + ']' : "['" + x[i] + "']";
24652465
}
24662466
}
24672467
return p;
@@ -2476,7 +2476,7 @@
24762476
n = x.length;
24772477
let p = '';
24782478
for (let i = 1; i < n; i++) {
2479-
if (!/^(~|\^|@.*?\(\))$/u.test(x[i])) {
2479+
if (!/^(~|\^|@.*?\(\))$/v.test(x[i])) {
24802480
p += '/' + x[i].toString().replaceAll('~', '~0').replaceAll('/', '~1');
24812481
}
24822482
}
@@ -2495,37 +2495,37 @@
24952495
const subx = [];
24962496
const normalized = expr
24972497
// Properties
2498-
.replaceAll(/@[\w$-]+\(\)/gu, ';$&;')
2498+
.replaceAll(/@[\w$\-]+\(\)/gv, ';$&;')
24992499
// Parenthetical evaluations (filtering and otherwise), directly
25002500
// within brackets or single quotes
2501-
.replaceAll(/[['](\??\(.*?\))[\]'](?!.\])/gu, function ($0, $1) {
2501+
.replaceAll(/[\['](\??\(.*?\))[\]'](?!.\])/gv, function ($0, $1) {
25022502
return '[#' + (
25032503
// eslint-disable-next-line @stylistic/max-len -- Long
25042504
// eslint-disable-next-line unicorn/no-return-array-push -- Optimization
25052505
subx.push($1) - 1) + ']';
25062506
})
25072507
// Escape periods and tildes within properties
2508-
.replaceAll(/\[['"]([^'\]]*)['"]\]/gu, function ($0, prop) {
2508+
.replaceAll(/\[['"]([^'\]]*)['"]\]/gv, function ($0, prop) {
25092509
return "['" + prop.replaceAll('.', '%@%').replaceAll('~', '%%@@%%') + "']";
25102510
})
25112511
// Properties operator
25122512
.replaceAll('~', ';~;')
25132513
// Split by property boundaries
2514-
.replaceAll(/['"]?\.['"]?(?![^[]*\])|\[['"]?/gu, ';')
2514+
.replaceAll(/['"]?\.['"]?(?![^\[]*\])|\[['"]?/gv, ';')
25152515
// Reinsert periods within properties
25162516
.replaceAll('%@%', '.')
25172517
// Reinsert tildes within properties
25182518
.replaceAll('%%@@%%', '~')
25192519
// Parent
2520-
.replaceAll(/(?:;)?(\^+)(?:;)?/gu, function ($0, ups) {
2520+
.replaceAll(/(?:;)?(\^+)(?:;)?/gv, function ($0, ups) {
25212521
return ';' + ups.split('').join(';') + ';';
25222522
})
25232523
// Descendents
2524-
.replaceAll(/;;;|;;/gu, ';..;')
2524+
.replaceAll(/;;;|;;/gv, ';..;')
25252525
// Remove trailing
2526-
.replaceAll(/;$|'?\]|'$/gu, '');
2526+
.replaceAll(/;$|'?\]|'$/gv, '');
25272527
const exprList = normalized.split(';').map(function (exp) {
2528-
const match = exp.match(/#(\d+)/u);
2528+
const match = exp.match(/#(\d+)/v);
25292529
return !match || !match[1] ? exp : subx[Number(match[1])];
25302530
});
25312531
pathCache.set(expr, exprList);
@@ -2656,22 +2656,22 @@
26562656
});
26572657
const funcString = funcs.reduce((s, func) => {
26582658
let fString = context[func].toString();
2659-
if (!/function/u.test(fString)) {
2659+
if (!/function/v.test(fString)) {
26602660
fString = 'function ' + fString;
26612661
}
26622662
return 'var ' + func + '=' + fString + ';' + s;
26632663
}, '');
26642664
expr = funcString + expr;
26652665

26662666
// Mitigate https://perfectionkills.com/global-eval-what-are-the-options/#new_function
2667-
if (!/(['"])use strict\1/u.test(expr) && !keys.includes('arguments')) {
2667+
if (!/(['"])use strict\1/v.test(expr) && !keys.includes('arguments')) {
26682668
expr = 'var arguments = undefined;' + expr;
26692669
}
26702670

26712671
// Remove last semi so `return` will be inserted before
26722672
// the previous one instead, allowing for the return
26732673
// of a bare ending expression
2674-
expr = expr.replace(/;\s*$/u, '');
2674+
expr = expr.replace(/;\s*$/v, '');
26752675

26762676
// Insert `return`
26772677
const lastStatementEnd = expr.lastIndexOf(';');

‎dist/index-browser-umd.min.cjs‎

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

‎dist/index-browser-umd.min.cjs.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.

‎dist/index-node-cjs.cjs‎

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2114,7 +2114,7 @@ class JSONPathClass {
21142114
} else if (loc === '$') {
21152115
// root only
21162116
addRet(this._trace(x, val, path, null, null, callback, hasArrExpr));
2117-
} else if (/^(-?\d*):(-?\d*):?(\d*)$/u.test(loc)) {
2117+
} else if (/^(-?\d*):(-?\d*):?(\d*)$/v.test(loc)) {
21182118
// [start:end:step] Python slice syntax
21192119
const sliceResult = this._slice(loc, x, val, path, parent, parentPropName, callback);
21202120
if (sliceResult) {
@@ -2125,10 +2125,10 @@ class JSONPathClass {
21252125
if (this.currEval === false) {
21262126
throw new Error('Eval [?(expr)] prevented in JSONPath expression.');
21272127
}
2128-
const safeLoc = loc.replace(/^\?\((.*?)\)$/u, '$1');
2128+
const safeLoc = loc.replace(/^\?\((.*?)\)$/v, '$1');
21292129
// check for a nested filter expression
21302130

2131-
const nested = /@.?([^?]*)[['](\??\(.*?\))(?!.\)\])[\]']/gu.exec(safeLoc);
2131+
const nested = /@.?([^?]*)[\['](\??\(.*?\))(?!.\)\])[\]']/gv.exec(safeLoc);
21322132
if (nested) {
21332133
// find if there are matches in the nested expression
21342134
// add them to the result set if there is at least one match
@@ -2362,7 +2362,7 @@ class JSONPathClass {
23622362
}
23632363
const scriptCacheKey = this.currEval + 'Script:' + code;
23642364
if (!scriptCache.has(scriptCacheKey)) {
2365-
let script = code.replaceAll('@parentProperty', '_$_parentProperty').replaceAll('@parent', '_$_parent').replaceAll('@property', '_$_property').replaceAll('@root', '_$_root').replaceAll(/@([.\s)[])/gu, '_$_v$1');
2365+
let script = code.replaceAll('@parentProperty', '_$_parentProperty').replaceAll('@parent', '_$_parent').replaceAll('@property', '_$_property').replaceAll('@root', '_$_root').replaceAll(/@([.\s\)\[])/gv, '_$_v$1');
23662366
if (containsPath) {
23672367
script = script.replaceAll('@path', '_$_path');
23682368
}
@@ -2458,8 +2458,8 @@ JSONPath.toPathString = function (pathArr) {
24582458
n = x.length;
24592459
let p = '$';
24602460
for (let i = 1; i < n; i++) {
2461-
if (!/^(~|\^|@.*?\(\))$/u.test(x[i])) {
2462-
p += /^[0-9*]+$/u.test(x[i]) ? '[' + x[i] + ']' : "['" + x[i] + "']";
2461+
if (!/^(~|\^|@.*?\(\))$/v.test(x[i])) {
2462+
p += /^[0-9*]+$/v.test(x[i]) ? '[' + x[i] + ']' : "['" + x[i] + "']";
24632463
}
24642464
}
24652465
return p;
@@ -2474,7 +2474,7 @@ JSONPath.toPointer = function (pointer) {
24742474
n = x.length;
24752475
let p = '';
24762476
for (let i = 1; i < n; i++) {
2477-
if (!/^(~|\^|@.*?\(\))$/u.test(x[i])) {
2477+
if (!/^(~|\^|@.*?\(\))$/v.test(x[i])) {
24782478
p += '/' + x[i].toString().replaceAll('~', '~0').replaceAll('/', '~1');
24792479
}
24802480
}
@@ -2493,37 +2493,37 @@ JSONPath.toPathArray = function (expr) {
24932493
const subx = [];
24942494
const normalized = expr
24952495
// Properties
2496-
.replaceAll(/@[\w$-]+\(\)/gu, ';$&;')
2496+
.replaceAll(/@[\w$\-]+\(\)/gv, ';$&;')
24972497
// Parenthetical evaluations (filtering and otherwise), directly
24982498
// within brackets or single quotes
2499-
.replaceAll(/[['](\??\(.*?\))[\]'](?!.\])/gu, function ($0, $1) {
2499+
.replaceAll(/[\['](\??\(.*?\))[\]'](?!.\])/gv, function ($0, $1) {
25002500
return '[#' + (
25012501
// eslint-disable-next-line @stylistic/max-len -- Long
25022502
// eslint-disable-next-line unicorn/no-return-array-push -- Optimization
25032503
subx.push($1) - 1) + ']';
25042504
})
25052505
// Escape periods and tildes within properties
2506-
.replaceAll(/\[['"]([^'\]]*)['"]\]/gu, function ($0, prop) {
2506+
.replaceAll(/\[['"]([^'\]]*)['"]\]/gv, function ($0, prop) {
25072507
return "['" + prop.replaceAll('.', '%@%').replaceAll('~', '%%@@%%') + "']";
25082508
})
25092509
// Properties operator
25102510
.replaceAll('~', ';~;')
25112511
// Split by property boundaries
2512-
.replaceAll(/['"]?\.['"]?(?![^[]*\])|\[['"]?/gu, ';')
2512+
.replaceAll(/['"]?\.['"]?(?![^\[]*\])|\[['"]?/gv, ';')
25132513
// Reinsert periods within properties
25142514
.replaceAll('%@%', '.')
25152515
// Reinsert tildes within properties
25162516
.replaceAll('%%@@%%', '~')
25172517
// Parent
2518-
.replaceAll(/(?:;)?(\^+)(?:;)?/gu, function ($0, ups) {
2518+
.replaceAll(/(?:;)?(\^+)(?:;)?/gv, function ($0, ups) {
25192519
return ';' + ups.split('').join(';') + ';';
25202520
})
25212521
// Descendents
2522-
.replaceAll(/;;;|;;/gu, ';..;')
2522+
.replaceAll(/;;;|;;/gv, ';..;')
25232523
// Remove trailing
2524-
.replaceAll(/;$|'?\]|'$/gu, '');
2524+
.replaceAll(/;$|'?\]|'$/gv, '');
25252525
const exprList = normalized.split(';').map(function (exp) {
2526-
const match = exp.match(/#(\d+)/u);
2526+
const match = exp.match(/#(\d+)/v);
25272527
return !match || !match[1] ? exp : subx[Number(match[1])];
25282528
});
25292529
pathCache.set(expr, exprList);

0 commit comments

Comments
 (0)