Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Abstracting safe array copy function

  • Loading branch information...
commit 0149597da84fe2fdb5f48b868c69e4ce09b3bbf3 1 parent ef139cb
Brian Cavalier authored December 07, 2011

Showing 1 changed file with 13 additions and 3 deletions. Show diff stats Hide diff stats

  1. 16  wire.js
16  wire.js
@@ -315,11 +315,11 @@ define(['require', 'when', 'wire/base'], function(require, when, basePlugin) {
315 315
             factories.module = moduleFactory;
316 316
             factories.create = instanceFactory;
317 317
             factories.wire   = wireFactory;
318  
-
319  
-            listeners = parent.listeners ? [].concat(parent.listeners) : [];
  318
+            
  319
+            listeners = delegateArray(parent.listeners);// ? [].concat(parent.listeners) : [];
320 320
 
321 321
             // Proxies is an array, have to concat
322  
-            proxies = parent.proxies ? [].concat(parent.proxies) : [];
  322
+            proxies = delegateArray(parent.proxies);// ? [].concat(parent.proxies) : [];
323 323
             proxied = [];
324 324
 
325 325
             modulesToLoad = [];
@@ -1026,6 +1026,16 @@ define(['require', 'when', 'wire/base'], function(require, when, basePlugin) {
1026 1026
         return typeof it == 'function';
1027 1027
     }
1028 1028
 
  1029
+    /**
  1030
+     * Creates a new {Array} with the same contents as array
  1031
+     * @param array {Array}
  1032
+     * @return {Array} a new {Array} with the same contents as array. If array is falsey,
  1033
+     *  returns a new empty {Array}
  1034
+     */
  1035
+    function delegateArray(array) {
  1036
+        return array ? [].concat(array) : [];
  1037
+    }
  1038
+
1029 1039
     // In case Object.create isn't available
1030 1040
     function T() {
1031 1041
     }

0 notes on commit 0149597

Please sign in to comment.
Something went wrong with that request. Please try again.