Humanity

Deno GitHub GitHub release (latest SemVer) npm

GitHub Repo stars

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 thousand

NodeJS

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

You 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 th

Disable spaces between number and word

Humanity.disable("spacing");
console.log(Humanity.number(500000)); // 500thousand

Supported languages by default

  • en_US
  • de_DE
  • ru_RU