Comparing version 3.7.3 to 3.7.4
21
index.js
@@ -79,3 +79,3 @@ var util = require('util') | ||
.then(fn) | ||
.else(elseFalse) | ||
.else(callbackFalse) | ||
) | ||
@@ -95,6 +95,6 @@ | ||
ifAsync(predicate) | ||
.then(elseTrue) | ||
.then(callbackTrue) | ||
.elseIf(fn) | ||
.then(elseTrue) | ||
.else(elseFalse) | ||
.then(callbackTrue) | ||
.else(callbackFalse) | ||
) | ||
@@ -162,3 +162,6 @@ return functor | ||
function elseNoop() { | ||
var callback = arguments[arguments.length - 1] | ||
var args = toArray(arguments) | ||
var callback = args.pop() | ||
args.unshift(null) | ||
if (typeof callback !== 'function') { | ||
@@ -168,6 +171,8 @@ throw new Error('expected a callback function') | ||
setImmediate(callback) | ||
setImmediate(function () { | ||
callback.apply(null, args) | ||
}) | ||
} | ||
function elseTrue() { | ||
function callbackTrue() { | ||
var callback = arguments[arguments.length - 1] | ||
@@ -181,3 +186,3 @@ if (typeof callback !== 'function') { | ||
function elseFalse() { | ||
function callbackFalse() { | ||
var callback = arguments[arguments.length - 1] | ||
@@ -184,0 +189,0 @@ if (typeof callback !== 'function') { |
{ | ||
"name": "if-async", | ||
"description": "", | ||
"version": "3.7.3", | ||
"version": "3.7.4", | ||
"keywords": [ | ||
@@ -6,0 +6,0 @@ "async" |
19
test.js
@@ -445,3 +445,3 @@ var ifAsync = require('./index.js') | ||
it('carry arguments', function (done) { | ||
it('carry arguments from "then" consequent', function (done) { | ||
ifAsync(function(a, b, callback) { | ||
@@ -462,2 +462,19 @@ a.should.eql(1) | ||
it('carry arguments from default "else" consequent', function (done) { | ||
ifAsync(function(a, b, callback) { | ||
a.should.eql(1) | ||
b.should.eql(2) | ||
callback(null, false) | ||
}) | ||
.then(function(a, b, callback) { | ||
a.should.eql(1) | ||
b.should.eql(2) | ||
callback(null, 3) | ||
})(1, 2, function (err, a, b) { | ||
a.should.eql(1) | ||
b.should.eql(2) | ||
done() | ||
}) | ||
}) | ||
it('has a negation operator for predicates', function (done) { | ||
@@ -464,0 +481,0 @@ var p1Invoked = false |
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
23422
635