Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lukem512/uponatime
[Once] upon a time. Prints 'once', 'twice' or 'n times'.
https://github.com/lukem512/uponatime
count grammar language once thrice twice
Last synced: about 8 hours ago
JSON representation
[Once] upon a time. Prints 'once', 'twice' or 'n times'.
- Host: GitHub
- URL: https://github.com/lukem512/uponatime
- Owner: lukem512
- Created: 2017-04-21T10:23:54.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-11-07T17:07:28.000Z (about 7 years ago)
- Last Synced: 2024-10-13T15:10:59.741Z (about 1 month ago)
- Topics: count, grammar, language, once, thrice, twice
- Language: JavaScript
- Homepage: http://npmjs.com/package/uponatime
- Size: 2.93 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# [Once] upon a time
[![Build Status](https://travis-ci.org/lukem512/uponatime.svg?branch=master)](https://travis-ci.org/lukem512/uponatime)
Prints 'once', 'twice' or 'n times'.
## Install
```
npm i --save uponatime
```## Usage
```js
const uponatime = require('uponatime');let clicks = 0;
// This will print:
// 1. 'Clicked the button once'
// 2. 'Clicked the button twice'
// 3. 'Clicked the button 3 times'
// 4. 'Clicked the button 4 times'
// ...
function buttonHandler() {
clicks++;
console.log(`Clicked the button ${uponatime(clicks)}`);
}
```An `opts` object may be passed as a optional parameter.
Specifying a truthy value for `thrice` will print `thrice` rather than `3 times`. The default value for `thrice` is `false`.
Specifying a truthy value of `capitalize` will print `Once`, `Twice` and `Trhrice` with a capital letter at the beginning. Then values for `n times` are not affected. The default value for `capitalize` is `false`.
A second method, `times` is also exported. This will simply print `n times` for a specified value of `n`.
```js
// This will print: '14 times'
console.log(uponatime.times(14));
```## License
MIT © Luke Mitchell