leref.ts
Version:
Something upcoming for aoi.js and npm packages uses
1 lines • 1.4 kB
JavaScript
;var __decorate=this&&this.__decorate||function(e,t,r,s){var i,o=arguments.length,u=o<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,r):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)u=Reflect.decorate(e,t,r,s);else for(var a=e.length-1;0<=a;a--)(i=e[a])&&(u=(o<3?i(u):3<o?i(t,r,u):i(t,r))||u);return 3<o&&u&&Object.defineProperty(t,r,u),u};Object.defineProperty(exports,"__esModule",{value:!0}),exports.LerefQueueSystem=void 0;const validators_1=require("../utils/decorators/validators");class LerefQueueSystem extends Array{get duration(){var e=this.current?.duration??0;return this.reduce((e,t)=>e+(t.duration??0),e)}get totalSize(){return this.length+(this.current?1:0)}get size(){return this.length}add(e,t){void 0===t&&"number"!=typeof t?Array.isArray(e)?this.push(...e):this.push(e):Array.isArray(e)?this.splice(t,0,...e):this.splice(t,0,e)}remove(e,t){return void 0!==t?this.splice(e,t-e):this.splice(e,1)}clear(){this.length=0}shuffle(){for(let e=this.length-1;0<e;e--){var t=Math.floor(Math.random()*(e+1));[this[e],this[t]]=[this[t],this[e]]}}progress(){return this.previous=this.current,this.current=this.shift(),this.current}}__decorate([validators_1.Queue.validateTracks()],LerefQueueSystem.prototype,"add",null),__decorate([validators_1.Queue.validatePosition()],LerefQueueSystem.prototype,"remove",null),exports.LerefQueueSystem=LerefQueueSystem;