UNPKG

node-later

Version:

Defer function calls to the start of the next cycle.

53 lines (39 loc) 3.1 kB
# {"gitdown": "gitinfo", "name": "name"} [![NPM Version](http://img.shields.io/npm/v/{"gitdown": "gitinfo", "name": "name"}.svg?style=flat)](https://www.npmjs.org/package/{"gitdown": "gitinfo", "name": "name"}) [![CI](https://github.com/{"gitdown": "gitinfo", "name": "username"}/{"gitdown": "gitinfo", "name": "name"}/workflows/CI/badge.svg?branch=master)](https://github.com/{"gitdown": "gitinfo", "name": "username"}/{"gitdown": "gitinfo", "name": "name"}/actions) [![Coverage Status](https://coveralls.io/repos/{"gitdown": "gitinfo", "name": "username"}/{"gitdown": "gitinfo", "name": "name"}/badge.svg)](https://coveralls.io/r/{"gitdown": "gitinfo", "name": "username"}/{"gitdown": "gitinfo", "name": "name"}) [![Known Vulnerabilities](https://snyk.io/test/github/{"gitdown": "gitinfo", "name": "username"}/{"gitdown": "gitinfo", "name": "name"}/badge.svg)](https://snyk.io/test/github/{"gitdown": "gitinfo", "name": "username"}/{"gitdown": "gitinfo", "name": "name"}) [![Inline docs](http://inch-ci.org/github/{"gitdown": "gitinfo", "name": "username"}/{"gitdown": "gitinfo", "name": "name"}.svg?branch=master)](http://inch-ci.org/github/{"gitdown": "gitinfo", "name": "username"}/{"gitdown": "gitinfo", "name": "name"}) [![License](https://img.shields.io/npm/l/{"gitdown": "gitinfo", "name": "name"}.svg?style=flat)](https://github.com/{"gitdown": "gitinfo", "name": "username"}/{"gitdown": "gitinfo", "name": "name"}/blob/master/LICENSE) [![Total Downloads](https://img.shields.io/npm/dt/{"gitdown": "gitinfo", "name": "name"}.svg?style=flat)](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"}