https://github.com/nuintun/holding
Holding a callback for some times
https://github.com/nuintun/holding
Last synced: about 1 year ago
JSON representation
Holding a callback for some times
- Host: GitHub
- URL: https://github.com/nuintun/holding
- Owner: nuintun
- License: mit
- Created: 2016-07-04T03:46:41.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2019-04-22T03:06:39.000Z (about 7 years ago)
- Last Synced: 2024-02-03T05:06:22.054Z (over 2 years ago)
- Language: JavaScript
- Homepage:
- Size: 17.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# holding
> Holding a callback for some times
>
> [![NPM Version][npm-image]][npm-url]
> [![Download Status][download-image]][npm-url]
> [![Dependencies][david-image]][david-url]
## Installation
```bash
$ npm install holding
```
## API
```js
const holding = require('holding');
const done = holding(2, function() {
console.log(this, 'called');
}, this);
done();
done();
done(); // it works
done.times; // show called times
done.called; // show fn call status
```
#### holding(n, fn, context)
* `n` - `{Number}`
holding times, it will execute fn after n times.
* `fn` - `{Function}`
holding callback.
* `context` - `{Any}`
fn context.
#### holding(n, fn, context).times
* show called times.
#### holding(n, fn, context).called
* show fn call status.
#### holding.assert(n, fn, context)
* function for assertion testing, will throw error if call times out of range.
## License
[MIT](LICENSE)
[david-image]: http://img.shields.io/david/nuintun/holding.svg?style=flat-square
[david-url]: https://david-dm.org/nuintun/holding
[npm-image]: http://img.shields.io/npm/v/holding.svg?style=flat-square
[npm-url]: https://www.npmjs.org/package/holding
[download-image]: http://img.shields.io/npm/dm/holding.svg?style=flat-square