Comparing version 3.4.2 to 3.7.2
@@ -85,2 +85,6 @@ var util = require('util') | ||
functor.and.not = function(predicate) { | ||
return functor.and(not(predicate)) | ||
} | ||
functor.or = function(fn) { | ||
@@ -99,2 +103,6 @@ var predicate = clauses.pop() | ||
functor.or.not = function(predicate) { | ||
return functor.or(not(predicate)) | ||
} | ||
functor.else = function(predicate) { | ||
@@ -101,0 +109,0 @@ if (fluentState === EXPECT_THEN) { |
{ | ||
"name": "if-async", | ||
"description": "", | ||
"version": "3.4.2", | ||
"version": "3.7.2", | ||
"keywords": [ | ||
@@ -6,0 +6,0 @@ "async" |
@@ -135,2 +135,5 @@ # if-async [![Build Status](https://secure.travis-ci.org/kessler/if-async.png?branch=master)](http://travis-ci.org/kessler/if-async) | ||
#### .and.not(Function) | ||
same as and() only negate the result of the predicate | ||
#### .or(Function) | ||
@@ -142,2 +145,5 @@ ```javascript | ||
#### .or.not(Function) | ||
same as or() only negate the result of the predicate | ||
#### .elseIf(Function) | ||
@@ -151,3 +157,3 @@ ```javascript | ||
#### .elseIf.not(Function) | ||
same as elseIf only negate the result of the predicate | ||
same as elseIf() only negate the result of the predicate | ||
@@ -154,0 +160,0 @@ #### .else(Function) |
55
test.js
@@ -270,2 +270,29 @@ var ifAsync = require('./index.js') | ||
}) | ||
it('ifAsync(p1 = true).and.not(p2 = false).then(c1), should invoke p1 and p2 and c1 and not c2', function (done) { | ||
var c1Invoked = false | ||
var c2Invoked = false | ||
var p1Invoked = false | ||
var p2Invoked = false | ||
ifAsync(function p1(callback) { | ||
p1Invoked = true | ||
callback(null, true) | ||
}).and.not(function p2(callback) { | ||
p2Invoked = true | ||
callback(null, false) | ||
}).then(function c1(callback) { | ||
c1Invoked = true | ||
callback() | ||
}).else(function c2 (callback) { | ||
c2Invoked = true | ||
callback() | ||
})(function(err) { | ||
p1Invoked.should.be.true | ||
p2Invoked.should.be.true | ||
c1Invoked.should.be.true | ||
c2Invoked.should.be.false | ||
done() | ||
}) | ||
}) | ||
}) | ||
@@ -389,2 +416,30 @@ | ||
}) | ||
it('ifAsync(p1 = false).or.not(p2 = false).then(c1), should invoke p1 and p2 and c1 and not c2', function (done) { | ||
var c1Invoked = false | ||
var c2Invoked = false | ||
var p1Invoked = false | ||
var p2Invoked = false | ||
ifAsync(function p1(callback) { | ||
p1Invoked = true | ||
callback(null, false) | ||
}).or.not(function p2(callback) { | ||
p2Invoked = true | ||
callback(null, false) | ||
}).then(function c1(callback) { | ||
c1Invoked = true | ||
callback() | ||
}).else(function c2 (callback) { | ||
c2Invoked = true | ||
callback() | ||
})(function(err) { | ||
p1Invoked.should.be.true | ||
p2Invoked.should.be.true | ||
c1Invoked.should.be.true | ||
c2Invoked.should.be.false | ||
done() | ||
}) | ||
}) | ||
}) | ||
@@ -391,0 +446,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
22542
603
162