Skip to content

Commit

Permalink
ensure iterate is defined
Browse files Browse the repository at this point in the history
  • Loading branch information
marcuswestin committed Apr 20, 2013
1 parent d1513e6 commit c3e12e3
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion asyncEach.js
Expand Up @@ -51,7 +51,9 @@ module.exports = function asyncEach(items, opts) {

module.exports.makeIterator = function(context, iterate) {
// the given iterator may expect arguments (item + i + next), or just (item + i)
if (iterate.length == 2) {
if (!iterate) {
throw new Error('iterate function is undefined')
} else if (iterate.length == 2) {
return function iterator2(item, i, next) {
iterate.call(context, item, next)
}
Expand Down

0 comments on commit c3e12e3

Please sign in to comment.