{"size": 1197, "ext": "js", "max_stars_repo_path": "src/contexts/AngularCore.js", "max_stars_repo_name": "paychex/context-manager", "max_stars_repo_stars_event_min_datetime": "2016-05-13T14:18:25.000Z", "max_stars_repo_stars_event_max_datetime": "2016-05-13T14:18:25.000Z", "max_issues_repo_path": "src/contexts/AngularCore.js", "max_issues_repo_name": "paychex/context-manager", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/contexts/AngularCore.js", "max_forks_repo_name": "paychex/context-manager", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 21.7636363636, "max_line_length": 60, "alphanum_fraction": 0.4344193818}
/* global define: false */
/* jshint browser: true */

define(['lodash', 'angular'], function(_, angular) {

    'use strict';

    var orig = angular.module,
        targets = [
            'constant',
            'value',
            'factory',
            'service',
            'controller',
            'directive',
            'filter',
            'animation'
        ];

    return _.once(function initialize(ContextManager) {

        angular.module = function module() {

            var mod = orig.apply(angular, arguments),
                parent = ContextManager.getCurrentContext();

            targets.forEach(function wrapTarget(target) {

                var fn = mod[target];

                mod[target] = function _ignore_(name) {
                    try {
                        return fn.apply(angular, arguments);
                    } catch (e) {
                        parent.handleError(e);
                    }
                };

                return mod;

            });

            mod.onError = function onError(handler) {
                parent.onError(handler);
                return mod;
            };

            return mod;

        };

    });

});
