<commit_before>angular
    .module('angular-event-emitter', [ ])
    .factory('EventEmitter', function($exceptionHandler) {
        function EventEmitter() {
            this._eventsHandlers = { };
        }


        angular.extend(EventEmitter.prototype, {
            on: function(eventName, handler) {
                if(!angular.isString(eventName)) {
                    $exceptionHandler(new Error('event name must be a string'));
                }

                if(!angular.isFunction(handler)) {
                    $exceptionHandler(Error('event handler must be a function'));
                }

                var eventHandlers = (this._eventsHandlers[eventName] || (this._eventsHandlers[eventName] = [ ]));

                eventHandlers.push(handler);
                
                var removed = false;
                return function() {
                    if(!removed) {
                        for(var i = 0, maxi = eventHandlers.length; i < maxi; i++) {
                            if(eventHandlers[i] === handler) {
                                // do not splice here to allow removing inside the handler
                                eventHandlers[i] = null;

                                removed = true;

                                break;
                            }
                        }
                    }
                };<commit_msg>Update event-emitter.service.js<commit_after>angular
    .module('angular-event-emitter', [ ])
    .factory('EventEmitter', function($exceptionHandler) {
        function EventEmitter() {
            this._eventsHandlers = { };
        }


        angular.extend(EventEmitter.prototype, {
            on: function(eventName, handler) {
                if(!angular.isString(eventName)) {
                    $exceptionHandler(new Error('event name must be a string'));
                }

                if(!angular.isFunction(handler)) {
                    $exceptionHandler(new Error('event handler must be a function'));
                }

                var eventHandlers = (this._eventsHandlers[eventName] || (this._eventsHandlers[eventName] = [ ]));

                eventHandlers.push(handler);
                
                var removed = false;
                return function() {
                    if(!removed) {
                        for(var i = 0, maxi = eventHandlers.length; i < maxi; i++) {
                            if(eventHandlers[i] === handler) {
                                // do not splice here to allow removing inside the handler
                                eventHandlers[i] = null;

                                removed = true;

                                break;
                            }
                        }
                    }
                };
{'fraction_non_alphanumeric': 0.09907010014306152, 'fraction_numerical': 0.000715307582260372, 'mean_word_length': 1.1515384615384616, 'pattern_counts': {'":': 0, '<': 5, '<?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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3194096', 'n_tokens_mistral': 666, 'n_tokens_neox': 616, 'n_words': 126}