| Index: src/array.js
|
| diff --git a/src/array.js b/src/array.js
|
| index dc0b65fc1d0c2d91898322bfde92f9c58e60fbe5..3f9bd68bbf483bd0c8b42472905ebf9237af13e5 100644
|
| --- a/src/array.js
|
| +++ b/src/array.js
|
| @@ -10,6 +10,8 @@ var $arrayShift;
|
| var $arraySlice;
|
| var $arraySplice;
|
| var $arrayUnshift;
|
| +var $innerArrayForEach;
|
| +var $innerArrayEvery;
|
|
|
| (function(global, shared, exports) {
|
|
|
| @@ -1179,15 +1181,7 @@ function ArrayFilter(f, receiver) {
|
| return result;
|
| }
|
|
|
| -
|
| -function ArrayForEach(f, receiver) {
|
| - CHECK_OBJECT_COERCIBLE(this, "Array.prototype.forEach");
|
| -
|
| - // Pull out the length so that modifications to the length in the
|
| - // loop will not affect the looping and side effects are visible.
|
| - var array = $toObject(this);
|
| - var length = TO_UINT32(array.length);
|
| -
|
| +function InnerArrayForEach(f, receiver, array, length) {
|
| if (!IS_SPEC_FUNCTION(f)) throw MakeTypeError(kCalledNonCallable, f);
|
| var needs_wrapper = false;
|
| if (IS_NULL(receiver)) {
|
| @@ -1209,6 +1203,16 @@ function ArrayForEach(f, receiver) {
|
| }
|
| }
|
|
|
| +function ArrayForEach(f, receiver) {
|
| + CHECK_OBJECT_COERCIBLE(this, "Array.prototype.forEach");
|
| +
|
| + // Pull out the length so that modifications to the length in the
|
| + // loop will not affect the looping and side effects are visible.
|
| + var array = $toObject(this);
|
| + var length = TO_UINT32(array.length);
|
| + InnerArrayForEach(f, receiver, array, length);
|
| +}
|
| +
|
|
|
| // Executes the function once for each element present in the
|
| // array until it finds one where callback returns true.
|
| @@ -1243,14 +1247,7 @@ function ArraySome(f, receiver) {
|
| }
|
|
|
|
|
| -function ArrayEvery(f, receiver) {
|
| - CHECK_OBJECT_COERCIBLE(this, "Array.prototype.every");
|
| -
|
| - // Pull out the length so that modifications to the length in the
|
| - // loop will not affect the looping and side effects are visible.
|
| - var array = $toObject(this);
|
| - var length = TO_UINT32(array.length);
|
| -
|
| +function InnerArrayEvery(f, receiver, array, length) {
|
| if (!IS_SPEC_FUNCTION(f)) throw MakeTypeError(kCalledNonCallable, f);
|
| var needs_wrapper = false;
|
| if (IS_NULL(receiver)) {
|
| @@ -1273,6 +1270,16 @@ function ArrayEvery(f, receiver) {
|
| return true;
|
| }
|
|
|
| +function ArrayEvery(f, receiver) {
|
| + CHECK_OBJECT_COERCIBLE(this, "Array.prototype.every");
|
| +
|
| + // Pull out the length so that modifications to the length in the
|
| + // loop will not affect the looping and side effects are visible.
|
| + var array = $toObject(this);
|
| + var length = TO_UINT32(array.length);
|
| + return InnerArrayEvery(f, receiver, array, length);
|
| +}
|
| +
|
|
|
| function ArrayMap(f, receiver) {
|
| CHECK_OBJECT_COERCIBLE(this, "Array.prototype.map");
|
| @@ -1595,4 +1602,7 @@ $arraySlice = ArraySlice;
|
| $arraySplice = ArraySplice;
|
| $arrayUnshift = ArrayUnshift;
|
|
|
| -})
|
| +$innerArrayForEach = InnerArrayForEach;
|
| +$innerArrayEvery = InnerArrayEvery;
|
| +
|
| +});
|
|
|