import { IEventEmitter } from "../../interface" ; import { EventEmitter } from "events" ; export class NodeEventEmitter implements IEventEmitter { private target : EventEmitter ; constructor ( target ? ) { this . target = target ?? new EventEmitter ( ) ; } dispatch < D > ( eventName , data ) { this . target . emit ( eventName , data ) ; } addListener ( eventName , callback ) { this . target . addListener ( eventName , callback ) ; return callback ; } removeListener ( eventName , callback ) { this . target . removeListener ( eventName , callback ) ; } }