<commit_before>var patchUtils = require('../patching/patchUtils')
var Subscription = require('../common/subscription')

var utils = require('../lib/utils')
function ZoneService (zone, logger) {
  function rafPatch (parentRaf) {
    return function (rafFn) {
      var self = this
      var args = patchUtils.argumentsToArray(arguments)
      var tId
      args[0] = patchUtils.wrapAfter(rafFn, function () {
        self._removeTransactionTask('raf' + tId)
        self.log(' - requestAnimationFrame ')
      })
      tId = parentRaf.apply(this, args)
      self._addTransactionTask('raf' + tId)
      self.log(' + requestAnimationFrame ')
      return tId
    }
  }

  function cancelRafPatch (id) {
    this._removeTransactionTask('raf' + id)
    this.log('cancelAnimationFrame')
  }

  this.events = new Subscription()
  // var zoneService = this
  function noop () { }
  var spec = this.spec = {
    onAddTask: noop,
    onRemoveTask: noop,
    onDetectFinish: noop
  }

  var zoneConfig = {
    log: function log (methodName, theRest) {
      var logText = 'Zone(' + this.$id + ') parent(' + this.parent.$id + ') ' + methodName
      var logArray = [logText]
      if (!utils.isUndefined(theRest)) {
        logArray.push(theRest)
      }
      logger.debug.apply(logger, logArray)
    },
    // onZoneCreated: function () {
    //   this.log('onZoneCreated')
    // },
    beforeTask: function () {
      var sig = this.signature
      this.log('beforeTask', (typeof sig === 'undefined' ? undefined : ' signature: ' + sig))
    },
    afterTask: function () {
      var sig = this.signature
      this.log('afterTask', (typeof sig === 'undefined' ? undefined : ' signature: ' + sig))
      this._detectFinish()
    },
    // '-onError': function () {
    //   this.log('onError')
    // },
    // enqueueTask: function () {
    //   this.log('enqueueTask', arguments)
    // },
    // dequeueTask: function () {
    //   this.log('dequeueTask', arguments)
    // },
    $setTimeout: function (parentTimeout) {
      return function (timeoutFn, delay) {
        var self = this
        if (delay === 0) {
          var args = patchUtils.argumentsToArray(arguments)
          var tId
          args[0] = patchUtils.wrapAfter(timeoutFn, function () {
            self._removeTransactionTask('setTimeout' + tId)
            self.log(' - setTimeout ', ' delay: ' + delay)
          })
          tId = parentTimeout.apply(this, args)
          self._addTransactionTask('setTimeout' + tId)
          self.log(' + setTimeout ', ' delay: ' + delay)
          return tId
        } else {
          return parentTimeout.apply(this, arguments)
        }
      }
    },
    '-clearTimeout': function (id) {
      this._removeTransactionTask('setTimeout' + id)
      this.log('clearTimeout', this.timeout)
    },
    '$requestAnimationFrame': rafPatch,
    '-cancelAnimationFrame': cancelRafPatch,

    '$webkitRequestAnimationFrame': rafPatch,
    '-webkitCancelAnimationFrame': cancelRafPatch,

    '$mozRequestAnimationFrame': rafPatch,
    '-mozCancelAnimationFrame': cancelRafPatch

  // $addEventListener: function (parentAddEventListener) {<commit_msg>minor fix check timeoutFn type<commit_after>var patchUtils = require('../patching/patchUtils')
var Subscription = require('../common/subscription')

var utils = require('../lib/utils')
function ZoneService (zone, logger) {
  function rafPatch (parentRaf) {
    return function (rafFn) {
      var self = this
      var args = patchUtils.argumentsToArray(arguments)
      var tId
      args[0] = patchUtils.wrapAfter(rafFn, function () {
        self._removeTransactionTask('raf' + tId)
        self.log(' - requestAnimationFrame ')
      })
      tId = parentRaf.apply(this, args)
      self._addTransactionTask('raf' + tId)
      self.log(' + requestAnimationFrame ')
      return tId
    }
  }

  function cancelRafPatch (id) {
    this._removeTransactionTask('raf' + id)
    this.log('cancelAnimationFrame')
  }

  this.events = new Subscription()
  // var zoneService = this
  function noop () { }
  var spec = this.spec = {
    onAddTask: noop,
    onRemoveTask: noop,
    onDetectFinish: noop
  }

  var zoneConfig = {
    log: function log (methodName, theRest) {
      var logText = 'Zone(' + this.$id + ') parent(' + this.parent.$id + ') ' + methodName
      var logArray = [logText]
      if (!utils.isUndefined(theRest)) {
        logArray.push(theRest)
      }
      logger.debug.apply(logger, logArray)
    },
    // onZoneCreated: function () {
    //   this.log('onZoneCreated')
    // },
    beforeTask: function () {
      var sig = this.signature
      this.log('beforeTask', (typeof sig === 'undefined' ? undefined : ' signature: ' + sig))
    },
    afterTask: function () {
      var sig = this.signature
      this.log('afterTask', (typeof sig === 'undefined' ? undefined : ' signature: ' + sig))
      this._detectFinish()
    },
    // '-onError': function () {
    //   this.log('onError')
    // },
    // enqueueTask: function () {
    //   this.log('enqueueTask', arguments)
    // },
    // dequeueTask: function () {
    //   this.log('dequeueTask', arguments)
    // },
    $setTimeout: function (parentTimeout) {
      return function (timeoutFn, delay) {
        var self = this
        if (delay === 0 && typeof timeoutFn === 'function') {
          var args = patchUtils.argumentsToArray(arguments)
          var tId
          args[0] = patchUtils.wrapAfter(timeoutFn, function () {
            self._removeTransactionTask('setTimeout' + tId)
            self.log(' - setTimeout ', ' delay: ' + delay)
          })
          tId = parentTimeout.apply(this, args)
          self._addTransactionTask('setTimeout' + tId)
          self.log(' + setTimeout ', ' delay: ' + delay)
          return tId
        } else {
          return parentTimeout.apply(this, arguments)
        }
      }
    },
    '-clearTimeout': function (id) {
      this._removeTransactionTask('setTimeout' + id)
      this.log('clearTimeout', this.timeout)
    },
    '$requestAnimationFrame': rafPatch,
    '-cancelAnimationFrame': cancelRafPatch,

    '$webkitRequestAnimationFrame': rafPatch,
    '-webkitCancelAnimationFrame': cancelRafPatch,

    '$mozRequestAnimationFrame': rafPatch,
    '-mozCancelAnimationFrame': cancelRafPatch

  // $addEventListener: function (parentAddEventListener) {
{'fraction_non_alphanumeric': 0.1395971041863393, 'fraction_numerical': 0.0009442870632672333, 'mean_word_length': 2.562219730941704, 'pattern_counts': {'":': 0, '<': 3, '<?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': '5502713', 'n_tokens_mistral': 1878, 'n_tokens_neox': 1860, 'n_words': 389}