[Pkg-javascript-commits] [node-async] 400/480: use internal _isArray function

Jonas Smedegaard js at moszumanska.debian.org
Fri May 2 08:58:46 UTC 2014


This is an automated email from the git hooks/post-receive script.

js pushed a commit to branch master
in repository node-async.

commit 9f57a352bbaba436db11f8885e460eaa81d97b75
Author: Caolan McMahon <caolan at caolanmcmahon.com>
Date:   Fri Mar 28 15:12:02 2014 +0000

    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 6568025..7dfef34 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) {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-async.git



More information about the Pkg-javascript-commits mailing list