import { TypedArray } from "./internal/typedarray"; export class Int8Array extends TypedArray { static readonly BYTES_PER_ELEMENT: usize = sizeof(); subarray(begin: i32 = 0, end: i32 = 0x7fffffff): Int8Array { return changetype(super.subarray(begin, end)); } reduce( callbackfn: (accumulator: ReturnType, value: i8, index: i32, array: Int8Array) => ReturnType, initialValue: ReturnType, ): ReturnType { return super.reduce_internal(callbackfn, this, initialValue); } reduceRight( callbackfn: (accumulator: ReturnType, value: i8, index: i32, array: Int8Array) => ReturnType, initialValue: ReturnType, ): ReturnType { return super.reduce_internal(callbackfn, this, initialValue, true); } } export class Uint8Array extends TypedArray { static readonly BYTES_PER_ELEMENT: usize = sizeof(); subarray(begin: i32 = 0, end: i32 = 0x7fffffff): Uint8Array { return changetype(super.subarray(begin, end)); } reduce( callbackfn: (accumulator: ReturnType, value: u8, index: i32, array: Uint8Array) => ReturnType, initialValue: ReturnType, ): ReturnType { return super.reduce_internal(callbackfn, this, initialValue); } reduceRight( callbackfn: (accumulator: ReturnType, value: u8, index: i32, array: Uint8Array) => ReturnType, initialValue: ReturnType, ): ReturnType { return super.reduce_internal(callbackfn, this, initialValue, true); } } export class Uint8ClampedArray extends TypedArray { static readonly BYTES_PER_ELEMENT: usize = sizeof(); @inline @operator("[]=") protected __set(index: i32, value: i32): void { super.__set(index, max(min(value, 255), 0)); } @inline @operator("{}=") protected __unchecked_set(index: i32, value: i32): void { super.__unchecked_set(index, max(min(value, 255), 0)); } subarray(begin: i32 = 0, end: i32 = 0x7fffffff): Uint8ClampedArray { return changetype(super.subarray(begin, end)); } reduce( callbackfn: (accumulator: ReturnType, value: u8, index: i32, array: Uint8ClampedArray) => ReturnType, initialValue: ReturnType, ): ReturnType { return super.reduce_internal(callbackfn, this, initialValue); } reduceRight( callbackfn: (accumulator: ReturnType, value: u8, index: i32, array: Uint8ClampedArray) => ReturnType, initialValue: ReturnType, ): ReturnType { return super.reduce_internal(callbackfn, this, initialValue, true); } } export class Int16Array extends TypedArray { static readonly BYTES_PER_ELEMENT: usize = sizeof(); subarray(begin: i32 = 0, end: i32 = 0x7fffffff): Int16Array { return changetype(super.subarray(begin, end)); } reduce( callbackfn: (accumulator: ReturnType, value: i16, index: i32, array: Int16Array) => ReturnType, initialValue: ReturnType, ): ReturnType { return super.reduce_internal(callbackfn, this, initialValue); } reduceRight( callbackfn: (accumulator: ReturnType, value: i16, index: i32, array: Int16Array) => ReturnType, initialValue: ReturnType, ): ReturnType { return super.reduce_internal(callbackfn, this, initialValue, true); } } export class Uint16Array extends TypedArray { static readonly BYTES_PER_ELEMENT: usize = sizeof(); subarray(begin: i32 = 0, end: i32 = 0x7fffffff): Uint16Array { return changetype(super.subarray(begin, end)); } reduce( callbackfn: (accumulator: ReturnType, value: u16, index: i32, array: Uint16Array) => ReturnType, initialValue: ReturnType, ): ReturnType { return super.reduce_internal(callbackfn, this, initialValue); } reduceRight( callbackfn: (accumulator: ReturnType, value: u16, index: i32, array: Uint16Array) => ReturnType, initialValue: ReturnType, ): ReturnType { return super.reduce_internal(callbackfn, this, initialValue, true); } } export class Int32Array extends TypedArray { static readonly BYTES_PER_ELEMENT: usize = sizeof(); subarray(begin: i32 = 0, end: i32 = 0x7fffffff): Int32Array { return changetype(super.subarray(begin, end)); } /** * @param callbackfn {function} - a function that reduces each value to a ReturnType * @param initialValue {ReturnType} - the initial ReturnType value to be passed to the callbackfn */ reduce( callbackfn: (accumulator: ReturnType, value: i32, index: i32, array: Int32Array) => ReturnType, initialValue: ReturnType, ): ReturnType { return super.reduce_internal(callbackfn, this, initialValue); } reduceRight( callbackfn: (accumulator: ReturnType, value: i32, index: i32, array: Int32Array) => ReturnType, initialValue: ReturnType, ): ReturnType { return super.reduce_internal(callbackfn, this, initialValue, true); } } export class Uint32Array extends TypedArray { static readonly BYTES_PER_ELEMENT: usize = sizeof(); subarray(begin: i32 = 0, end: i32 = 0x7fffffff): Uint32Array { return changetype(super.subarray(begin, end)); } reduce( callbackfn: (accumulator: ReturnType, value: u32, index: i32, array: Uint32Array) => ReturnType, initialValue: ReturnType, ): ReturnType { return super.reduce_internal(callbackfn, this, initialValue); } reduceRight( callbackfn: (accumulator: ReturnType, value: u32, index: i32, array: Uint32Array) => ReturnType, initialValue: ReturnType, ): ReturnType { return super.reduce_internal(callbackfn, this, initialValue, true); } } export class Int64Array extends TypedArray { static readonly BYTES_PER_ELEMENT: usize = sizeof(); subarray(begin: i32 = 0, end: i32 = 0x7fffffff): Int64Array { return changetype(super.subarray(begin, end)); } reduce( callbackfn: (accumulator: ReturnType, value: i64, index: i32, array: Int64Array) => ReturnType, initialValue: ReturnType, ): ReturnType { return super.reduce_internal(callbackfn, this, initialValue); } reduceRight( callbackfn: (accumulator: ReturnType, value: i64, index: i32, array: Int64Array) => ReturnType, initialValue: ReturnType, ): ReturnType { return super.reduce_internal(callbackfn, this, initialValue, true); } } export class Uint64Array extends TypedArray { static readonly BYTES_PER_ELEMENT: usize = sizeof(); subarray(begin: i32 = 0, end: i32 = 0x7fffffff): Uint64Array { return changetype(super.subarray(begin, end)); } reduce( callbackfn: (accumulator: ReturnType, value: u64, index: i32, array: Uint64Array) => ReturnType, initialValue: ReturnType, ): ReturnType { return super.reduce_internal(callbackfn, this, initialValue); } reduceRight( callbackfn: (accumulator: ReturnType, value: u64, index: i32, array: Uint64Array) => ReturnType, initialValue: ReturnType, ): ReturnType { return super.reduce_internal(callbackfn, this, initialValue, true); } } export class Float32Array extends TypedArray { static readonly BYTES_PER_ELEMENT: usize = sizeof(); subarray(begin: i32 = 0, end: i32 = 0x7fffffff): Float32Array { return changetype(super.subarray(begin, end)); } reduce( callbackfn: (accumulator: ReturnType, value: f32, index: i32, array: Float32Array) => ReturnType, initialValue: ReturnType, ): ReturnType { return super.reduce_internal(callbackfn, this, initialValue); } reduceRight( callbackfn: (accumulator: ReturnType, value: f32, index: i32, array: Float32Array) => ReturnType, initialValue: ReturnType, ): ReturnType { return super.reduce_internal(callbackfn, this, initialValue, true); } } export class Float64Array extends TypedArray { static readonly BYTES_PER_ELEMENT: usize = sizeof(); subarray(begin: i32 = 0, end: i32 = 0x7fffffff): Float64Array { return changetype(super.subarray(begin, end)); } reduce( callbackfn: (accumulator: ReturnType, value: f64, index: i32, array: Float64Array) => ReturnType, initialValue: ReturnType, ): ReturnType { return super.reduce_internal(callbackfn, this, initialValue); } reduceRight( callbackfn: (accumulator: ReturnType, value: f64, index: i32, array: Float64Array) => ReturnType, initialValue: ReturnType, ): ReturnType { return super.reduce_internal(callbackfn, this, initialValue, true); } }