@jsenv/humanize
helps to generate messages meant to be read by humans
It is written in ES6 and compatible with browsers and Node.js.
Turns a JavaScript value into a string meant to be read by a human.
import { humanize } from "@jsenv/humanize";
console.log(
humanize({
boolean: true,
number: 10,
string: "hello world",
}),
);
{
"boolean": true,
"number": 10,
"string": "hello world"
}
Table comparing JSON.stringify
and humanize()
to demonstrates how inspect focuses on readability and accuracy.
value | JSON.stringify | humanize |
---|---|---|
123456789 | "123456789" | 123_456_789 |
Infinity | "null" | Infinity |
-0 | "0" | -0 |
'"' | '"\""' | '"' |
import { humanizeDuration } from "@jsenv/humanize";
humanizeDuration(61_421); // "1 minute and 1 second"