Skip to content

Commit f429bc2

Browse files
committed
- npm: Update devDeps
1 parent e1e089d commit f429bc2

File tree

9 files changed

+1739
-513
lines changed

9 files changed

+1739
-513
lines changed

CHANGES.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# CHANGES for jsonpath-plus
22

3+
## ?
4+
5+
- npm: Update devDeps
6+
37
## 3.0.0 (2020-01-13)
48

59
- Breaking change: Expect Node >= 8

dist/index-es.js

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
function _typeof(obj) {
2+
"@babel/helpers - typeof";
3+
24
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
35
_typeof = function (obj) {
46
return typeof obj;
@@ -216,7 +218,7 @@ var vm = JSONPath.nodeVMSupported ? require('vm') : {
216218
var funcString = funcs.reduce(function (s, func) {
217219
var fString = context[func].toString();
218220

219-
if (!/function/.exec(fString)) {
221+
if (!/function/.test(fString)) {
220222
fString = 'function ' + fString;
221223
}
222224

@@ -428,15 +430,16 @@ JSONPath.prototype.evaluate = function (expr, json, callback, otherTypeCallback)
428430
expr = expr || this.path;
429431

430432
if (expr && _typeof(expr) === 'object' && !Array.isArray(expr)) {
431-
if (!expr.path) {
433+
if (!expr.path && expr.path !== '') {
432434
throw new TypeError('You must supply a "path" property when providing an object ' + 'argument to JSONPath.evaluate().');
433435
}
434436

435-
if (!('json' in expr)) {
437+
if (!hasOwnProp.call(expr, 'json')) {
436438
throw new TypeError('You must supply a "json" property when providing an object ' + 'argument to JSONPath.evaluate().');
437439
}
438440

439-
json = hasOwnProp.call(expr, 'json') ? expr.json : json;
441+
var _expr = expr;
442+
json = _expr.json;
440443
flatten = hasOwnProp.call(expr, 'flatten') ? expr.flatten : flatten;
441444
this.currResultType = hasOwnProp.call(expr, 'resultType') ? expr.resultType : this.currResultType;
442445
this.currSandbox = hasOwnProp.call(expr, 'sandbox') ? expr.sandbox : this.currSandbox;
@@ -456,7 +459,7 @@ JSONPath.prototype.evaluate = function (expr, json, callback, otherTypeCallback)
456459
expr = JSONPath.toPathString(expr);
457460
}
458461

459-
if (!expr || !json) {
462+
if (!expr && expr !== '' || !json) {
460463
return undefined;
461464
}
462465

@@ -503,9 +506,12 @@ JSONPath.prototype._getPreferredOutput = function (ea) {
503506
throw new TypeError('Unknown result type');
504507

505508
case 'all':
506-
ea.pointer = JSONPath.toPointer(ea.path);
507-
ea.path = typeof ea.path === 'string' ? ea.path : JSONPath.toPathString(ea.path);
508-
return ea;
509+
{
510+
var path = Array.isArray(ea.path) ? ea.path : JSONPath.toPathArray(ea.path);
511+
ea.pointer = JSONPath.toPointer(path);
512+
ea.path = typeof ea.path === 'string' ? ea.path : JSONPath.toPathString(ea.path);
513+
return ea;
514+
}
509515

510516
case 'value':
511517
case 'parent':
@@ -614,11 +620,11 @@ JSONPath.prototype._trace = function (expr, val, path, parent, parentPropName, c
614620
} else if (loc === '^') {
615621
// This is not a final endpoint, so we do not invoke the callback here
616622
this._hasParentSelector = true;
617-
return path.length ? {
623+
return {
618624
path: path.slice(0, -1),
619625
expr: x,
620626
isParentSelector: true
621-
} : [];
627+
};
622628
} else if (loc === '~') {
623629
// property name
624630
retObj = {
@@ -817,12 +823,10 @@ JSONPath.prototype._walk = function (loc, expr, val, path, parent, parentPropNam
817823
for (var i = 0; i < n; i++) {
818824
f(i, loc, expr, val, path, parent, parentPropName, callback);
819825
}
820-
} else if (_typeof(val) === 'object') {
821-
for (var m in val) {
822-
if (hasOwnProp.call(val, m)) {
823-
f(m, loc, expr, val, path, parent, parentPropName, callback);
824-
}
825-
}
826+
} else if (val && _typeof(val) === 'object') {
827+
Object.keys(val).forEach(function (m) {
828+
f(m, loc, expr, val, path, parent, parentPropName, callback);
829+
});
826830
}
827831
};
828832

dist/index-es.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-es.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-umd.js

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
}(this, (function (exports) { 'use strict';
66

77
function _typeof(obj) {
8+
"@babel/helpers - typeof";
9+
810
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
911
_typeof = function (obj) {
1012
return typeof obj;
@@ -222,7 +224,7 @@
222224
var funcString = funcs.reduce(function (s, func) {
223225
var fString = context[func].toString();
224226

225-
if (!/function/.exec(fString)) {
227+
if (!/function/.test(fString)) {
226228
fString = 'function ' + fString;
227229
}
228230

@@ -434,15 +436,16 @@
434436
expr = expr || this.path;
435437

436438
if (expr && _typeof(expr) === 'object' && !Array.isArray(expr)) {
437-
if (!expr.path) {
439+
if (!expr.path && expr.path !== '') {
438440
throw new TypeError('You must supply a "path" property when providing an object ' + 'argument to JSONPath.evaluate().');
439441
}
440442

441-
if (!('json' in expr)) {
443+
if (!hasOwnProp.call(expr, 'json')) {
442444
throw new TypeError('You must supply a "json" property when providing an object ' + 'argument to JSONPath.evaluate().');
443445
}
444446

445-
json = hasOwnProp.call(expr, 'json') ? expr.json : json;
447+
var _expr = expr;
448+
json = _expr.json;
446449
flatten = hasOwnProp.call(expr, 'flatten') ? expr.flatten : flatten;
447450
this.currResultType = hasOwnProp.call(expr, 'resultType') ? expr.resultType : this.currResultType;
448451
this.currSandbox = hasOwnProp.call(expr, 'sandbox') ? expr.sandbox : this.currSandbox;
@@ -462,7 +465,7 @@
462465
expr = JSONPath.toPathString(expr);
463466
}
464467

465-
if (!expr || !json) {
468+
if (!expr && expr !== '' || !json) {
466469
return undefined;
467470
}
468471

@@ -509,9 +512,12 @@
509512
throw new TypeError('Unknown result type');
510513

511514
case 'all':
512-
ea.pointer = JSONPath.toPointer(ea.path);
513-
ea.path = typeof ea.path === 'string' ? ea.path : JSONPath.toPathString(ea.path);
514-
return ea;
515+
{
516+
var path = Array.isArray(ea.path) ? ea.path : JSONPath.toPathArray(ea.path);
517+
ea.pointer = JSONPath.toPointer(path);
518+
ea.path = typeof ea.path === 'string' ? ea.path : JSONPath.toPathString(ea.path);
519+
return ea;
520+
}
515521

516522
case 'value':
517523
case 'parent':
@@ -620,11 +626,11 @@
620626
} else if (loc === '^') {
621627
// This is not a final endpoint, so we do not invoke the callback here
622628
this._hasParentSelector = true;
623-
return path.length ? {
629+
return {
624630
path: path.slice(0, -1),
625631
expr: x,
626632
isParentSelector: true
627-
} : [];
633+
};
628634
} else if (loc === '~') {
629635
// property name
630636
retObj = {
@@ -823,12 +829,10 @@
823829
for (var i = 0; i < n; i++) {
824830
f(i, loc, expr, val, path, parent, parentPropName, callback);
825831
}
826-
} else if (_typeof(val) === 'object') {
827-
for (var m in val) {
828-
if (hasOwnProp.call(val, m)) {
829-
f(m, loc, expr, val, path, parent, parentPropName, callback);
830-
}
831-
}
832+
} else if (val && _typeof(val) === 'object') {
833+
Object.keys(val).forEach(function (m) {
834+
f(m, loc, expr, val, path, parent, parentPropName, callback);
835+
});
832836
}
833837
};
834838

dist/index-umd.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-umd.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)