1.0.0 • Published 4 years ago
@humanwhocodes/number-to-words v1.0.0
Number to Words
If you find this useful, please consider supporting my work with a donation.
Description
A function that accepts a positive integer (or zero) and returns the English-language description of the number.
Usage
Node.js
npm install @humanwhocodes/number-to-words --save
# or
yarn add @humanwhocodes/number-to-wordsImport into your Node.js project:
// CommonJS
const { numberToWords } = require("@humanwhocodes/number-to-words");
// ESM
import { numberToWords } from "@humanwhocodes/number-to-words";Deno
Import into your Deno project:
import { numberToWords } from "https://cdn.skypack.dev/@humanwhocodes/number-to-words?dts";Browser
It's recommended to import the minified version to save bandwidth:
import { numberToWords } from "https://cdn.skypack.dev/@humanwhocodes/number-to-words?min";However, you can also import the unminified version for debugging purposes:
import { numberToWords } from "https://cdn.skypack.dev/@humanwhocodes/number-to-words";API
After importing, pass any positive integer or zero to numberToWords():
console.log(numberToWords(0)); // "zero"
console.log(numberToWords(10)); // "ten"
console.log(numberToWords(524)); // "five hundred twenty-four"The numberToWords() function works up to 999 trillion. If you need larger numbers then that, I envy you.
Developer Setup
- Fork the repository
- Clone your fork
- Run
npm installto setup dependencies - Run
npm testto run tests
License
Apache 2.0
1.0.0
4 years ago