Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(387)

Unified Diff: src/harmony-typedarray.js

Issue 1141763004: Implement %TypedArray%.{lastI,i}ndexOf (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: minor style fix Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/harmony-typedarray.js
diff --git a/src/harmony-typedarray.js b/src/harmony-typedarray.js
index 90679e0c1fe1afffb6b6b7115e93719e02d7b0c1..60bb65a138b6167d9c86fc7a56a1c08236f4b6a0 100644
--- a/src/harmony-typedarray.js
+++ b/src/harmony-typedarray.js
@@ -91,6 +91,29 @@ function TypedArrayFindIndex(predicate, thisArg) {
%FunctionSetLength(TypedArrayFindIndex, 1);
+// ES6 draft 05-18-15 section 22.2.3.13
arv (Not doing code reviews) 2015/05/19 15:10:41 At this point you can just refer to it as ES6
+function TypedArrayIndexOf(element, index) {
+ if (!%IsTypedArray(this)) throw MakeTypeError(kNotTypedArray);
+
+ var length = %_TypedArrayGetLength(this);
+
+ return %_CallFunction(this, element, index, length, $innerArrayIndexOf);
+}
+%FunctionSetLength(TypedArrayIndexOf, 1);
+
+
+// ES6 draft 05-18-15 section 22.2.3.16
+function TypedArrayLastIndexOf(element, index) {
+ if (!%IsTypedArray(this)) throw MakeTypeError(kNotTypedArray);
+
+ var length = %_TypedArrayGetLength(this);
+
+ return %_CallFunction(this, element, index, length,
+ %_ArgumentsLength(), $innerArrayLastIndexOf);
+}
+%FunctionSetLength(TypedArrayLastIndexOf, 1);
+
+
// ES6 draft 08-24-14, section 22.2.2.2
function TypedArrayOf() {
var length = %_ArgumentsLength();
@@ -140,7 +163,9 @@ macro EXTEND_TYPED_ARRAY(NAME)
"forEach", TypedArrayForEach,
"find", TypedArrayFind,
"findIndex", TypedArrayFindIndex,
- "fill", TypedArrayFill
+ "fill", TypedArrayFill,
+ "indexOf", TypedArrayIndexOf,
+ "lastIndexOf", TypedArrayLastIndexOf
]);
endmacro

Powered by Google App Engine
This is Rietveld 408576698