added case of empty object and empty array
This commit is contained in:
parent
55438debc5
commit
1ad8b9e54f
|
@ -8,5 +8,7 @@
|
||||||
"grault": 1,
|
"grault": 1,
|
||||||
"garply": true,
|
"garply": true,
|
||||||
"waldo": "false",
|
"waldo": "false",
|
||||||
"fred": "undefined"
|
"fred": "undefined",
|
||||||
|
"emptyarr": [],
|
||||||
|
"emptyobj": {}
|
||||||
}
|
}
|
||||||
|
|
10
index.js
10
index.js
|
@ -34,6 +34,11 @@
|
||||||
var output = ''
|
var output = ''
|
||||||
;
|
;
|
||||||
|
|
||||||
|
if (0 === x.length) {
|
||||||
|
output += '[]';
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
indentLevel = indentLevel.replace(/$/, ' ');
|
indentLevel = indentLevel.replace(/$/, ' ');
|
||||||
x.forEach(function (y) {
|
x.forEach(function (y) {
|
||||||
// TODO how should `undefined` be handled?
|
// TODO how should `undefined` be handled?
|
||||||
|
@ -55,6 +60,11 @@
|
||||||
var output = ''
|
var output = ''
|
||||||
;
|
;
|
||||||
|
|
||||||
|
if (0 === Object.keys(x).length) {
|
||||||
|
output += '{}';
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
indentLevel = indentLevel.replace(/$/, ' ');
|
indentLevel = indentLevel.replace(/$/, ' ');
|
||||||
Object.keys(x).forEach(function (k) {
|
Object.keys(x).forEach(function (k) {
|
||||||
var val = x[k]
|
var val = x[k]
|
||||||
|
|
Loading…
Reference in New Issue