colyseus.js
Version:
Colyseus Multiplayer SDK for JavaScript/TypeScript
1 lines • 2.51 kB
Source Map (JSON)
{"version":3,"file":"nanoevents.mjs","sources":["../../../src/core/nanoevents.ts"],"sourcesContent":["/**\n * The MIT License (MIT)\n *\n * Copyright 2016 Andrey Sitnik <andrey@sitnik.ru>\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy of\n * this software and associated documentation files (the \"Software\"), to deal in\n * the Software without restriction, including without limitation the rights to\n * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\n * the Software, and to permit persons to whom the Software is furnished to do so,\n * subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\n * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\n * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\n * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\n * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n */\n\nexport const createNanoEvents = () => ({\n emit(event: string, ...args: any[]) {\n let callbacks = this.events[event] || []\n for (let i = 0, length = callbacks.length; i < length; i++) {\n callbacks[i](...args)\n }\n },\n events: {},\n on(event: string, cb: (...args: any[]) => void) {\n this.events[event]?.push(cb) || (this.events[event] = [cb])\n return () => {\n this.events[event] = this.events[event]?.filter(i => cb !== i)\n }\n }\n});"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;AAqBG;AAEU,MAAA,gBAAgB,GAAG,OAAO;AACnC,IAAA,IAAI,CAAC,KAAa,EAAE,GAAG,IAAW,EAAA;QAC9B,IAAI,SAAS,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE;AACxC,QAAA,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,GAAG,MAAM,EAAE,CAAC,EAAE,EAAE;AACxD,YAAA,SAAS,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;;KAE5B;AACD,IAAA,MAAM,EAAE,EAAE;IACV,EAAE,CAAC,KAAa,EAAE,EAA4B,EAAA;QAC1C,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,EAAE,CAAC,KAAK,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;AAC3D,QAAA,OAAO,MAAK;YACR,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AAClE,SAAC;;AAER,CAAA;;;;"}