import { EventEmitter } from 'events' ; export default class OnMessageWrapper extends EventEmitter { constructor ( self ) { super ( ) ; this . onMessage = this . onMessage . bind ( this ) ; self . addEventListener ( 'message' , this . onMessage ) ; } public onMessage ( e ) { this . emit ( 'message' , e ) ; } public addEventListener ( name , cb ) { this . addListener ( name , cb ) ; } public removeEventListener ( name , cb ) { this . removeListener ( name , cb ) ; } }