UNPKG

@pinyin/frame

Version:
42 lines 1.16 kB
"use strict"; // inspired by https://github.com/Popmotion/framesync Object.defineProperty(exports, "__esModule", { value: true }); var Queue = /** @class */ (function () { function Queue() { this.tasks = []; } Queue.prototype.schedule = function (task) { this.tasks.push(task); }; Queue.prototype.execute = function () { for (var i = 0; i < this.tasks.length; i++) { try { this.tasks[i](); } catch (_a) { } } this.tasks.length = 0; }; Queue.prototype.moveInto = function (to) { for (var i = 0; i < this.tasks.length; i++) { try { to.schedule(this.tasks[i]); } catch (_a) { } } this.tasks.length = 0; }; Queue.prototype.clear = function () { this.tasks.length = 0; }; Object.defineProperty(Queue.prototype, "hasTask", { get: function () { return this.tasks.length > 0; }, enumerable: true, configurable: true }); return Queue; }()); exports.Queue = Queue; //# sourceMappingURL=Queue.js.map