Socket
Socket
Sign inDemoInstall

number-to-words

Package Overview
Dependencies
0
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.1 to 1.1.0

spec/indexSpec.js

32

package.json
{
"name": "number-to-words",
"description": "Convert numbers into words",
"version": "1.0.1",
"author": "Martin Eneqvist <marlun78@hotmail.com> (https://github.com/marlun78)",
"homepage": "https://github.com/marlun78",
"version": "1.1.0",
"description": "Contains some util methods for converting numbers into words, ordinal words and ordinal numbers.",
"main": "./src",
"devDependencies": {
"jasmine": "^2.2.1"
},
"scripts": {
"test": "jasmine"
},
"repository": {

@@ -11,25 +16,16 @@ "type": "git",

},
"author": "Martin Eneqvist <marlun78@hotmail.com> (https://github.com/marlun78)",
"license": "MIT",
"bugs": {
"url": "https://github.com/marlun78/number-to-words/issues"
},
"homepage": "https://github.com/marlun78/number-to-words",
"keywords": [
"convert",
"converter",
"number",
"numbers",
"ordinal",
"string",
"strings",
"tool",
"tools",
"word",
"words"
],
"main": "./src",
"scripts": {
"test": "jasmine"
},
"devDependencies": {
"jasmine": "^2.2.1"
}
"word"
]
}

@@ -0,3 +1,9 @@

[![NPM](https://nodei.co/npm/number-to-words.png)](https://www.npmjs.com/package/number-to-words)
# Number To Words
Converts numbers into words.
Contains some util methods for converting numbers into words, ordinal words and
ordinal numbers.

@@ -9,22 +15,35 @@

### Usage
```JavaScript
var numberConverter = require('number-to-words');
numberConverter.toWords(13);
// “thirteen”
### API
#### `toOrdinal(number)`
Converts an integer into a string with an ordinal postfix.
If number is decimal, the decimals will be removed.
```js
var converter = require('number-to-words');
converter.toOrdinal(21); // => “21st”
```
#### `toWords(number)`
Converts an integer into words.
If number is decimal, the decimals will be removed.
```js
var converter = require('number-to-words');
converter.toWords(13); // => “thirteen”
// Decimal numbers:
converter.toWords(2.9); // => “two”
// Negative numbers:
numberConverter.toWords(-3);
// “minus three”
converter.toWords(-3); // => “minus three”
// Large numbers:
numberConverter.toWords(9007199254740992);
// “nine quadrillion, seven trillion, one hundred ninety-nine billion, two hundred fifty-four million, seven hundred forty thousand, nine hundred ninety-two”
converter.toWords(9007199254740992); // => “nine quadrillion, seven trillion, one hundred ninety-nine billion, two hundred fifty-four million, seven hundred forty thousand, nine hundred ninety-two”
```
// As ordinal:
numberConverter.toWords(21, true);
// “twenty-first”
#### `toWordsOrdinal(number)`
Converts a number into ordinal words.
If number is decimal, the decimals will be removed.
```js
var converter = require('number-to-words');
converter.toWordsOrdinal(21); // => “twenty-first”
```

@@ -35,1 +54,16 @@

Comments and bug reports are much appreciated. Please enter them on the [issues page](https://github.com/marlun78/number-to-words/issues). Thanks!
### Change Log
##### 1.1.0
- New methods `toOrdinal` and `toWordsOrdinal`
- Deprecated `toWords` second optional `asOrdinal` parameter
- `toWords` now converts any decimal input to an integer (with `Math.floor`)
- Bug fixed returning _“zeroth”_ instead of _“zero”_ when converting a number word into its ordinal
##### 1.0.1
- Minor package tweaks
##### 1.0.0
- Initial release
'use strict';
module.exports = {
toWords: require('./numberToWords')
toOrdinal: require('./toOrdinal'),
toWords: require('./toWords'),
toWordsOrdinal: require('./toWordsOrdinal')
};
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc