Skip to content

A tiny utility library with no dependencies that parses words representing numbers into their numeric values.

License

Notifications You must be signed in to change notification settings

f3rno64/numbers-from-words

Repository files navigation

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

About

A tiny utility library with no dependencies that parses words representing numbers into their numeric values.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published