Add TypedArray#fill (#274)

This commit is contained in:
Max Graey
2018-10-26 19:28:31 +03:00
committed by Daniel Wirtz
parent afb8fe7762
commit 83fa12164f
10 changed files with 4816 additions and 2062 deletions

View File

@ -119,11 +119,13 @@ export class Array<T> {
start = start < 0 ? max(len + start, 0) : min(start, len);
end = end < 0 ? max(len + end, 0) : min(end, len);
if (sizeof<T>() == 1) {
memory.fill(
changetype<usize>(buffer) + start + HEADER_SIZE,
<u8>value,
<usize>(end - start)
);
if (start < end) {
memory.fill(
changetype<usize>(buffer) + start + HEADER_SIZE,
<u8>value,
<usize>(end - start)
);
}
} else {
for (; start < end; ++start) {
storeUnsafe<T,T>(buffer, start, value);