text: const privateKey={id:([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,c=>(c^crypto.getRandomValues(new Uint8Array(1))[0]&15>>c/4).toString(16))};export default class LoudArray extends Array{constructor(listeners,...fromValues){super(...fromValues),this._private=new WeakMap,this._private.set(privateKey,{listeners:listeners||[]});const mutatorMethods="copyWithin fill pop push reverse shift sort splice unshift".split(" "),privateData=this._private.get(privateKey);for(let i=0;i<mutatorMethods.length;i++){let method=mutatorMethods[i];privateData[method]=this[method].bind(this),this[method]=(...args)=>{let listeners=privateData.listeners.filter(value=>{if("copyWithin"===method&&value.event.indexOf("copy-within")>-1)return!0;let event=value.event.toLowerCase();return event.indexOf(method)>-1||event.indexOf("any")>-1||event.indexOf("all")>-1});_dispatchEvents(this,listeners,"before",args);let returnValue=privateData[method](...args);return _dispatchEvents(this,listeners,"after",args),returnValue}}privateData.concat=this.concat.bind(this),this.concat=(...args)=>{let returnValue=privateData.concat(...args);return returnValue=new Array(...returnValue)},privateData.slice=this.slice.bind(this),this.slice=(...args)=>{let returnValue=privateData.slice(...args);return returnValue=new Array(...returnValue)}}addEventListener(event,handler){let listener=event;event instanceof ArrayListener||(listener=new ArrayListener(event,handler));const privateData=this._private.get(privateKey);let listenerIndex=_array_findListener(this,listener.event,listener.handler);return listenerIndex>-1?privateData.listeners[listenerIndex]:(privateData.listeners.push(listener),listener)}removeEventListener(event,handler){let listener=event;event instanceof ArrayListener||(listener=new ArrayListener(event,handler));let listenerIndex=_array_findListener(this,listener.event,listener.handler);if(-1==listenerIndex)return;const privateData=this._private.get(privateKey);privateData.listeners.splice(listenerIndex,1)}}export class ArrayListener{constructor(event,handler){this.event=event,this.handler=handler}}export class ArrayEvent{static get BeforeAll(){return"before-all"}static get BeforeCopyWithin(){return"before-copy-within"}static get BeforeFill(){return"before-fill"}static get BeforePop(){return"before-pop"}static get BeforePush(){return"before-push"}static get BeforeReverse(){return"before-reverse"}static get BeforeShift(){return"before-shift"}static get BeforeSort(){return"before-sort"}static get BeforeSplice(){return"before-splice"}static get BeforeUnshift(){return"before-unshift"}static get AfterAll(){return"after-all"}static get AfterCopyWithin(){return"after-copy-within"}static get AfterFill(){return"after-fill"}static get AfterPop(){return"after-pop"}static get AfterPush(){return"after-push"}static get AfterReverse(){return"after-reverse"}static get AfterShift(){return"after-shift"}static get AfterSort(){return"after-sort"}static get AfterSplice(){return"after-splice"}static get AfterUnshift(){return"after-unshift"}}function _array_findListener(target,event,handler){let index=-1;const privateData=target._private.get(privateKey);for(let i=0;i<privateData.listeners.length;i++){let listener=privateData.listeners[i],listenerEvent;if(listener.event.toLowerCase()==event&&listener.handler==handler){index=i;break}}return index}function _dispatchEvents(target,listeners,stage,args){for(let i=0;i<listeners.length;i++){let listener=listeners[i];listener.event.toLowerCase().indexOf(stage)>-1&&listener.handler(target,args)}}