Skip to content

Commit 2b1efe6

Browse files
committed
- Refactoring: Avoid extra code for filtering own properties (also improves coverage)
1 parent 9fc7c32 commit 2b1efe6

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/jsonpath.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -633,12 +633,10 @@ JSONPath.prototype._walk = function (
633633
for (let i = 0; i < n; i++) {
634634
f(i, loc, expr, val, path, parent, parentPropName, callback);
635635
}
636-
} else if (typeof val === 'object') {
637-
for (const m in val) {
638-
if (hasOwnProp.call(val, m)) {
639-
f(m, loc, expr, val, path, parent, parentPropName, callback);
640-
}
641-
}
636+
} else if (val && typeof val === 'object') {
637+
Object.keys(val).forEach((m) => {
638+
f(m, loc, expr, val, path, parent, parentPropName, callback);
639+
});
642640
}
643641
};
644642

0 commit comments

Comments
 (0)