Skip to content

Commit 1b5bf74

Browse files
author
Carlos Rodriguez
committed
don't choke on null
1 parent f8ff127 commit 1b5bf74

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ module.exports = function (obj, opts) {
1414
})(opts.cmp);
1515

1616
return (function stringify (node) {
17-
if (typeof node !== 'object') {
17+
if (typeof node !== 'object' || node === null) {
1818
return json.stringify(node);
1919
}
2020
if (isArray(node)) {

test/str.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ var stringify = require('../');
33

44
test('simple object', function (t) {
55
t.plan(1);
6-
var obj = { c: 6, b: [4,5], a: 3 };
7-
t.equal(stringify(obj), '{"a":3,"b":[4,5],"c":6}');
6+
var obj = { c: 6, b: [4,5], a: 3, z: null };
7+
t.equal(stringify(obj), '{"a":3,"b":[4,5],"c":6,"z":null}');
88
});

0 commit comments

Comments
 (0)