Arrays in single line
Closed this issue · 6 comments
Is there a way to display Arrays on a single line?
{
'good': [0,1,2],
'bad': [
0,
1,
2
]
}
I think it's useful the way it is, since an array containing anything other than small numbers is going to best be viewed on its own line (think objects with nested properties of various types). I don't think the solution would be too elegant if the code starts making assumptions on what would look good on a new line and what wouldn't.
However, I just noticed the readme says it will print out array elements on a single line, so that should be fixed / tested for if that was the original intentions.
However, I just noticed the readme says it will print out array elements on a single line, so that should be fixed / tested for if that was the original intentions.
PR #14
Nope. Consistency wins here.
I agree that default behavior is useful the way it is.
I just wondered if there was a way to override the default configuration for specific objects (such as Array
s for example) to match special needs.
I understand that it is not possible / desired.
Best regards
PS: This might be configured this way:
var obj = {
foo: 'bar',
'arr': [1, 2, 3],
nested: { hello: "world" }
};
var pretty = stringifyObject(obj, {
indent: {
_default: ' '
Array : ''
},
singleQuotes: false
});
console.log(pretty);
/*
{
foo: "bar",
arr: [ 1, 2, 3 ],
nested: {
hello: "world"
}
}
*/
BTW, I can send a PR for this (if you agree with the idea...)
No sorry, not interested in that kind of bloat.