diff --git a/Makefile b/Makefile index 5da8c682e..69cd87a19 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,6 @@ RUNTIME_SRC = \ src/runtime/runtime.js \ + src/runtime/spread.js \ src/runtime/url.js \ src/runtime/ModuleStore.js SRC = \ diff --git a/bin/traceur.js b/bin/traceur.js index 546ae3e66..81d7d590c 100644 --- a/bin/traceur.js +++ b/bin/traceur.js @@ -268,17 +268,6 @@ throw $TypeError(x + ' is not an Object'); return x; } - function spread() { - var rv = [], - k = 0; - for (var i = 0; i < arguments.length; i++) { - var valueToSpread = toObject(arguments[i]); - for (var j = 0; j < valueToSpread.length; j++) { - rv[k++] = valueToSpread[j]; - } - } - return rv; - } function superDescriptor(homeObject, name) { var proto = $getPrototypeOf(homeObject); do { @@ -571,7 +560,6 @@ getOwnHashObject: getOwnHashObject, setProperty: setProperty, setupGlobals: setupGlobals, - spread: spread, superCall: superCall, superGet: superGet, superSet: superSet, @@ -581,6 +569,22 @@ typeof: typeOf }; })(typeof global !== 'undefined' ? global : this); +(function() { + 'use strict'; + var toObject = $traceurRuntime.toObject; + function spread() { + var rv = [], + k = 0; + for (var i = 0; i < arguments.length; i++) { + var valueToSpread = toObject(arguments[i]); + for (var j = 0; j < valueToSpread.length; j++) { + rv[k++] = valueToSpread[j]; + } + } + return rv; + } + $traceurRuntime.spread = spread; +})(); (function() { function buildFromEncodedParts(opt_scheme, opt_userInfo, opt_domain, opt_port, opt_path, opt_queryData, opt_fragment) { var out = []; diff --git a/src/runtime/runtime.js b/src/runtime/runtime.js index 1851b1a81..75fcb9773 100644 --- a/src/runtime/runtime.js +++ b/src/runtime/runtime.js @@ -392,17 +392,6 @@ return x; } - function spread() { - var rv = [], k = 0; - for (var i = 0; i < arguments.length; i++) { - var valueToSpread = toObject(arguments[i]); - for (var j = 0; j < valueToSpread.length; j++) { - rv[k++] = valueToSpread[j]; - } - } - return rv; - } - function superDescriptor(homeObject, name) { var proto = $getPrototypeOf(homeObject); do { @@ -743,7 +732,6 @@ getOwnHashObject: getOwnHashObject, setProperty: setProperty, setupGlobals: setupGlobals, - spread: spread, superCall: superCall, superGet: superGet, superSet: superSet, diff --git a/src/runtime/spread.js b/src/runtime/spread.js new file mode 100644 index 000000000..41fc40a48 --- /dev/null +++ b/src/runtime/spread.js @@ -0,0 +1,32 @@ +// Copyright 2014 Traceur Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +(function() { + 'use strict'; + + var toObject = $traceurRuntime.toObject; + + function spread() { + var rv = [], k = 0; + for (var i = 0; i < arguments.length; i++) { + var valueToSpread = toObject(arguments[i]); + for (var j = 0; j < valueToSpread.length; j++) { + rv[k++] = valueToSpread[j]; + } + } + return rv; + } + + $traceurRuntime.spread = spread; +})();