https://github.com/dcousens/ordinal.js
A compact module to provide the English ordinal letters following a numeral
https://github.com/dcousens/ordinal.js
javascript numeral ordinal
Last synced: 10 months ago
JSON representation
A compact module to provide the English ordinal letters following a numeral
- Host: GitHub
- URL: https://github.com/dcousens/ordinal.js
- Owner: dcousens
- License: mit
- Created: 2017-04-26T03:44:14.000Z (about 9 years ago)
- Default Branch: main
- Last Pushed: 2024-01-09T19:47:19.000Z (over 2 years ago)
- Last Synced: 2025-08-20T10:53:40.366Z (11 months ago)
- Topics: javascript, numeral, ordinal
- Language: JavaScript
- Homepage:
- Size: 16.6 KB
- Stars: 41
- Watchers: 3
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ordinal
[](https://www.npmjs.org/package/ordinal)
A compact module to provide the English ordinal letters following a numeral.
If other languages are required, [please submit an issue](https://github.com/dcousens/ordinal/issues/new).
## Examples
Numbers only, anything else will throw a `TypeError`.
``` javascript
var ordinal = require('ordinal')
ordinal(1) // '1st'
ordinal(2) // '2nd'
ordinal(3) // '3rd'
ordinal(4) // '4th'
ordinal(11) // '11th'
ordinal(12) // '12th'
ordinal(13) // '13th'
ordinal(21) // '21st'
ordinal(22) // '22nd'
ordinal(23) // '23rd'
ordinal(24) // '24th'
```
To get just the indicator:
``` javascript
var indicator = require('ordinal/indicator')
indicator(1) // 'st'
indicator(2) // 'nd'
indicator(3) // 'rd'
indicator(4) // 'th'
indicator(11) // 'th'
indicator(12) // 'th'
indicator(13) // 'th'
indicator(21) // 'st'
indicator(22) // 'nd'
indicator(23) // 'rd'
indicator(24) // 'th'
```
## LICENSE [MIT](LICENSE)