Attributes
Includes Deno configuration
Repository
Current version released
3 years ago
Humanity
Humanity is a library for humanizing data in a human-readable form.
How to use
Deno
import { createHumanity } from "https://deno.land/x/humanity/mod.ts";
const Humanity = createHumanity("en_US");
console.log(Humanity.number(500000)); // 500 000
// Output: 500 thousandNodeJS
You can use it library with NodeJS
npm i humanity-denoconst { createHumanity } = require("humanity-deno");
const Humanity = createHumanity("en_US");
console.log(Humanity.number(500000)); // 500 000
// Output: 500 thousandYou can use custom language
import { createCustomHumanity } from "https://deno.land/x/humanity/mod.ts";
const Humanity = createCustomHumanity({
locale: "custom",
numbers: {
thousand: "th",
million: "m",
billion: "b",
trillion: "t",
quadrillion: "q",
quintillion: "qui",
},
});
console.log(Humanity.number(500000)); // 500 thDisable spaces between number and word
Humanity.disableFeature("spacing");
console.log(Humanity.number(500000)); // 500thousandAvailable functions
- number(n: number | bigint): string
Humanity.number(500000) // 500 thousand - truncate(n: string | number | bigint, lengthMax: number): string
Humanity.truncate("Humanity is a library for humanizing data in a human-readable form.", 24) // "Humanity is a library fo..." - toRoman(n: number): string
Humanity.toRoman(505) // DV - binarySuffix(n: number, fixed = 2): string
Humanity.binarySuffix(500, 0) // 500 B
Supported languages by default
You can customize defaults the language and create yourself language
en_USde_DEru_RU