Implement TypedArray#reduce/reduceRight (#352)

This commit is contained in:
jtenner
2018-12-05 11:53:31 -05:00
committed by Daniel Wirtz
parent ced01216f8
commit d7f4874650
7 changed files with 5079 additions and 8 deletions

View File

@ -520,6 +520,16 @@ declare abstract class TypedArray<T> implements ArrayBufferView<T> {
readonly length: i32;
/** Returns a new TypedArray of this type on the same ArrayBuffer from begin inclusive to end exclusive. */
subarray(begin?: i32, end?: i32): this;
/** The reduce() method applies a function against an accumulator and each value of the typed array (from left-to-right) has to reduce it to a single value. This method has the same algorithm as Array.prototype.reduce(). */
reduce<W>(
callbackfn: (accumulator: W, value: T, index: i32, self: this) => W,
initialValue: W,
): W;
/** The reduceRight() method applies a function against an accumulator and each value of the typed array (from left-to-right) has to reduce it to a single value, starting from the end of the array. This method has the same algorithm as Array.prototype.reduceRight(). */
reduceRight<W>(
callbackfn: (accumulator: W, value: T, index: i32, self: this) => W,
initialValue: W,
): W;
}
/** An array of twos-complement 8-bit signed integers. */