Skip to content

Instantly share code, notes, and snippets.

@ghiden
Created June 25, 2015 20:00
Show Gist options
  • Save ghiden/d5f12108d9e2e7503bc5 to your computer and use it in GitHub Desktop.
Save ghiden/d5f12108d9e2e7503bc5 to your computer and use it in GitHub Desktop.
Q delay behavior
var Q = require('q');
function test() {
var d = Q.defer();
setTimeout(function() {
d.reject(new Error('failed'));
}, 500);
return d.promise;
}
var result = test().delay(1000);
console.log(result);
setTimeout(function() {
console.log(result);
}, 800);
setTimeout(function() {
console.log(result);
}, 1500);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment