https://github.com/sagiegurari/node-later
Defer function calls to the start of the next cycle.
https://github.com/sagiegurari/node-later
async defer delay nodejs settimeout
Last synced: 12 months ago
JSON representation
Defer function calls to the start of the next cycle.
- Host: GitHub
- URL: https://github.com/sagiegurari/node-later
- Owner: sagiegurari
- License: apache-2.0
- Created: 2017-04-28T14:08:50.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2023-01-19T17:37:29.000Z (about 3 years ago)
- Last Synced: 2025-04-10T19:27:15.344Z (12 months ago)
- Topics: async, defer, delay, nodejs, settimeout
- Language: JavaScript
- Size: 123 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: .github/CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# node-later
[](https://www.npmjs.org/package/node-later) [](https://github.com/sagiegurari/node-later/actions) [](https://coveralls.io/r/sagiegurari/node-later) [](https://snyk.io/test/github/sagiegurari/node-later) [](http://inch-ci.org/github/sagiegurari/node-later) [](https://github.com/sagiegurari/node-later/blob/master/LICENSE) [](https://www.npmjs.org/package/node-later)
> 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)
## Overview
Invoke functions in the next cycle.
You have multiple node.js APIs to run a function later, for example process.nextTick, setImmediate and setTimeout.
Each of those will invoke the provided function at a different time.
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.
```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
});
```
## Installation
In order to use this library, just run the following npm install command:
```sh
npm install --save node-later
```
## API Documentation
See full docs at: [API Docs](docs/api.md)
## Contributing
See [contributing guide](.github/CONTRIBUTING.md)
| Date | Version | Description |
| ----------- | ------- | ----------- |
| 2020-05-11 | v2.0.0 | Migrate to github actions and upgrade minimal node version |
| 2019-12-16 | v1.0.16 | Maintenance |
| 2017-04-28 | v1.0.0 | Offical release |
| 2017-04-28 | v0.0.1 | Initial release |
## License
Developed by Sagie Gur-Ari and licensed under the Apache 2 open source license.