An open API service indexing awesome lists of open source software.

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.

Awesome Lists containing this project

README

          

# node-later

[![NPM Version](http://img.shields.io/npm/v/node-later.svg?style=flat)](https://www.npmjs.org/package/node-later) [![CI](https://github.com/sagiegurari/node-later/workflows/CI/badge.svg?branch=master)](https://github.com/sagiegurari/node-later/actions) [![Coverage Status](https://coveralls.io/repos/sagiegurari/node-later/badge.svg)](https://coveralls.io/r/sagiegurari/node-later) [![Known Vulnerabilities](https://snyk.io/test/github/sagiegurari/node-later/badge.svg)](https://snyk.io/test/github/sagiegurari/node-later) [![Inline docs](http://inch-ci.org/github/sagiegurari/node-later.svg?branch=master)](http://inch-ci.org/github/sagiegurari/node-later) [![License](https://img.shields.io/npm/l/node-later.svg?style=flat)](https://github.com/sagiegurari/node-later/blob/master/LICENSE) [![Total Downloads](https://img.shields.io/npm/dt/node-later.svg?style=flat)](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.


## 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
});
```


## 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)


## Release History

| 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.