[Pkg-javascript-commits] [sockjs-client] 108/350: Update shims to es5-shim. Shim forEach. More global prefixes.

tonnerre at ancient-solutions.com tonnerre at ancient-solutions.com
Fri Aug 5 01:03:48 UTC 2016


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

tonnerre-guest pushed a commit to branch upstream
in repository sockjs-client.

commit f963b831a0c82a4842616d1c8cc74695fba27321
Author: Bryce Kahle <bkahle at gmail.com>
Date:   Fri Oct 10 12:58:28 2014 -0400

    Update shims to es5-shim. Shim forEach. More global prefixes.
---
 .eslintrc                             |   4 -
 lib/iframe-bootstrap.js               |   7 +-
 lib/main.js                           |  12 +-
 lib/polyfills/eventtarget.js          |  13 +-
 lib/shims.js                          | 377 ++++++++++++++++++++++++++--------
 lib/transport/browser/websocket.js    |   2 +-
 lib/transport/driver/websocket.js     |   2 +-
 lib/transport/lib/ajax-based.js       |   2 +-
 lib/transport/receiver/eventsource.js |   2 +-
 lib/transport/receiver/htmlfile.js    |   2 +-
 lib/transport/receiver/xhr.js         |  10 +-
 lib/transport/sender/xhr-cors.js      |   6 +-
 lib/transport/sender/xhr-fake.js      |   2 +-
 lib/transport/sender/xhr-local.js     |   2 +-
 lib/transports.js                     |   9 +-
 15 files changed, 327 insertions(+), 125 deletions(-)

