zaraz
Version:
Cheap way to introduce short async delay.
61 lines (35 loc) • 1.29 kB
Markdown
[![NPM version][npm-image]][npm-url]
[![Build Status][build-image]][build-url]
[![Dependency Status][deps-image]][deps-url]
Cheap way to introduce short async delay.
```sh
$ npm install --save zaraz
```
```js
const zaraz = require('zaraz');
function sum(a, b) {
console.log(a + b);
}
zaraz(sum, 5, 7); // will display 13 after a short delay
zaraz(sum, 10, 10); // will displey 20 after it displays 13
```
schedule `fn` to be called in near future - `args` will be passed to `fn`
minumum delay before task is processed - 10 millis by default
maximum time spent processing taks queue before yielding - 100 millis by default
maximum number of task processed before yielding - 1000 by default
MIT © [Damian Krzeminski](https://pirxpilot.me)
[]: https://img.shields.io/npm/v/zaraz
[]: https://npmjs.org/package/zaraz
[]: https://github.com/pirxpilot/zaraz/actions/workflows/check.yaml
[]: https://img.shields.io/github/actions/workflow/status/pirxpilot/zaraz/check.yaml?branch=main
[]: https://img.shields.io/librariesio/release/npm/zaraz
[]: https://libraries.io/npm/zaraz