accelerator-core
Version:
[](https://travis-ci.org/furkleindustries/accelerator-core)
22 lines (20 loc) • 544 B
text/typescript
export const getNiceValueString = (value: any) => {
if (Array.isArray(value)) {
if (value.length > 1) {
return JSON.stringify(value, null, 2);
} else {
return `[ ${JSON.stringify(value).slice(1, -1)} ]`;
}
} else if (value && typeof value === 'object') {
if (Object.keys(value).length > 1) {
return JSON.stringify(value, null, 2);
} else {
return `{ ${
JSON.stringify(value, null, 2)
.replace(/\n/g, '')
.slice(3, -1)
} }`;
}
}
return String(value);
};