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

Unified Diff: src/js/typedarray.js

Issue 2776433003: [builtins] Implement Array.prototype.reduceRight in the CSA (Closed)
Patch Set: Add back accidental removals Created 3 years, 9 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
« no previous file with comments | « src/js/array.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/js/typedarray.js
diff --git a/src/js/typedarray.js b/src/js/typedarray.js
index ac8609a8266378661f3711ca9b5b1671daa768f6..1f11e897e4f25e9c2a4b50b7023bd59599e644fe 100644
--- a/src/js/typedarray.js
+++ b/src/js/typedarray.js
@@ -24,7 +24,6 @@ var InnerArrayFilter;
var InnerArrayFind;
var InnerArrayFindIndex;
var InnerArrayJoin;
-var InnerArrayReduceRight;
var InnerArraySort;
var InnerArrayToLocaleString;
var InternalArray = utils.InternalArray;
@@ -66,7 +65,6 @@ utils.Import(function(from) {
InnerArrayFind = from.InnerArrayFind;
InnerArrayFindIndex = from.InnerArrayFindIndex;
InnerArrayJoin = from.InnerArrayJoin;
- InnerArrayReduceRight = from.InnerArrayReduceRight;
InnerArraySort = from.InnerArraySort;
InnerArrayToLocaleString = from.InnerArrayToLocaleString;
MaxSimple = from.MaxSimple;
@@ -572,6 +570,31 @@ function TypedArrayReduce(callback, current) {
}
%FunctionSetLength(TypedArrayReduce, 1);
+function InnerArrayReduceRight(callback, current, array, length,
+ argumentsLength) {
+ if (!IS_CALLABLE(callback)) {
+ throw %make_type_error(kCalledNonCallable, callback);
+ }
+
+ var i = length - 1;
+ find_initial: if (argumentsLength < 2) {
+ for (; i >= 0; i--) {
+ if (i in array) {
+ current = array[i--];
+ break find_initial;
+ }
+ }
+ throw %make_type_error(kReduceNoInitial);
+ }
+
+ for (; i >= 0; i--) {
+ if (i in array) {
+ var element = array[i];
+ current = callback(current, element, i, array);
+ }
+ }
+ return current;
+}
// ES6 draft 07-15-13, section 22.2.3.19
function TypedArrayReduceRight(callback, current) {
« no previous file with comments | « src/js/array.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698