fallback
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -33,3 +33,3 @@ module.exports = function fallback(array, iteratorFunction, outerCallback) { | ||
if (!array.length) { | ||
callback() | ||
return callback() | ||
} | ||
@@ -44,2 +44,2 @@ var arr = array.slice() | ||
}) | ||
} | ||
} |
{ | ||
"name": "fallback", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "retry a function with a series of arguments until one works", | ||
@@ -20,2 +20,3 @@ "main": "index.js", | ||
"author": "jden <jason@denizac.org>", | ||
"contributors": ["jden <jason@denizac.org>", "Nathan Peck <nathan@storydesk.com>"], | ||
"license": "MIT", | ||
@@ -22,0 +23,0 @@ "devDependencies": { |
@@ -85,5 +85,10 @@ # fallback | ||
## contributors | ||
- jden <jason@denizac.org> | ||
- Nathan Peck <nathan@storydesk.com> | ||
## license | ||
MIT | ||
(c) 2012 jden - Jason Denizac <jason@denizac.org | ||
(c) MMXIII jden - Jason Denizac <jason@denizac.org> | ||
http://jden.mit-license.org/2012 |
@@ -18,5 +18,2 @@ var test = require('tape') | ||
}) | ||
}) | ||
@@ -37,4 +34,2 @@ | ||
}) | ||
}) | ||
@@ -60,2 +55,21 @@ | ||
}) | ||
}) | ||
test('if no items in the fallback sequence succeed it returns false', function (t) { | ||
t.plan(2) | ||
var iterations = 0 | ||
var tried = [] | ||
fallback([1,3,4,5], function (item, cb) { | ||
iterations++ | ||
if (item == 2) { | ||
return cb(null, item) | ||
} | ||
cb() | ||
}, function (err, result) { | ||
t.equal(iterations, 4) | ||
t.equal(result, false) | ||
t.end() | ||
}) | ||
}) |
7067
119
93