<commit_before>'use strict'

var Promise = require('bluebird')
Promise.config({ cancellation: true })

exports.define = {
  is (val, callback, event) {
    var type = typeof val
    var compare
    var promise
    var parsed = this.val
    var _this = this

    if (type === 'function') {
      compare = val
    } else {
      compare = function (compare) {
        return compare == val //eslint-disable-line
      }
    }

    if (!callback) {
      let cancel = function () {
        promise.cancel()
      }
      promise = new Promise(function (resolve, reject, onCancel) {
        onCancel(function () {
          _this.off('data', is)
          _this.off('remove', cancel)
        })
        // reject
        callback = function (data, event) {
          _this.off('remove', cancel)
          resolve(this, data, event)
        }
      })
      _this.on('remove', cancel)
    }

    if (compare(parsed)) {
      if (callback) {
        callback.call(this, parsed, event)
      }
    } else {
      this.on('data', is)
    }

    // use attach not a closure
    function is (data, event) {
      if (compare(this.val)) {
        _this.off('data', is)
        callback.call(this, data, event)
      }
    }

    return promise || this
  }
}
<commit_msg>is passes event and data<commit_after>'use strict'

var Promise = require('bluebird')
Promise.config({ cancellation: true })

exports.define = {
  is (val, callback, event) {
    var type = typeof val
    var compare
    var promise
    var parsed = this.val
    var _this = this

    if (type === 'function') {
      compare = val
    } else {
      compare = function (compare) {
        return compare == val //eslint-disable-line
      }
    }

    if (!callback) {
      let cancel = function () {
        promise.cancel()
      }
      promise = new Promise(function (resolve, reject, onCancel) {
        onCancel(function () {
          _this.off('data', is)
          _this.off('remove', cancel)
        })
        // reject
        callback = function (data, event) {
          _this.off('remove', cancel)
          resolve(this, data, event)
        }
      })
      _this.on('remove', cancel)
    }

    if (compare(parsed, void 0, event)) {
      if (callback) {
        callback.call(this, parsed, event)
      }
    } else {
      this.on('data', is)
    }

    // use attach not a closure
    function is (data, event) {
      if (compare(this.val, data, event)) {
        _this.off('data', is)
        callback.call(this, data, event)
      }
    }

    return promise || this
  }
}

{'fraction_non_alphanumeric': 0.13208284486127395, 'fraction_numerical': 0.00039077764751856197, 'mean_word_length': 1.8507795100222717, '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': '2184154', 'n_tokens_mistral': 775, 'n_tokens_neox': 769, 'n_words': 205}