spoken-numbers
v0.0.4
Published
Convert numbers to spoken word formats (e.g. 1375 becomes thirteen seventy five). Various formatting options are provided to support simple digits, double digits, leading zeros, alphanumeric values, and variations on the word for 'zero' such a 'O'
Downloads
4
Readme
spoken-numbers
Convert numbers to spoken word formats (e.g. 1375 becomes thirteen seventy five). Various formatting options are provided to support simple digits, c
Install with npm
$ npm install --save spoken-numbers
Usage
var spokenNumbers = require('spoken-numbers');
var words1 = spokenNumbers.toSpoken(1724, 'dd'); // => 'seventeen twenty four'
var words2 = spokenNumbers.toSpoken(1701, 'dd:o'); // => 'seventeen o one'
var words3 = spokenNumbers.toSpoken('AA1901', 'dd:o'); // => 'A A nineteen o one'
var words4 = spokenNumbers.toSpoken('AA1901', 'd'); // => 'A A one nine zero one'
Formats
d
- Formats all numbers as individual digits. Example:14,302,033
becomesone four three zero two zero three three
dd
- Formats all numbers as individual digits. Example:14,30,20,33
becomesfourteen thirty twenty thirty three
w
- Formats all numbers in a verbose form, including named units. Example:14,302,033
becomesfourteen million three hundred and two thousand thirty three
d:o
- Formats all numbers as individual digits but replaceszero
with0
. Example:14,302,033
becomesone four three o two o three three
License
This code is licensed under the MIT license for Scott Beaudreau. For more information, please refer to the LICENSE file.