function now ( ) { return performance ? performance . now ( ) : Date . now ( ) ; } export type Tick = { run ( cb ) : void ; stop ( ) : void ; } ; export function Tick ( ) { const nextFrame = requestAnimationFrame || webkitRequestAnimationFrame || setTimeout ; const cancelNextFrame = cancelAnimationFrame || webkitCancelAnimationFrame || clearTimeout ; let startTime ; let id ; function run ( cb ) { startTime = startTime === void 0 ? now ( ) : startTime ; id = nextFrame ( ( ) => { const timeStamp = now ( ) ; const interval = timeStamp - < number > startTime ; startTime = timeStamp ; cb ( interval ) ; } ) ; } function stop ( ) { startTime = undefined ; cancelNextFrame ( id ) ; } return { run , stop } ; }