import { performance } from 'perf_hooks' ; param { number } ms param { number } start example export async function stall ( ms , start ) { const now = performance . now ( ) ; const timeElapsed = now - start ; const timeRemaining = ms - timeElapsed ; if ( timeRemaining <= 0 ) return ; return new Promise ( ( resolve ) => setTimeout ( resolve , timeRemaining ) ) ; }