| Index: src/js/typedarray.js
|
| diff --git a/src/js/typedarray.js b/src/js/typedarray.js
|
| index 06d1657d40c5e198e48ee6df76ae8c8def4d850a..ce504fdd953a597b58d28e62f291d49d3f46b639 100644
|
| --- a/src/js/typedarray.js
|
| +++ b/src/js/typedarray.js
|
| @@ -20,15 +20,13 @@ var GlobalArray = global.Array;
|
| var GlobalArrayBuffer = global.ArrayBuffer;
|
| var GlobalArrayBufferPrototype = GlobalArrayBuffer.prototype;
|
| var GlobalObject = global.Object;
|
| -var InnerArrayEvery;
|
| +var InnerArrayFill;
|
| var InnerArrayFilter;
|
| var InnerArrayFind;
|
| var InnerArrayFindIndex;
|
| -var InnerArrayForEach;
|
| var InnerArrayJoin;
|
| var InnerArrayReduce;
|
| var InnerArrayReduceRight;
|
| -var InnerArraySome;
|
| var InnerArraySort;
|
| var InnerArrayToLocaleString;
|
| var InternalArray = utils.InternalArray;
|
| @@ -66,15 +64,13 @@ utils.Import(function(from) {
|
| ArrayValues = from.ArrayValues;
|
| GetIterator = from.GetIterator;
|
| GetMethod = from.GetMethod;
|
| - InnerArrayEvery = from.InnerArrayEvery;
|
| + InnerArrayFill = from.InnerArrayFill;
|
| InnerArrayFilter = from.InnerArrayFilter;
|
| InnerArrayFind = from.InnerArrayFind;
|
| InnerArrayFindIndex = from.InnerArrayFindIndex;
|
| - InnerArrayForEach = from.InnerArrayForEach;
|
| InnerArrayJoin = from.InnerArrayJoin;
|
| InnerArrayReduce = from.InnerArrayReduce;
|
| InnerArrayReduceRight = from.InnerArrayReduceRight;
|
| - InnerArraySome = from.InnerArraySome;
|
| InnerArraySort = from.InnerArraySort;
|
| InnerArrayToLocaleString = from.InnerArrayToLocaleString;
|
| MaxSimple = from.MaxSimple;
|
| @@ -371,6 +367,17 @@ function TypedArrayGetToStringTag() {
|
| return name;
|
| }
|
|
|
| +function InnerTypedArrayEvery(f, receiver, array, length) {
|
| + if (!IS_CALLABLE(f)) throw %make_type_error(kCalledNonCallable, f);
|
| +
|
| + for (var i = 0; i < length; i++) {
|
| + if (i in array) {
|
| + var element = array[i];
|
| + if (!%_Call(f, receiver, element, i, array)) return false;
|
| + }
|
| + }
|
| + return true;
|
| +}
|
|
|
| // ES6 draft 05-05-15, section 22.2.3.7
|
| function TypedArrayEvery(f, receiver) {
|
| @@ -378,10 +385,29 @@ function TypedArrayEvery(f, receiver) {
|
|
|
| var length = %_TypedArrayGetLength(this);
|
|
|
| - return InnerArrayEvery(f, receiver, this, length);
|
| + return InnerTypedArrayEvery(f, receiver, this, length);
|
| }
|
| %FunctionSetLength(TypedArrayEvery, 1);
|
|
|
| +function InnerTypedArrayForEach(f, receiver, array, length) {
|
| + if (!IS_CALLABLE(f)) throw %make_type_error(kCalledNonCallable, f);
|
| +
|
| + if (IS_UNDEFINED(receiver)) {
|
| + for (var i = 0; i < length; i++) {
|
| + if (i in array) {
|
| + var element = array[i];
|
| + f(element, i, array);
|
| + }
|
| + }
|
| + } else {
|
| + for (var i = 0; i < length; i++) {
|
| + if (i in array) {
|
| + var element = array[i];
|
| + %_Call(f, receiver, element, i, array);
|
| + }
|
| + }
|
| + }
|
| +}
|
|
|
| // ES6 draft 08-24-14, section 22.2.3.12
|
| function TypedArrayForEach(f, receiver) {
|
| @@ -389,7 +415,7 @@ function TypedArrayForEach(f, receiver) {
|
|
|
| var length = %_TypedArrayGetLength(this);
|
|
|
| - InnerArrayForEach(f, receiver, this, length);
|
| + InnerTypedArrayForEach(f, receiver, this, length);
|
| }
|
| %FunctionSetLength(TypedArrayForEach, 1);
|
|
|
| @@ -472,6 +498,17 @@ function TypedArrayMap(f, thisArg) {
|
| }
|
| %FunctionSetLength(TypedArrayMap, 1);
|
|
|
| +function InnerTypedArraySome(f, receiver, array, length) {
|
| + if (!IS_CALLABLE(f)) throw %make_type_error(kCalledNonCallable, f);
|
| +
|
| + for (var i = 0; i < length; i++) {
|
| + if (i in array) {
|
| + var element = array[i];
|
| + if (%_Call(f, receiver, element, i, array)) return true;
|
| + }
|
| + }
|
| + return false;
|
| +}
|
|
|
| // ES6 draft 05-05-15, section 22.2.3.24
|
| function TypedArraySome(f, receiver) {
|
| @@ -479,7 +516,7 @@ function TypedArraySome(f, receiver) {
|
|
|
| var length = %_TypedArrayGetLength(this);
|
|
|
| - return InnerArraySome(f, receiver, this, length);
|
| + return InnerTypedArraySome(f, receiver, this, length);
|
| }
|
| %FunctionSetLength(TypedArraySome, 1);
|
|
|
|
|