Skip to content

Commit

Permalink
Include null keys in paths response (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
amarinov authored and mickhansen committed Dec 2, 2019
1 parent 306dce7 commit b504242
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion dottie.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@
for (key in object) {
value = object[key];

if (typeof value === 'object') {
if (typeof value === 'object' && value !== null) {
paths = paths.concat(Dottie.paths(value, prefixes.concat([key])));
} else {
paths.push(prefixes.concat(key).join('.'));
Expand Down
9 changes: 9 additions & 0 deletions test/paths.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,13 @@ describe("dottie.paths", function() {

expect(dottie.paths(object)).to.eql(["a", "b.c", "b.d.e"]);
});

it("includes keys of null objects", function() {
var object = {
nonNullKey: 1,
nullKey: null
};

expect(dottie.paths(object)).to.eql(["nonNullKey", "nullKey"]);
});
});

0 comments on commit b504242

Please sign in to comment.