Humanizer for Deno & NodeJS
Humanity is a library for humanizing data in a human-readable form.
import { createHumanity } from "https://deno.land/x/humanity/mod.ts";
const Humanity = createHumanity("en_US");
console.log(Humanity.number(500000)); // 500 000
// Output: 500 thousand
You can use it library with NodeJS
npm i humanity-deno
const { createHumanity } = require("humanity-deno");
const Humanity = createHumanity("en_US");
console.log(Humanity.number(500000)); // 500 000
// Output: 500 thousand
import { createCustomHumanity } from "https://deno.land/x/humanity/mod.ts";
const Humanity = createCustomHumanity({
locale: "custom",
words: {
...DefaultLocales.en_US.words,
},
numbers: {
thousand: "th",
million: "m",
billion: "b",
trillion: "t",
quadrillion: "q",
quintillion: "qui",
},
});
console.log(Humanity.number(500000)); // 500 th
Humanity.disableFeature("spacing");
console.log(Humanity.number(500000)); // 500thousand
Humanity.number(500000) // 500 thousand
Humanity.truncate("Humanity is a library for humanizing data in a human-readable form.", 24) // "Humanity is a library fo..."
Humanity.toRoman(505) // DV
Humanity.binarySuffix(500, 0) // 500 B
Humanity.arrayToText(["Dustin", "Leda", "Tristin", "Maybelle", "Dee", "Stephon"], 3) // Dustin, Leda, Tristin and 3 others
Humanity.dateTime.difference(1656532800000, 1659211200000); // 4 weeks ago
Humanity.humanCase("mainField") // "Main field"
You can customize defaults the language and create yourself language
en_US
de_DE
ru_RU