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"
npm i --save to-numbers
Import the parse
function call it with the input string containing words
defining a number/quantity.
import { parse } from 'to-numbers'
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
})
See CHANGELOG.md for more information.
Distributed under the MIT license. See LICENSE.md for more information.
- 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