numbers-from-words
v0.0.8
Published
A utility library for parsing numbers from words.
Downloads
1,107
Maintainers
Readme
numbers-from-words - A library for parsing words to numbers
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
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request