Socket
Book a DemoInstallSign in
Socket

@humanwhocodes/number-to-words

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@humanwhocodes/number-to-words

Converts a number into English words.

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

Number to Words

by Nicholas C. Zakas

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

Install using npm or yarn:

npm install @humanwhocodes/number-to-words --save

# or

yarn add @humanwhocodes/number-to-words

Import 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 install to setup dependencies
  • Run npm test to run tests

License

Apache 2.0

Keywords

numbers

FAQs

Package last updated on 15 Oct 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts