const create_tact = interval => {
    let start = Date.now()

    return () => {
        const diff = Date.now() - start
        if (diff > interval) {
            start += ~~(diff / interval) * interval
            return true
        }

        return false
    }
}

export default create_tact

/*
const everySecond = create_tact(1000)

let i = 0
while (i < 10) {
    if (everySecond()) {
        console.log(i++)
    }
}

*/
