node-later
Version:
Defer function calls to the start of the next cycle.
53 lines (39 loc) • 3.1 kB
Markdown
# {"gitdown": "gitinfo", "name": "name"}
[](https://www.npmjs.org/package/{"gitdown": "gitinfo", "name": "name"}) [](https://github.com/{"gitdown": "gitinfo", "name": "username"}/{"gitdown": "gitinfo", "name": "name"}/actions) [](https://coveralls.io/r/{"gitdown": "gitinfo", "name": "username"}/{"gitdown": "gitinfo", "name": "name"}) [](https://snyk.io/test/github/{"gitdown": "gitinfo", "name": "username"}/{"gitdown": "gitinfo", "name": "name"}) [](http://inch-ci.org/github/{"gitdown": "gitinfo", "name": "username"}/{"gitdown": "gitinfo", "name": "name"}) [](https://github.com/{"gitdown": "gitinfo", "name": "username"}/{"gitdown": "gitinfo", "name": "name"}/blob/master/LICENSE) [](https://www.npmjs.org/package/{"gitdown": "gitinfo", "name": "name"})
> Defer function calls to the start of the next cycle.
* [Overview](#overview)
* [Usage](#usage)
* [Installation](#installation)
* [API Documentation](docs/api.md)
* [Contributing](.github/CONTRIBUTING.md)
* [Release History](#history)
* [License](#license)
<a name="overview"></a>
## Overview
Invoke functions in the next cycle.<br>
You have multiple node.js APIs to run a function later, for example process.nextTick, setImmediate and setTimeout.<br>
Each of those will invoke the provided function at a different time.<br>
This library enables to extract the "best" API which enables to run a provided function **as soon as possible** based on the currently node.js runtime version.
<a name="usage"></a>
## Usage
```js
//first you must require this library as follows:
var later = require('node-later');
//get a defer function based on current node.js version
var defer = later();
//or get a defer function based on a specific node.js version
defer = later('0.10.0'); //let be compatible with node.js 0.10 regardless of our current node.js runtime
//or get a defer function which is IO safe (will prevent stack overflow errors)
defer = later(true);
//use defer function
defer(onCallback() {
//do something
});
```
<a name="installation"></a>
## Installation
In order to use this library, just run the following npm install command:
```sh
npm install --save {"gitdown": "gitinfo", "name": "name"}
```
{"gitdown": "include", "file": "./README-footer-template.md"}