<commit_before>package eventemitter

type Event struct {
	Name   string
	Argv   []interface{}
	Result interface{}
}

type EventListener func(event *Event)

type EventEmitter struct {
	Events map[string][]EventListener
}

func NewEventEmitter() *EventEmitter {
	e := new(EventEmitter)
	e.Init()

	return e
}

// Allocates the EventEmitters memory. Has to be called when
// embedding an EventEmitter in another Type.
func (self *EventEmitter) Init() {
	self.Events = make(map[string][]EventListener)
}

// Alias to AddListener.
func (self *EventEmitter) On(event string, listener EventListener) {
	self.AddListener(event, listener)
}

// AddListener adds an event listener on the given event name.
func (self *EventEmitter) AddListener(event string, listener EventListener) {
	// Check if the event exists, otherwise initialize the list
	// of handlers for this event.
	if _, exists := self.Events[event]; !exists {
		self.Events[event] = []EventListener{listener}
	} else {
		self.Events[event] = append(self.Events[event], listener)
	}
}

// Removes all listeners from the given event.
func (self *EventEmitter) RemoveListeners(event string) {
	delete(self.Events, event)
}

// Emits the given event. Puts all arguments following the event name
// into the Event's `Argv` member. Returns a channel if listeners were
// called, nil otherwise.
func (self *EventEmitter) Emit(event string, argv ...interface{}) <-chan *Event {
	listeners, exists := self.Events[event]

	if !exists {
		return nil
	}

	c := make(chan *Event)

	for _, listener := range listeners {
		go func(l EventListener) {
			e := &Event{Name: event, Argv: argv}
			l(e)
			c <- e
		}(listener)
	}

	return c
}<commit_msg>Made events private<commit_after>package eventemitter

type Event struct {
	Name   string
	Argv   []interface{}
	Result interface{}
}

type EventListener func(event *Event)

type EventEmitter struct {
	events map[string][]EventListener
}

func NewEventEmitter() *EventEmitter {
	e := new(EventEmitter)
	e.Init()

	return e
}

// Allocates the EventEmitters memory. Has to be called when
// embedding an EventEmitter in another Type.
func (self *EventEmitter) Init() {
	self.events = make(map[string][]EventListener)
}

func (self *EventEmitter) Listeners(event string) []EventListener {
	return self.events[event]
}

// Alias to AddListener.
func (self *EventEmitter) On(event string, listener EventListener) {
	self.AddListener(event, listener)
}

// AddListener adds an event listener on the given event name.
func (self *EventEmitter) AddListener(event string, listener EventListener) {
	// Check if the event exists, otherwise initialize the list
	// of handlers for this event.
	if _, exists := self.events[event]; !exists {
		self.events[event] = []EventListener{listener}
	} else {
		self.events[event] = append(self.events[event], listener)
	}
}

// Removes all listeners from the given event.
func (self *EventEmitter) RemoveListeners(event string) {
	delete(self.events, event)
}

// Emits the given event. Puts all arguments following the event name
// into the Event's `Argv` member. Returns a channel if listeners were
// called, nil otherwise.
func (self *EventEmitter) Emit(event string, argv ...interface{}) <-chan *Event {
	listeners, exists := self.events[event]

	if !exists {
		return nil
	}

	c := make(chan *Event)

	for _, listener := range listeners {
		go func(l EventListener) {
			e := &Event{Name: event, Argv: argv}
			l(e)
			c <- e
		}(listener)
	}

	return c
}
{'fraction_non_alphanumeric': 0.11551724137931034, 'fraction_numerical': 0.0, 'mean_word_length': 4.211077844311378, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1303184', 'n_tokens_mistral': 1089, 'n_tokens_neox': 1069, 'n_words': 366}