UNPKG

mutant

Version:

Create observables and map them to DOM elements. Massively inspired by hyperscript and observ-*. No virtual dom, just direct observable bindings. Unnecessary garbage collection is avoided by using mutable objects instead of blasting immutable junk all ove

29 lines (24 loc) 497 B
var queue = [] var running = false var max = 1000 / 60 module.exports = function (fn) { if (typeof fn !== 'function') { throw new Error('Must be a function') } queue.push(fn) if (!running) { running = true window.requestIdleCallback(flush) } } function flush () { var startedAt = Date.now() while (queue.length && Date.now() - startedAt < max) { queue.shift()() } if (queue.length) { window.requestIdleCallback(flush) } else { running = false } }