npm

npm’s 2019 JavaScript ecosystem survey analysis is now available!Get your copy here »

timeout-as-promise

1.0.0 • Public • Published

timeout-as-promise

setTimeout as a native Promise.

npm Version Build Status Test Coverage Dependency Status

Installation

Install using npm:

$ npm install timeout-as-promise

Usage

var delay = require('timeout-as-promise');
 
delay().then(function() {
    console.log('nextTick!');
});
 
delay(5000).then(function() {
    console.log('5 seconds have passed!');
});
 
delay(5000, 'Jim').then(function(value) {
    console.log('my name is ' + value);
});
 
Promise.resolve(42)
    .then(function(result) {
        return delay(150, result);
    })
    .then(function(result) {
        console.log('result is ' + result); //=> 42
    });

License

MIT

install

npm i timeout-as-promise

Downloadsweekly downloads

41,517

version

1.0.0

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability