import { int32 } from './int32' ; import { modulo } from './intdiv' ; import { select_ints } from './select' ; param { Uint8Array } input param { number } desired export function resize ( input , desired ) { if ( desired === 0 ) { return new Uint8Array ( 0 ) ; } const output = new Uint8Array ( desired ) ; let x ; let y ; let z ; const desired32 = int32 . fromInt ( desired ) ; for ( x = 0 ; x < input . length ; x ++ ) { y = int32 . fromInt ( x ) . sub ( desired32 ) . msb ( ) ; z = modulo ( x , desired ) ; output [ z ] = select_ints ( y | 0 , input [ x ] , output [ z ] ) ; } desired32 . wipe ( ) ; return output ; }