const looper = cb => {
    let lastTime = Date.now()

    const fn = time => {
        cb(Math.max(time - lastTime, 0))
        lastTime = time
        requestAnimationFrame(fn)
    }

    fn(lastTime)
}

export default looper
