UNPKG

marko

Version:

UI Components + streaming, async, high performance, HTML templating for Node.js and the browser.

31 lines (27 loc) 592 B
"use strict";var queueMicrotask = require("./queueMicrotask"); var count = 0; var queue = new Set(); function noop() {} exports._l_ = function setImmediate(cb) { queue.add(cb); if (!count) { queueMicrotaskInternal(noop); } return cb; }; exports.ag_ = function clearImmediate(id) { queue.delete(id); }; exports.e_ = queueMicrotaskInternal; function queueMicrotaskInternal(cb) { count++; queueMicrotask(function () { if (--count === 0 && queue.size) { for (const fn of queue) { queueMicrotask(fn); } queue = new Set(); } cb(); }); }