<commit_before>/**
 * @license <NAME>
 * (c) 2015 <NAME> https://github.com/kasperlewau
 * License: MIT
 */

(function () {

  'use strict';

  /**
   * @ngdoc method
   * @name  setupNotifier
   * @kind function
   * @description
   *
   * Utility method to setup watcher(s) on the given scope
   * and register a $broadcast callback for the watcher(s).
   *
   * @param {Object} scope - the scope to attach watchers and broadcast from
   * @param {Object} notifierMap - key:value mapping of notifiers and expressions to watch.
   */
  function setupNotifier (scope, notifierMap) {
    function handler (notifierKey, newValue, oldValue) {
      if (newValue !== oldValue) {
        scope.$broadcast('$$rebind::' + notifierKey);
      }
    }

    Object.keys(notifierMap).forEach(function (k) {
      scope.$watch(
        notifierMap[k],
        handler.bind(null, k),
        typeof scope[notifierMap[k]] === 'object'
      );
    });
  }

  /**
   * @ngdoc method
   * @name dynamicWatcher
   * @kind function
   * @description
   *
   * Utility method that extends a regular oneTimeWatchDelegate function with
   * scope listeners for each of the given notifier keys. When an event in the format of
   * '$$rebind::[notifierKey]' is caught in the associated $scope, a oneTimeWatchDelegate
   * will be called with the original options and reevaluate the given expression.
   *
   * If the given expr.$$watchDelegate has already been flagged as 'wrapped', we're hitting this
   * function again due to some caching behaviour of Angular expressions. In which case,
   * we should not register additional $on listeners, nor should we re-wrap the given expression.
   * Exit early o/
   *
   * @param {String|Function} expr - The expression to evaluate. Can be either a string or a function.
   * @param {Array} notifierKeys - An array of keys to setup $on listeners for.
   *
   * @returns {Function} wrap - A decorated oneTimeWatchDelegate function.
   */
  function dynamicWatcher (expr, notifierKeys) {
    if (expr.$$watchDelegate.wrapped) {
      return expr.$$watchDelegate;
    }

    function setupListeners (scope, cb) {
      notifierKeys.forEach(function (nk) {
        scope.$on('$$rebind::' + nk, cb);
      });
    }

    function wrapDelegate (watchDelegate, scope, listener, objectEquality, parsedExpression) {
      var delegateCall = watchDelegate.bind(this, scope, listener, objectEquality, parsedExpression);
      setupListeners(scope, delegateCall);
      delegateCall();
    }

    var delegate     = wrapDelegate.bind(this, expr.$$watchDelegate);<commit_msg>Ensures wrapDelegate returns a value<commit_after>/**
 * @license <NAME>
 * (c) 2015 <NAME> https://github.com/kasperlewau
 * License: MIT
 */

(function () {

  'use strict';

  /**
   * @ngdoc method
   * @name  setupNotifier
   * @kind function
   * @description
   *
   * Utility method to setup watcher(s) on the given scope
   * and register a $broadcast callback for the watcher(s).
   *
   * @param {Object} scope - the scope to attach watchers and broadcast from
   * @param {Object} notifierMap - key:value mapping of notifiers and expressions to watch.
   */
  function setupNotifier (scope, notifierMap) {
    function handler (notifierKey, newValue, oldValue) {
      if (newValue !== oldValue) {
        scope.$broadcast('$$rebind::' + notifierKey);
      }
    }

    Object.keys(notifierMap).forEach(function (k) {
      scope.$watch(
        notifierMap[k],
        handler.bind(null, k),
        typeof scope[notifierMap[k]] === 'object'
      );
    });
  }

  /**
   * @ngdoc method
   * @name dynamicWatcher
   * @kind function
   * @description
   *
   * Utility method that extends a regular oneTimeWatchDelegate function with
   * scope listeners for each of the given notifier keys. When an event in the format of
   * '$$rebind::[notifierKey]' is caught in the associated $scope, a oneTimeWatchDelegate
   * will be called with the original options and reevaluate the given expression.
   *
   * If the given expr.$$watchDelegate has already been flagged as 'wrapped', we're hitting this
   * function again due to some caching behaviour of Angular expressions. In which case,
   * we should not register additional $on listeners, nor should we re-wrap the given expression.
   * Exit early o/
   *
   * @param {String|Function} expr - The expression to evaluate. Can be either a string or a function.
   * @param {Array} notifierKeys - An array of keys to setup $on listeners for.
   *
   * @returns {Function} wrap - A decorated oneTimeWatchDelegate function.
   */
  function dynamicWatcher (expr, notifierKeys) {
    if (expr.$$watchDelegate.wrapped) {
      return expr.$$watchDelegate;
    }

    function setupListeners (scope, cb) {
      notifierKeys.forEach(function (nk) {
        scope.$on('$$rebind::' + nk, cb);
      });
    }

    function wrapDelegate (watchDelegate, scope, listener, objectEquality, parsedExpression) {
      var delegateCall = watchDelegate.bind(this, scope, listener, objectEquality, parsedExpression);
      setupListeners(scope, delegateCall);
      return delegateCall();
    }

    var delegate     = wrapDelegate.bind(this, expr.$$watchDelegate);
{'fraction_non_alphanumeric': 0.10619469026548672, 'fraction_numerical': 0.0015390534821085034, 'mean_word_length': 3.152555910543131, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 2, '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': '5244748', 'n_tokens_mistral': 1509, 'n_tokens_neox': 1462, 'n_words': 502}