Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist
View async-1-a.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14
 
var Q = require("events");
 
exports.and = function (a, b) {
return Q.when(a, function (a) {
return Q.when(b, function (b) {
return a && b;
});
});
};
 
Q.when(exports.and(true, true), function (and) {
print(and);
});
View async-1-a.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
 
var Q = require("events");
 
exports.and = function (a, b) {
return Q.when(a, function (a) {
return Q.when(b, function (b) {
return a && b;
});
});
};
 
var a = Q.defer();
var b = Q.defer();
 
Q.when(exports.and(a.promise, b.promise), function (and) {
print(and);
});
 
a.resolve(true);
b.resolve(false);
View async-1-a.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
 
var Q = require("events");
 
exports.and = function (a, b) {
return Q.when(a, function (a) {
return Q.when(b, function (b) {
return a && b;
});
});
};
 
exports.all = function (values) {
return values.reduce(function (a, b) {
return exports.and(a, b);
});
};
 
Q.when(exports.all([true, true, true]), function (and) {
print(and);
});
View async-1-a.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
 
var Q = require("events");
 
exports.and = function (a, b) {
return Q.when(a, function (a) {
return Q.when(b, function (b) {
return a && b;
});
});
};
 
exports.all = function (values) {
return values.reduce(function (a, b) {
return exports.and(a, b);
});
};
 
var deferred = Q.defer();
 
Q.when(exports.all([true, deferred.promise, true]), function (and) {
print(and);
});
 
deferred.resolve(false);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.