From 9f57a352bbaba436db11f8885e460eaa81d97b75 Mon Sep 17 00:00:00 2001 From: Caolan McMahon Date: Fri, 28 Mar 2014 15:12:02 +0000 Subject: [PATCH] use internal _isArray function --- lib/async.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/async.js b/lib/async.js index 656802583..7dfef3440 100755 --- a/lib/async.js +++ b/lib/async.js @@ -27,6 +27,10 @@ //// cross-browser compatiblity functions //// + var _isArray = Array.isArray || function (obj) { + return toString.call(obj) === '[object Array]'; + }; + var _each = function (arr, iterator) { if (arr.forEach) { return arr.forEach(iterator); @@ -475,7 +479,7 @@ async.waterfall = function (tasks, callback) { callback = callback || function () {}; - if (tasks.constructor !== Array) { + if (!_isArray(tasks)) { var err = new Error('First argument to waterfall must be an array of functions'); return callback(err); } @@ -508,7 +512,7 @@ var _parallel = function(eachfn, tasks, callback) { callback = callback || function () {}; - if (tasks.constructor === Array) { + if (_isArray(tasks)) { eachfn.map(tasks, function (fn, callback) { if (fn) { fn(function (err) { @@ -548,7 +552,7 @@ async.series = function (tasks, callback) { callback = callback || function () {}; - if (tasks.constructor === Array) { + if (_isArray(tasks)) { async.mapSeries(tasks, function (fn, callback) { if (fn) { fn(function (err) { @@ -678,7 +682,7 @@ concurrency = 1; } function _insert(q, data, pos, callback) { - if(data.constructor !== Array) { + if (!_isArray(data)) { data = [data]; } if(data.length == 0) { @@ -764,7 +768,7 @@ drain: null, drained: true, push: function (data, callback) { - if(data.constructor !== Array) { + if (!_isArray(data)) { data = [data]; } _each(data, function(task) {