timeout-as-promise
v1.0.0
Published
setTimeout as a native Promise
Downloads
91,923
Maintainers
Readme
timeout-as-promise
setTimeout
as a native Promise
.
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