| Index: src/harmony-typedarray.js
|
| diff --git a/src/harmony-typedarray.js b/src/harmony-typedarray.js
|
| index 014206c4cba8400cf745b9295d5cb223695ad6cb..0d02615428f60ac99f700b6f9539a9ae16e8d0f6 100644
|
| --- a/src/harmony-typedarray.js
|
| +++ b/src/harmony-typedarray.js
|
| @@ -59,6 +59,59 @@ function NAMEForEach(f /* thisArg */) { // length == 1
|
| }
|
| }
|
|
|
| +// ES6 draft 11-14-14, section 22.2.3.13
|
| +function NAMEIndexOf(element /* fromIndex */) { // length == 1
|
| + if (!%IsTypedArray(this)) {
|
| + throw MakeTypeError('not_typed_array', []);
|
| + }
|
| +
|
| + // Typed arrays cannot contain undefined elements.
|
| + if (IS_UNDEFINED(element)) {
|
| + return -1;
|
| + }
|
| +
|
| + var length = %_TypedArrayGetLength(this);
|
| + if (length == 0) return -1;
|
| +
|
| + var n = (%_ArgumentsLength() > 1) ? ToInteger(%_Arguments(1)) : 0;
|
| + if (n < 0) {
|
| + n += length;
|
| + if (n < 0) n = 0;
|
| + }
|
| +
|
| + for (; n < length; n++) {
|
| + if (this[n] === element) return n;
|
| + }
|
| + return -1;
|
| +}
|
| +
|
| +// ES6 draft 11-14-14, section 22.2.3.16
|
| +function NAMELastIndexOf(element /* fromIndex */){ // length == 1
|
| + if (!%IsTypedArray(this)) {
|
| + throw MakeTypeError('not_typed_array', []);
|
| + }
|
| +
|
| + // Typed arrays cannot contain undefined elements.
|
| + if (IS_UNDEFINED(element)) {
|
| + return -1;
|
| + }
|
| +
|
| + var length = %_TypedArrayGetLength(this);
|
| + if (length == 0) return -1;
|
| +
|
| + var n = (%_ArgumentsLength() > 1) ? ToInteger(%_Arguments(1)) : length - 1;
|
| + if (n < 0) {
|
| + n += length;
|
| + } else if (n >= length) {
|
| + n = length - 1;
|
| + }
|
| +
|
| + for (; n >= 0; n--) {
|
| + if (this[n] === element) return n;
|
| + }
|
| + return -1;
|
| +}
|
| +
|
| // ES6 draft 08-24-14, section 22.2.2.2
|
| function NAMEOf() { // length == 0
|
| var length = %_ArgumentsLength();
|
| @@ -84,8 +137,10 @@ macro EXTEND_TYPED_ARRAY(ARRAY_ID, NAME, ELEMENT_SIZE)
|
| ));
|
|
|
| // Set up non-enumerable functions on the prototype object.
|
| - InstallFunctions(global.NAME.prototype, DONT_ENUM, $Array(
|
| - "forEach", NAMEForEach
|
| + InstallFunctions(global.NAME.prototype, DONT_ENUM | DONT_DELETE | READ_ONLY, $Array(
|
| + "forEach", NAMEForEach,
|
| + "indexOf", NAMEIndexOf,
|
| + "lastIndexOf", NAMELastIndexOf
|
| ));
|
| endmacro
|
|
|
|
|