numbers-from-words
TypeScript icon, indicating that this package has built-in type declarations

0.0.8 • Public • Published

numbers-from-words - A library for parsing words to numbers

NPM Version Downloads Stats

A tiny utility library with no dependencies that parses words representing numbers into their numeric values. Supports a wide variety of inputs, such as:

  • "one hundred and twenty three"
  • "twenty"
  • "one thousand, and five hundred"

Installation

npm i --save numbers-from-words

Usage

Import the parse function call it with the input string containing words defining a number/quantity.

import { parse } from 'numbers-from-words'

const numberA = parse('twenty two')
const numberB = parse('one thousand and twenty three')
const numberC = parse('zero')

console.log({
  numberA,  // 22
  numberB,  // 1023
  numberC   // 0
})

Release History

See CHANGELOG.md for more information.

License

Distributed under the MIT license. See LICENSE.md for more information.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Package Sidebar

Install

npm i numbers-from-words

Weekly Downloads

19

Version

0.0.8

License

MIT

Unpacked Size

241 kB

Total Files

35

Last publish

Collaborators

  • f3rno64