diff --git a/.eslintrc b/.eslintrc
index d4a02a7..07dea7d 100644
--- a/.eslintrc
+++ b/.eslintrc
@@ -10,10 +10,6 @@
     "no-underscore-dangle": [0]
   },
   "globals": {
-    "XDomainRequest": true,
-    "XMLHttpRequest": true,
-    "EventSource": true,
-    "ActiveXObject": true,
     "describe": true,
     "before": true,
     "it": true
diff --git a/lib/iframe-bootstrap.js b/lib/iframe-bootstrap.js
index b38ebf2..2f8954f 100644
--- a/lib/iframe-bootstrap.js
+++ b/lib/iframe-bootstrap.js
@@ -11,9 +11,10 @@ var originUtils = require('./utils/origin')
 
 module.exports = function (SockJS, facadeTransports) {
   var transportMap = {};
-  for (var i = 0; i < facadeTransports.length; i++) {
-    transportMap[facadeTransports[i].transportName] = facadeTransports[i];
-  }
+  facadeTransports.forEach(function (ft) {
+    transportMap[ft.transportName] = ft;
+  });
+
   // hard-coded for the info iframe
   // TODO see if we can make this more dynamic
   transportMap[InfoIframeFacade.transportName] = InfoIframeFacade;
diff --git a/lib/main.js b/lib/main.js
index 5aa38fa..00b721b 100644
--- a/lib/main.js
+++ b/lib/main.js
@@ -59,15 +59,14 @@ function SockJS(url, protocols, transportsWhitelist) {
 
   // Step 5 - check protocols argument
   var sortedProtocols = protocols.sort();
-  for (var i = 0; i < sortedProtocols.length; i++) {
-    var proto = sortedProtocols[i];
+  sortedProtocols.forEach(function (proto, i) {
     if (!proto) {
       throw new SyntaxError("The protocols entry '" + proto + "' is invalid.");
     }
     if (i < (sortedProtocols.length - 1) && proto === sortedProtocols[i + 1]) {
       throw new SyntaxError("The protocols entry '" + proto + "' is duplicated.");
     }
-  }
+  });
 
   // Step 6 - convert origin
   this._origin = loc.origin ? loc.origin.toLowerCase() : null;
@@ -188,6 +187,7 @@ SockJS.prototype._transportTimeout = function() {
 };
 
 SockJS.prototype._transportMessage = function(e) {
+  var self = this;
   var type = e.data.slice(0, 1);
   var payload;
   switch (type) {
@@ -196,9 +196,9 @@ SockJS.prototype._transportMessage = function(e) {
       break;
     case 'a':
       payload = JSON3.parse(e.data.slice(1) || '[]');
-      for (var i = 0; i < payload.length; i++){
-        this._dispatchMessage(payload[i]);
-      }
+      payload.forEach(function (p) {
+        self._dispatchMessage(p);
+      });
       break;
     case 'm':
       payload = JSON3.parse(e.data.slice(1) || 'null');
diff --git a/lib/polyfills/eventtarget.js b/lib/polyfills/eventtarget.js
index b6d5336..8f955cc 100644
--- a/lib/polyfills/eventtarget.js
+++ b/lib/polyfills/eventtarget.js
@@ -4,15 +4,6 @@
  *   http://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-EventTarget
  */
 
-function arrayIndexOf(arr, item) {
-  for (var i = 0; i < arr.length; i++) {
-    if (arr[i] === item) {
-      return i;
-    }
-  }
-  return -1;
-}
-
 var EventTarget = function() {
   this._listeners = {};
 };
@@ -22,7 +13,7 @@ EventTarget.prototype.addEventListener = function (eventType, listener) {
     this._listeners[eventType] = [];
   }
   var arr = this._listeners[eventType];
-  if (arrayIndexOf(arr, listener) === -1) {
+  if (arr.indexOf(listener) === -1) {
     // Make a copy so as not to interfere with a current dispatchEvent.
     arr = arr.concat([listener]);
   }
@@ -35,7 +26,7 @@ EventTarget.prototype.removeEventListener = function (eventType, listener) {
     return;
   }
   var arr = this._listeners[eventType];
-  var idx = arrayIndexOf(arr, listener);
+  var idx = arr.indexOf(listener);
   if (idx !== -1) {
     if (arr.length > 1) {
       // Make a copy so as not to interfere with a current dispatchEvent.
diff --git a/lib/shims.js b/lib/shims.js
index b8e980d..3855b86 100644
--- a/lib/shims.js
+++ b/lib/shims.js
@@ -1,105 +1,322 @@
+/* eslint-disable */
 'use strict';
 
-if (!Date.now) {
-  Date.now = function now() {
-    return new Date().getTime();
-  };
+// pulled specific shims from https://github.com/es-shims/es5-shim
+
+var ArrayPrototype = Array.prototype;
+var ObjectPrototype = Object.prototype;
+var FunctionPrototype = Function.prototype;
+var array_slice = ArrayPrototype.slice;
+
+var _toString = ObjectPrototype.toString;
+var isFunction = function (val) {
+    return ObjectPrototype.toString.call(val) === '[object Function]';
+};
+var isArray = function isArray(obj) {
+    return _toString.call(obj) === '[object Array]';
+};
+var isString = function isString(obj) {
+    return _toString.call(obj) === '[object String]';
+};
+
+var supportsDescriptors = Object.defineProperty && (function () {
+    try {
+        Object.defineProperty({}, 'x', {});
+        return true;
+    } catch (e) { /* this is ES3 */
+        return false;
+    }
+}());
+
+// Define configurable, writable and non-enumerable props
+// if they don't exist.
+var defineProperty;
+if (supportsDescriptors) {
+    defineProperty = function (object, name, method, forceAssign) {
+        if (!forceAssign && (name in object)) { return; }
+        Object.defineProperty(object, name, {
+            configurable: true,
+            enumerable: false,
+            writable: true,
+            value: method
+        });
+    };
+} else {
+    defineProperty = function (object, name, method, forceAssign) {
+        if (!forceAssign && (name in object)) { return; }
+        object[name] = method;
+    };
 }
+var defineProperties = function (object, map, forceAssign) {
+    for (var name in map) {
+        if (ObjectPrototype.hasOwnProperty.call(map, name)) {
+          defineProperty(object, name, map[name], forceAssign);
+        }
+    }
+};
 
-if (!Function.prototype.bind) {
-  /* eslint no-extend-native: 0 */
-  Function.prototype.bind = function (oThis) {
-    if (typeof this !== 'function') {
-      // closest thing possible to the ECMAScript 5
-      // internal IsCallable function
-      throw new TypeError('Function.prototype.bind - what is trying to be bound is not callable');
+var toObject = function (o) {
+    if (o == null) { // this matches both null and undefined
+        throw new TypeError("can't convert " + o + ' to object');
     }
+    return Object(o);
+};
 
-    var aArgs = Array.prototype.slice.call(arguments, 1),
-        self = this,
-        NOP = function () {},
-        Bound = function () {
-          return self.apply(this instanceof NOP && oThis
-                 ? this
-                 : oThis,
-                 aArgs.concat(Array.prototype.slice.call(arguments)));
-        };
+//
+// Util
+// ======
+//
 
-    NOP.prototype = this.prototype;
-    Bound.prototype = new NOP();
+// ES5 9.4
+// http://es5.github.com/#x9.4
+// http://jsperf.com/to-integer
 
-    return Bound;
-  };
+function toInteger(num) {
+    var n = +num;
+    if (n !== n) { // isNaN
+        n = 0;
+    } else if (n !== 0 && n !== (1 / 0) && n !== -(1 / 0)) {
+        n = (n > 0 || -1) * Math.floor(Math.abs(n));
+    }
+    return n;
 }
 
-if (!Array.isArray) {
-  Array.isArray = function(arg) {
-    return Object.prototype.toString.call(arg) === '[object Array]';
-  };
-}
+//
+// Function
+// ========
+//
 
-// Production steps of ECMA-262, Edition 5, 15.4.4.14
-// Reference: http://es5.github.io/#x15.4.4.14
-if (!Array.prototype.indexOf) {
-  Array.prototype.indexOf = function(searchElement, fromIndex) {
+// ES-5 15.3.4.5
+// http://es5.github.com/#x15.3.4.5
 
-    var k;
+function Empty() {}
 
-    // 1. Let O be the result of calling ToObject passing
-    //    the this value as the argument.
-    if (this == null) {
-      throw new TypeError('"this" is null or not defined');
-    }
+defineProperties(FunctionPrototype, {
+    bind: function bind(that) { // .length is 1
+        // 1. Let Target be the this value.
+        var target = this;
+        // 2. If IsCallable(Target) is false, throw a TypeError exception.
+        if (!isFunction(target)) {
+            throw new TypeError('Function.prototype.bind called on incompatible ' + target);
+        }
+        // 3. Let A be a new (possibly empty) internal list of all of the
+        //   argument values provided after thisArg (arg1, arg2 etc), in order.
+        // XXX slicedArgs will stand in for "A" if used
+        var args = array_slice.call(arguments, 1); // for normal call
+        // 4. Let F be a new native ECMAScript object.
+        // 11. Set the [[Prototype]] internal property of F to the standard
+        //   built-in Function prototype object as specified in 15.3.3.1.
+        // 12. Set the [[Call]] internal property of F as described in
+        //   15.3.4.5.1.
+        // 13. Set the [[Construct]] internal property of F as described in
+        //   15.3.4.5.2.
+        // 14. Set the [[HasInstance]] internal property of F as described in
+        //   15.3.4.5.3.
+        var binder = function () {
+
+            if (this instanceof bound) {
+                // 15.3.4.5.2 [[Construct]]
+                // When the [[Construct]] internal method of a function object,
+                // F that was created using the bind function is called with a
+                // list of arguments ExtraArgs, the following steps are taken:
+                // 1. Let target be the value of F's [[TargetFunction]]
+                //   internal property.
+                // 2. If target has no [[Construct]] internal method, a
+                //   TypeError exception is thrown.
+                // 3. Let boundArgs be the value of F's [[BoundArgs]] internal
+                //   property.
+                // 4. Let args be a new list containing the same values as the
+                //   list boundArgs in the same order followed by the same
+                //   values as the list ExtraArgs in the same order.
+                // 5. Return the result of calling the [[Construct]] internal
+                //   method of target providing args as the arguments.
+
+                var result = target.apply(
+                    this,
+                    args.concat(array_slice.call(arguments))
+                );
+                if (Object(result) === result) {
+                    return result;
+                }
+                return this;
+
+            } else {
+                // 15.3.4.5.1 [[Call]]
+                // When the [[Call]] internal method of a function object, F,
+                // which was created using the bind function is called with a
+                // this value and a list of arguments ExtraArgs, the following
+                // steps are taken:
+                // 1. Let boundArgs be the value of F's [[BoundArgs]] internal
+                //   property.
+                // 2. Let boundThis be the value of F's [[BoundThis]] internal
+                //   property.
+                // 3. Let target be the value of F's [[TargetFunction]] internal
+                //   property.
+                // 4. Let args be a new list containing the same values as the
+                //   list boundArgs in the same order followed by the same
+                //   values as the list ExtraArgs in the same order.
+                // 5. Return the result of calling the [[Call]] internal method
+                //   of target providing boundThis as the this value and
+                //   providing args as the arguments.
+
+                // equiv: target.call(this, ...boundArgs, ...args)
+                return target.apply(
+                    that,
+                    args.concat(array_slice.call(arguments))
+                );
+
+            }
+
+        };
 
-    var O = Object(this);
+        // 15. If the [[Class]] internal property of Target is "Function", then
+        //     a. Let L be the length property of Target minus the length of A.
+        //     b. Set the length own property of F to either 0 or L, whichever is
+        //       larger.
+        // 16. Else set the length own property of F to 0.
 
-    // 2. Let lenValue be the result of calling the Get
-    //    internal method of O with the argument "length".
-    // 3. Let len be ToUint32(lenValue).
-    var len = O.length >>> 0;
+        var boundLength = Math.max(0, target.length - args.length);
 
-    // 4. If len is 0, return -1.
-    if (len === 0) {
-      return -1;
+        // 17. Set the attributes of the length own property of F to the values
+        //   specified in 15.3.5.1.
+        var boundArgs = [];
+        for (var i = 0; i < boundLength; i++) {
+            boundArgs.push('$' + i);
+        }
+
+        // XXX Build a dynamic function with desired amount of arguments is the only
+        // way to set the length property of a function.
+        // In environments where Content Security Policies enabled (Chrome extensions,
+        // for ex.) all use of eval or Function costructor throws an exception.
+        // However in all of these environments Function.prototype.bind exists
+        // and so this code will never be executed.
+        var bound = Function('binder', 'return function (' + boundArgs.join(',') + '){ return binder.apply(this, arguments); }')(binder);
+
+        if (target.prototype) {
+            Empty.prototype = target.prototype;
+            bound.prototype = new Empty();
+            // Clean up dangling references.
+            Empty.prototype = null;
+        }
+
+        // TODO
+        // 18. Set the [[Extensible]] internal property of F to true.
+
+        // TODO
+        // 19. Let thrower be the [[ThrowTypeError]] function Object (13.2.3).
+        // 20. Call the [[DefineOwnProperty]] internal method of F with
+        //   arguments "caller", PropertyDescriptor {[[Get]]: thrower, [[Set]]:
+        //   thrower, [[Enumerable]]: false, [[Configurable]]: false}, and
+        //   false.
+        // 21. Call the [[DefineOwnProperty]] internal method of F with
+        //   arguments "arguments", PropertyDescriptor {[[Get]]: thrower,
+        //   [[Set]]: thrower, [[Enumerable]]: false, [[Configurable]]: false},
+        //   and false.
+
+        // TODO
+        // NOTE Function objects created using Function.prototype.bind do not
+        // have a prototype property or the [[Code]], [[FormalParameters]], and
+        // [[Scope]] internal properties.
+        // XXX can't delete prototype in pure-js.
+
+        // 22. Return F.
+        return bound;
     }
+});
+
+//
+// Array
+// =====
+//
+
+// ES5 15.4.3.2
+// http://es5.github.com/#x15.4.3.2
+// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/isArray
+defineProperties(Array, { isArray: isArray });
+
 
-    // 5. If argument fromIndex was passed let n be
-    //    ToInteger(fromIndex); else let n be 0.
-    var n = +fromIndex || 0;
+var boxedString = Object('a');
+var splitString = boxedString[0] !== 'a' || !(0 in boxedString);
 
-    if (Math.abs(n) === Infinity) {
-      n = 0;
+var properlyBoxesContext = function properlyBoxed(method) {
+    // Check node 0.6.21 bug where third parameter is not boxed
+    var properlyBoxesNonStrict = true;
+    var properlyBoxesStrict = true;
+    if (method) {
+        method.call('foo', function (_, __, context) {
+            if (typeof context !== 'object') { properlyBoxesNonStrict = false; }
+        });
+
+        method.call([1], function () {
+            'use strict';
+            properlyBoxesStrict = typeof this === 'string';
+        }, 'x');
     }
+    return !!method && properlyBoxesNonStrict && properlyBoxesStrict;
+};
+
+defineProperties(ArrayPrototype, {
+    forEach: function forEach(fun /*, thisp*/) {
+        var object = toObject(this),
+            self = splitString && isString(this) ? this.split('') : object,
+            thisp = arguments[1],
+            i = -1,
+            length = self.length >>> 0;
+
+        // If no callback function or if callback is not a callable function
+        if (!isFunction(fun)) {
+            throw new TypeError(); // TODO message
+        }
 
-    // 6. If n >= len, return -1.
-    if (n >= len) {
-      return -1;
+        while (++i < length) {
+            if (i in self) {
+                // Invoke the callback function with call, passing arguments:
+                // context, property value, property key, thisArg object
+                // context
+                fun.call(thisp, self[i], i, object);
+            }
+        }
     }
+}, !properlyBoxesContext(ArrayPrototype.forEach));
+
+// ES5 15.4.4.14
+// http://es5.github.com/#x15.4.4.14
+// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/indexOf
+var hasFirefox2IndexOfBug = Array.prototype.indexOf && [0, 1].indexOf(1, 2) !== -1;
+defineProperties(ArrayPrototype, {
+    indexOf: function indexOf(sought /*, fromIndex */ ) {
+        var self = splitString && isString(this) ? this.split('') : toObject(this),
+            length = self.length >>> 0;
+
+        if (!length) {
+            return -1;
+        }
 
-    // 7. If n >= 0, then Let k be n.
-    // 8. Else, n<0, Let k be len - abs(n).
-    //    If k is less than 0, then let k be 0.
-    k = Math.max(n >= 0 ? n : len - Math.abs(n), 0);
-
-    // 9. Repeat, while k < len
-    while (k < len) {
-      // a. Let Pk be ToString(k).
-      //   This is implicit for LHS operands of the in operator
-      // b. Let kPresent be the result of calling the
-      //    HasProperty internal method of O with argument Pk.
-      //   This step can be combined with c
-      // c. If kPresent is true, then
-      //    i.  Let elementK be the result of calling the Get
-      //        internal method of O with the argument ToString(k).
-      //   ii.  Let same be the result of applying the
-      //        Strict Equality Comparison Algorithm to
-      //        searchElement and elementK.
-      //  iii.  If same is true, return k.
-      if (k in O && O[k] === searchElement) {
-        return k;
-      }
-      k++;
+        var i = 0;
+        if (arguments.length > 1) {
+            i = toInteger(arguments[1]);
+        }
+
+        // handle negative indices
+        i = i >= 0 ? i : Math.max(0, length + i);
+        for (; i < length; i++) {
+            if (i in self && self[i] === sought) {
+                return i;
+            }
+        }
+        return -1;
     }
-    return -1;
-  };
+}, hasFirefox2IndexOfBug);
+
+//
+// Date
+// ====
+//
+
+// ES5 15.9.4.4
+// http://es5.github.com/#x15.9.4.4
+if (!Date.now) {
+    Date.now = function now() {
+        return new Date().getTime();
+    };
 }
diff --git a/lib/transport/browser/websocket.js b/lib/transport/browser/websocket.js
index 0885203..b98b3b9 100644
--- a/lib/transport/browser/websocket.js
+++ b/lib/transport/browser/websocket.js
@@ -1 +1 @@
-module.exports = global.WebSocket || global.MozWebSocket;
\ No newline at end of file
+module.exports = global.WebSocket || global.MozWebSocket;
diff --git a/lib/transport/driver/websocket.js b/lib/transport/driver/websocket.js
index d473885..82903af 100644
--- a/lib/transport/driver/websocket.js
+++ b/lib/transport/driver/websocket.js
@@ -1 +1 @@
-module.exports = require('faye-websocket').Client;
\ No newline at end of file
+module.exports = require('faye-websocket').Client;
diff --git a/lib/transport/lib/ajax-based.js b/lib/transport/lib/ajax-based.js
index f70190f..03b37b0 100644
--- a/lib/transport/lib/ajax-based.js
+++ b/lib/transport/lib/ajax-based.js
@@ -27,7 +27,7 @@ function createAjaxSender(AjaxObject) {
 function AjaxBasedTransport(transUrl, urlSuffix, Receiver, AjaxObject) {
   var self = this;
   BufferedSender.call(this, transUrl, createAjaxSender(AjaxObject));
-  
+
   this.poll = new Polling(Receiver, transUrl + urlSuffix, AjaxObject);
   this.poll.onmessage = this.poll.onclose = function (e) {
     self.dispatchEvent(e);
diff --git a/lib/transport/receiver/eventsource.js b/lib/transport/receiver/eventsource.js
index 74897b3..b15a607 100644
--- a/lib/transport/receiver/eventsource.js
+++ b/lib/transport/receiver/eventsource.js
@@ -9,7 +9,7 @@ function EventSourceReceiver(url) {
   EventTarget.call(this);
 
   var self = this;
-  var es = new EventSource(url);
+  var es = new global.EventSource(url);
   es.onmessage = function(e) {
     self.dispatchEvent(new SimpleEvent('message', {'data': decodeURI(e.data)}));
   };
diff --git a/lib/transport/receiver/htmlfile.js b/lib/transport/receiver/htmlfile.js
index 7db4e60..a8026cf 100644
--- a/lib/transport/receiver/htmlfile.js
+++ b/lib/transport/receiver/htmlfile.js
@@ -12,7 +12,7 @@ var isIeHtmlfileCapable = function() {
   if (_isIeHtmlfileCapable === undefined) {
     if ('ActiveXObject' in global) {
       try {
-        _isIeHtmlfileCapable = !!new ActiveXObject('htmlfile');
+        _isIeHtmlfileCapable = !!new global.ActiveXObject('htmlfile');
       } catch (x) {}
     } else {
       _isIeHtmlfileCapable = false;
diff --git a/lib/transport/receiver/xhr.js b/lib/transport/receiver/xhr.js
index 3f3afb8..7721a39 100644
--- a/lib/transport/receiver/xhr.js
+++ b/lib/transport/receiver/xhr.js
@@ -26,14 +26,14 @@ XhrReceiver.prototype._chunkHandler = function (status, text) {
     return;
   }
 
+  var self = this;
   var messages = text.split('\n');
-  for (var i = 0; i < messages.length; i++) {
-    var msg = messages[i];
+  messages.forEach(function (msg) {
     if (!msg) {
-      continue;
+      return;
     }
-    this.dispatchEvent(new SimpleEvent('message', {data: msg}));
-  }
+    self.dispatchEvent(new SimpleEvent('message', {data: msg}));
+  });
 };
 
 XhrReceiver.prototype.abort = function() {
diff --git a/lib/transport/sender/xhr-cors.js b/lib/transport/sender/xhr-cors.js
index cfc9bb4..0ab0ece 100644
--- a/lib/transport/sender/xhr-cors.js
+++ b/lib/transport/sender/xhr-cors.js
@@ -5,11 +5,9 @@ var util = require('util')
   ;
 
 function XHRCorsObject(method, url, payload, opts) {
-  var self = this
-    , args = arguments
-    ;
+  var self = this;
   process.nextTick(function(){
-    XhrDriver.apply(self, args);
+    XhrDriver.call(self, method, url, payload, opts);
   });
 }
 
diff --git a/lib/transport/sender/xhr-fake.js b/lib/transport/sender/xhr-fake.js
index 6d32462..af2996d 100644
--- a/lib/transport/sender/xhr-fake.js
+++ b/lib/transport/sender/xhr-fake.js
@@ -4,7 +4,7 @@ var EventEmitter = require('events').EventEmitter
   , util = require('util')
   ;
 
-function XHRFake(method, url, payload, opts) {
+function XHRFake(/* method, url, payload, opts */) {
   var self = this;
   EventEmitter.call(this);
 
diff --git a/lib/transport/sender/xhr-local.js b/lib/transport/sender/xhr-local.js
index f047941..9b841b7 100644
--- a/lib/transport/sender/xhr-local.js
+++ b/lib/transport/sender/xhr-local.js
@@ -4,7 +4,7 @@ var util = require('util')
   , XhrDriver = require('../driver/xhr')
   ;
 
-function XHRLocalObject(method, url, payload) {
+function XHRLocalObject(method, url, payload /*, opts */) {
   var self = this;
   process.nextTick(function(){
     XhrDriver.call(self, method, url, payload, {
diff --git a/lib/transports.js b/lib/transports.js
index 4b372f4..0364b0c 100644
--- a/lib/transports.js
+++ b/lib/transports.js
@@ -10,15 +10,14 @@ module.exports = function (availableTransports) {
       transportsWhitelist = [];
     }
 
-    for (var i = 0; i < availableTransports.length; i++) {
-      var trans = availableTransports[i];
+    availableTransports.forEach(function (trans) {
       if (!trans) {
-        continue;
+        return;
       }
 
       if (transportsWhitelist.length &&
           transportsWhitelist.indexOf(trans.transportName) === -1) {
-        continue;
+        return;
       }
 
       if (trans.enabled(url, info)) {
@@ -27,7 +26,7 @@ module.exports = function (availableTransports) {
           transports.facade.push(trans.facadeTransport);
         }
       }
-    }
+    });
     return transports;
   };
 };

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



More information about the Pkg-javascript-commits mailing list