UNPKG

2.38 kBSource Map (JSON)View Raw
1{"version":3,"sources":["../src/ReEmitter.js"],"names":["Reemitter","target","boundHandlers","eventName","args","emit","source","eventNames","undefined","_handleEvent","bind","boundHandler","on"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;AAkBA;;;;IAIqBA,S;AACjB,uBAAYC,MAAZ,EAAoB;AAAA;;AAChB,aAAKA,MAAL,GAAcA,MAAd;;AAEA;AACA;AACA,aAAKC,aAAL,GAAqB,EAArB;AACH;;;;qCAEYC,S,EAAoB;AAAA;;AAAA,8CAANC,IAAM;AAANA,oBAAM;AAAA;;AAC7B,4BAAKH,MAAL,EAAYI,IAAZ,iBAAiBF,SAAjB,SAA+BC,IAA/B;AACH;;;+BAEME,M,EAAQC,U,EAAY;AAAA;AAAA;AAAA;;AAAA;AACvB,gEAAwBA,UAAxB,4GAAoC;AAAA,wBAAzBJ,SAAyB;;AAChC,wBAAI,KAAKD,aAAL,CAAmBC,SAAnB,MAAkCK,SAAtC,EAAiD;AAC7C,6BAAKN,aAAL,CAAmBC,SAAnB,IAAgC,KAAKM,YAAL,CAAkBC,IAAlB,CAAuB,IAAvB,EAA6BP,SAA7B,CAAhC;AACH;AACD,wBAAMQ,eAAe,KAAKT,aAAL,CAAmBC,SAAnB,CAArB;;AAEAG,2BAAOM,EAAP,CAAUT,SAAV,EAAqBQ,YAArB;AACH;AARsB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAS1B;;;;;kBAtBgBX,S","file":"ReEmitter.js","sourcesContent":["/*\nCopyright 2015, 2016 OpenMarket Ltd\nCopyright 2017 Vector Creations Ltd\nCopyright 2017 New Vector Ltd\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\n/**\n * @module\n */\n\nexport default class Reemitter {\n constructor(target) {\n this.target = target;\n\n // We keep one bound event handler for each event name so we know\n // what event is arriving\n this.boundHandlers = {};\n }\n\n _handleEvent(eventName, ...args) {\n this.target.emit(eventName, ...args);\n }\n\n reEmit(source, eventNames) {\n for (const eventName of eventNames) {\n if (this.boundHandlers[eventName] === undefined) {\n this.boundHandlers[eventName] = this._handleEvent.bind(this, eventName);\n }\n const boundHandler = this.boundHandlers[eventName];\n\n source.on(eventName, boundHandler);\n }\n }\n}\n"]}
\No newline at end of file