| Index: src/js/array.js
|
| diff --git a/src/js/array.js b/src/js/array.js
|
| index 80051d5f8e69608e498e84c252f93400e76f4793..2cb2eda9552584a77f02f3f80ce128a4377d78c7 100644
|
| --- a/src/js/array.js
|
| +++ b/src/js/array.js
|
| @@ -1527,7 +1527,14 @@ function getFunction(name, jsBuiltin, len) {
|
| return f;
|
| };
|
|
|
| -var ArrayValues = getFunction("values", null, 0);
|
| +// Array prototype functions that return iterators. They are exposed to the
|
| +// public API via Template::SetIntrinsicDataProperty().
|
| +var IteratorFunctions = {
|
| + "entries": getFunction("entries", null, 0),
|
| + "forEach": getFunction("forEach", ArrayForEach, 1),
|
| + "keys": getFunction("keys", null, 0),
|
| + "values": getFunction("values", null, 0)
|
| +}
|
|
|
| // Set up non-enumerable functions of the Array.prototype object and
|
| // set their names.
|
| @@ -1546,7 +1553,6 @@ utils.InstallFunctions(GlobalArray.prototype, DONT_ENUM, [
|
| "splice", getFunction("splice", ArraySplice, 2),
|
| "sort", getFunction("sort", ArraySort),
|
| "filter", getFunction("filter", ArrayFilter, 1),
|
| - "forEach", getFunction("forEach", ArrayForEach, 1),
|
| "some", getFunction("some", ArraySome, 1),
|
| "every", getFunction("every", ArrayEvery, 1),
|
| "map", getFunction("map", ArrayMap, 1),
|
| @@ -1559,14 +1565,18 @@ utils.InstallFunctions(GlobalArray.prototype, DONT_ENUM, [
|
| "findIndex", getFunction("findIndex", ArrayFindIndex, 1),
|
| "fill", getFunction("fill", ArrayFill, 1),
|
| "includes", getFunction("includes", null, 1),
|
| - "keys", getFunction("keys", null, 0),
|
| - "entries", getFunction("entries", null, 0),
|
| - iteratorSymbol, ArrayValues
|
| + "entries", IteratorFunctions.entries,
|
| + "forEach", IteratorFunctions.forEach,
|
| + "keys", IteratorFunctions.keys,
|
| + iteratorSymbol, IteratorFunctions.values
|
| ]);
|
|
|
| utils.ForEachFunction = GlobalArray.prototype.forEach;
|
|
|
| -%FunctionSetName(ArrayValues, "values");
|
| +%FunctionSetName(IteratorFunctions.entries, "entries");
|
| +%FunctionSetName(IteratorFunctions.forEach, "forEach");
|
| +%FunctionSetName(IteratorFunctions.keys, "keys");
|
| +%FunctionSetName(IteratorFunctions.values, "values");
|
|
|
| %FinishArrayPrototypeSetup(GlobalArray.prototype);
|
|
|
| @@ -1609,7 +1619,7 @@ utils.Export(function(to) {
|
| to.ArrayJoin = ArrayJoin;
|
| to.ArrayPush = ArrayPush;
|
| to.ArrayToString = ArrayToString;
|
| - to.ArrayValues = ArrayValues;
|
| + to.ArrayValues = IteratorFunctions.values,
|
| to.InnerArrayEvery = InnerArrayEvery;
|
| to.InnerArrayFill = InnerArrayFill;
|
| to.InnerArrayFilter = InnerArrayFilter;
|
| @@ -1627,13 +1637,16 @@ utils.Export(function(to) {
|
| });
|
|
|
| %InstallToContext([
|
| + "array_entries_iterator", IteratorFunctions.entries,
|
| + "array_for_each_iterator", IteratorFunctions.forEach,
|
| + "array_keys_iterator", IteratorFunctions.keys,
|
| "array_pop", ArrayPop,
|
| "array_push", ArrayPush,
|
| "array_shift", ArrayShift,
|
| "array_splice", ArraySplice,
|
| "array_slice", ArraySlice,
|
| "array_unshift", ArrayUnshift,
|
| - "array_values_iterator", ArrayValues,
|
| + "array_values_iterator", IteratorFunctions.values,
|
| ]);
|
|
|
| });
|
|
|