npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

core-written-number

v0.1.1

Published

A versatile library for converting numeric values into their written word form in multiple languages.

Readme

core-written-number

Convert numbers to their written form.

The core-written-number library allows converting numeric values into their word equivalents, supporting multiple languages. Ideal for applications that require number-to-word transformations, such as financial applications, educational tools, or document generation.

Features

  • Supports multiple languages with unique grammar rules for each.
  • Provides detailed customization options to fit different linguistic structures.
  • Developed with TypeScript for better type safety and integration.

Installation

With npm:

npm install --save core-written-number

Usage

import writtenNumber from 'core-written-number';

// Default usage in English
console.log(writtenNumber(1234)); // => 'one thousand two hundred and thirty-four'

// Change default language to Spanish
writtenNumber.defaults.lang = 'es';
console.log(writtenNumber(4758)); // => 'cuatro mil setecientos cincuenta y ocho'

// Specifying a language using options
console.log(writtenNumber(1234, { lang: 'pt' })); // => 'mil duzentos e trinta e quatro'
console.log(writtenNumber(1234, { lang: 'en' })); // => 'one thousand two hundred and thirty-four'
console.log(writtenNumber(2580000000, { lang: 'pt' })); // => 'dois bilhões quinhentos e oitenta milhões'

Options

  • noAnd - Defaults to false. Determines whether to use the separator "and" for English and other languages where applicable. This separator is internationalized based on the chosen language.
  • lang - Could be a string representing the language code (like 'en', 'es', or 'pt') or an i18n configuration object. Defaults to 'en'. Determines which language to use.

Supported Languages

| Language | lang | |------------------|--------| | English | en | | Portuguese (BR) | pt | | Spanish | es |

Adding New Languages

If your language is not yet supported, you can configure your own! Each language has its own unique grammar exceptions and rules. To add support for a new language, create a new JSON file in the i18n folder and follow the parameters described below.

Language Parameters

Below are the parameters used in the current supported languages:

| Parameter | Type | Description | Examples | |-------------------|---------|-----------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------| | useLongScale | boolean | Determines if the language uses the long or short scale. | Affects the meaning of words like billion and trillion. | | baseSeparator | string | Separates the base cardinal numbers. | e.g., twenty-eight or in Spanish " y " | | unitSeparator | string | Separates the unit from the base cardinal numbers. | e.g., one thousand two hundred **and** thirty-four | | allSeparator | string | Optional: Separates all cardinals, not just the last one. | Arabic example: ألف ومائة وخمسة وعشرون | | base | Object | Defines base cardinal numbers that have unique names. | | | alternativeBase | Object | Defines alternative versions of base cardinal numbers, specific to units or grammatical rules. | "alternativeBase": {"feminine": {"1": "una", "2": "dos"}} | | units | Array | Defines a list of number units (string or Object). Supports singular, dual, and plural units. | | | unitExceptions | Object | Grammar exceptions affecting the base cardinal numbers combined with units. | Example: "1232000": "un millón doscientos mil" |

Here’s the corrected section of the README that only includes examples for English, Portuguese (pt), and Spanish (es):


Unit Parameters

A unit can be:

  • A simple string, e.g., "hundred"
  • An object with specific parameters:

| Unit Parameter | Description | Example Languages | |------------------------|----------------------------------------------------------------------------------------------------|--------------------| | singular | Used for one element. | All (en, es, pt) | | plural | Used for two or more elements (or 3 or more, depending on the language). | All (en, es, pt) | | useBaseInstead | Uses the base cardinal number instead of the unit in certain cases. | es, pt | | useBaseException | Specifies which units should not use the base cardinal number. | es, pt | | avoidPrefixException | Units not using the base cardinal number as a prefix for specific units or numbers. | pt | | useSingularEnding | Uses the singular form for numbers ending with 1. | pt, es | | restrictedPlural | Specifies when to use the plural form in a restricted range (e.g., in specific grammatical cases). | pt, es |

TypeScript Support

This library is fully written in TypeScript, ensuring better type safety and developer experience. You can import and use it in TypeScript projects seamlessly:

import writtenNumber from 'core-written-number';

const result: string = writtenNumber(1234, { lang: 'pt' });
console.log(result); // => 'mil duzentos e trinta e quatro'

Contributing

We welcome contributions! If you want to add a new language or improve an existing feature, feel free to submit a pull request. Before submitting, make sure to write and run tests to verify your changes.

Versioning

If you have write access and want to bump the version, run mversion [major|minor|patch] -m. This will bump both bower.json and package.json.

License

This library is licensed under the MIT License for Core Platform. For more information, please refer to the LICENSE file.