Comparing version 3.3.1 to 3.3.2
@@ -73,3 +73,3 @@ var util = require('util') | ||
functor.and = function(fn) { | ||
var predicate = clauses.shift() | ||
var predicate = clauses.pop() | ||
// logical AND using ifAsync | ||
@@ -86,3 +86,3 @@ clauses.push( | ||
functor.or = function(fn) { | ||
var predicate = clauses.shift() | ||
var predicate = clauses.pop() | ||
// logical OR | ||
@@ -89,0 +89,0 @@ clauses.push( |
{ | ||
"name": "if-async", | ||
"description": "", | ||
"version": "3.3.1", | ||
"version": "3.3.2", | ||
"keywords": [ | ||
@@ -6,0 +6,0 @@ "async" |
64
test.js
@@ -238,2 +238,34 @@ var ifAsync = require('./index.js') | ||
}) | ||
it('ifAsync(p1 = false).then(c1).elseif(p2 = true).and(p3 = true).then(c2) should not invoke c1 and should invoke p1, p2 and p3', function(done) { | ||
var c1Invoked = false | ||
var c2Invoked = false | ||
var p1Invoked = false | ||
var p2Invoked = false | ||
var p3Invoked = false | ||
ifAsync(function p1(callback) { | ||
p1Invoked = true | ||
callback(null, false) | ||
}).then(function c1(callback) { | ||
c1Invoked = true | ||
callback() | ||
}).elseif(function p2(callback) { | ||
p2Invoked = true | ||
callback(null, true) | ||
}).and(function p3(callback) { | ||
p3Invoked = true | ||
callback(null, true) | ||
}).then(function c2(callback) { | ||
c2Invoked = true | ||
callback() | ||
})(function(err) { | ||
p1Invoked.should.be.true | ||
c1Invoked.should.be.false | ||
p2Invoked.should.be.true | ||
p3Invoked.should.be.true | ||
c2Invoked.should.be.true | ||
done() | ||
}) | ||
}) | ||
}) | ||
@@ -325,2 +357,34 @@ | ||
}) | ||
it('ifAsync(p1 = false).then(c1).elseif(p2 = false).or(p3 = true).then(c2) should not invoke c1 and should invoke p1, p2 and p3', function(done) { | ||
var c1Invoked = false | ||
var c2Invoked = false | ||
var p1Invoked = false | ||
var p2Invoked = false | ||
var p3Invoked = false | ||
ifAsync(function p1(callback) { | ||
p1Invoked = true | ||
callback(null, false) | ||
}).then(function c1(callback) { | ||
c1Invoked = true | ||
callback() | ||
}).elseif(function p2(callback) { | ||
p2Invoked = true | ||
callback(null, false) | ||
}).or(function p3(callback) { | ||
p3Invoked = true | ||
callback(null, true) | ||
}).then(function c2(callback) { | ||
c2Invoked = true | ||
callback() | ||
})(function(err) { | ||
p1Invoked.should.be.true | ||
c1Invoked.should.be.false | ||
p2Invoked.should.be.true | ||
p3Invoked.should.be.true | ||
c2Invoked.should.be.true | ||
done() | ||
}) | ||
}) | ||
}) | ||
@@ -327,0 +391,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
18892
480