react-dayo
Version:
A Queue component for notification etc
56 lines • 2 kB
JavaScript
var __read = (this && this.__read) || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
};
var __spread = (this && this.__spread) || function () {
for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
return ar;
};
var DayoOperators = /** @class */ (function () {
function DayoOperators(dayo) {
this.dayo = dayo;
}
DayoOperators.prototype.rewriteQueueItem = function (seed) {
var queue = this.dayo.getQueue();
var targetIndex = queue.findIndex(function (item) {
return item.id === seed.id;
});
if (targetIndex === -1) {
return;
}
queue[targetIndex] = seed;
this.dayo.setQueue(queue);
};
DayoOperators.prototype.addSeed = function (seed) {
this.dayo.setQueue(__spread(this.dayo.getQueue(), [seed]));
};
DayoOperators.prototype.skipOverflowSeeds = function (opts) {
// const queueMaxLength = this.getOption('maxLength');
var enteredItems = this.dayo
.getQueue()
.filter(function (item) { return item.cycle.isEntering() || item.cycle.isEntered(); });
var addingItemLength = 1;
var overflowLength = enteredItems.length + addingItemLength - opts.maxLength;
if (overflowLength > 0) {
enteredItems.slice(0, overflowLength).forEach(function (seedOnCycle) {
seedOnCycle.cycle.skip();
});
}
};
return DayoOperators;
}());
export { DayoOperators };
export default DayoOperators;
//# sourceMappingURL=dayo-operators.js.map