UNPKG

time-slicing

Version:

Break down long tasks into smaller tasks, avoid blocking the main process.

11 lines (9 loc) 238 B
export default function ts (gen) { if (typeof gen === 'function') gen = gen() if (!gen || typeof gen.next !== 'function') return (function next () { const res = gen.next() if (res.done) return setTimeout(next) })() }