<commit_before>kefir = require('kefir')

function autoRelease(obs) {
  this.children = [];
  this.refEnd = [];
  this.refValue = [];
  this.refBoth = [];
  this.refLog = [];

  if(obs instanceof autoRelease) {
    this.__obs = obs.__obs;
  } else {
    this.__obs = obs;
  }
}

kefir.AUTO_RELEASE_EMITED = 1;
kefir.AUTO_RELEASE_ENDED = 2;
kefir.AUTO_RELEASE_BOTH = 3;

autoRelease.prototype.map = function(a,b) {var ret; this.children.push(ret = new autoRelease(this.__obs.map(a,b))); return ret;},
autoRelease.prototype.mapTo = function(a,b) {var ret; this.children.push(ret = new autoRelease(this.__obs.mapTo(a,b))); return ret;},
autoRelease.prototype.pluck = function(a,b) {var ret; this.children.push(ret = new autoRelease(this.__obs.pluck(a,b))); return ret;},
autoRelease.prototype.invoke = function(a,b) {var ret; this.children.push(ret = new autoRelease(this.__obs.invoke(a,b))); return ret;},
autoRelease.prototype.not = function(a,b) {var ret; this.children.push(ret = new autoRelease(this.__obs.not(a,b))); return ret;},
autoRelease.prototype.timestamp = function(a,b) {var ret; this.children.push(ret = new autoRelease(this.__obs.timestamp(a,b))); return ret;},
autoRelease.prototype.tap = function(a,b) {var ret; this.children.push(ret = new autoRelease(this.__obs.tap(a,b))); return ret;},
autoRelease.prototype.filter = function(a,b) {var ret; this.children.push(ret = new autoRelease(this.__obs.filter(a,b))); return ret;},
autoRelease.prototype.take = function(a,b) {var ret; this.children.push(ret = new autoRelease(this.__obs.take(a,b))); return ret;},
autoRelease.prototype.takeWhile = function(a,b) {var ret; this.children.push(ret = new autoRelease(this.__obs.takeWhile(a,b))); return ret;},
autoRelease.prototype.skip = function(a,b) {var ret; this.children.push(ret = new autoRelease(this.__obs.skip(a,b))); return ret;},
autoRelease.prototype.skipWhile = function(a,b) {var ret; this.children.push(ret = new autoRelease(this.__obs.skipWhile(a,b))); return ret;},
autoRelease.prototype.skipDuplicates = function(a,b) {var ret; this.children.push(ret = new autoRelease(this.__obs.skipDuplicates(a,b))); return ret;},
autoRelease.prototype.diff = function(a,b) {var ret; this.children.push(ret = new autoRelease(this.__obs.diff(a,b))); return ret;},
autoRelease.prototype.scan = function(a,b) {var ret; this.children.push(ret = new autoRelease(this.__obs.scan(a,b))); return ret;},
autoRelease.prototype.reduce = function(a,b) {var ret; this.children.push(ret = new autoRelease(this.__obs.reduce(a,b))); return ret;},
autoRelease.prototype.slidingWindow = function(a,b) {var ret; this.children.push(ret = new autoRelease(this.__obs.slidingWindow(a,b))); return ret;},
autoRelease.prototype.delay = function(a,b) {var ret; this.children.push(ret = new autoRelease(this.__obs.delay(a,b))); return ret;},
autoRelease.prototype.throttle = function(a,b) {var ret; this.children.push(ret = new autoRelease(this.__obs.throttle(a,b))); return ret;},
autoRelease.prototype.debounce = function(a,b) {var ret; this.children.push(ret = new autoRelease(this.__obs.debounce(a,b))); return ret;},
autoRelease.prototype.flatten = function(a,b) {var ret; this.children.push(ret = new autoRelease(this.__obs.flatten(a,b))); return ret;},
autoRelease.prototype.transduce = function(a,b) {var ret; this.children.push(ret = new autoRelease(this.__obs.transduce(a,b))); return ret;},
autoRelease.prototype.withHandler = function(a,b) {var ret; this.children.push(ret = new autoRelease(this.__obs.withHandler(a,b))); return ret;},
autoRelease.prototype.toProperty = function(a,b) {var ret; this.children.push(ret = new autoRelease(this.__obs.toProperty(a,b))); return ret;},
autoRelease.prototype.changes = function(a,b) {var ret; this.children.push(ret = new autoRelease(this.__obs.changes(a,b))); return ret;},
autoRelease.prototype.flatMap = function(a,b) {var ret; this.children.push(ret = new autoRelease(this.__obs.flatMap(a,b))); return ret;},
autoRelease.prototype.flatMapLatest = function(a,b) {var ret; this.children.push(ret = new autoRelease(this.__obs.flatMapLatest(a,b))); return ret;},
autoRelease.prototype.flatMapFirst = function(a,b) {var ret; this.children.push(ret = new autoRelease(this.__obs.flatMapFirst(a,b))); return ret;},
autoRelease.prototype.flatMapConcat = function(a,b) {var ret; this.children.push(ret = new autoRelease(this.__obs.flatMapConcat(a,b))); return ret;},
autoRelease.prototype.flatMapConcurLimit = function(a,b) {var ret; this.children.push(ret = new autoRelease(this.__obs.flatMapConcurLimit(a,b))); return ret;},
autoRelease.prototype.awaiting = function(a,b) {var ret; this.children.push(ret = new autoRelease(this.__obs.awaiting(a,b))); return ret;},
autoRelease.prototype.filterBy = function(a,b) {var ret; this.children.push(ret = new autoRelease(this.__obs.filterBy(a,b))); return ret;}

autoRelease.prototype.emit = function(a) {
  this.__obs.emit(a);
  return this;
}

autoRelease.prototype.end = function() {
  this.__obs.end();
  return this;
}

autoRelease.prototype.on = function(fn, type) {
  if(type === kefir.AUTO_RELEASE_ENDED) {
    this.refEnd.push(fn);
    this.__obs.onEnd(fn);
  } else if(type === kefir.AUTO_RELEASE_BOTH) {
    this.refBoth.push(fn);
    this.__obs.onAny(fn);
  } else {
    this.refValue.push(fn);
    this.__obs.onValue(fn);
  }

  return this;
}

autoRelease.prototype.log = function(name) {
  this.refLog.push(name);
  this.__obs.log(name);<commit_msg>feat: as a dev I want observables to track the owner/sender of the events to help filter<commit_after>kefir = require('kefir')

/**
 *
 * @param obs
 * @param _owner is the default sender for all messages
 */
function autoRelease(obs, owner) {
  this.children = [];
  this.refEnd = [];
  this.refValue = [];
  this.refBoth = [];
  this.refLog = [];

  this.owner = owner;

  if(obs instanceof autoRelease) {
    this.__obs = obs.__obs;
  } else if(obs) {
    this.__obs = obs;
  } else {
    this.__obs = kefir.emitter();
  }
}

autoRelease.prototype.AUTO_RELEASE_EMITED = kefir.AUTO_RELEASE_EMITED = 1;
autoRelease.prototype.AUTO_RELEASE_ENDED = kefir.AUTO_RELEASE_ENDED = 2;
autoRelease.prototype.AUTO_RELEASE_BOTH = kefir.AUTO_RELEASE_BOTH = 3;

autoRelease.prototype.map = function(a) {var ret; this.children.push(ret = new autoRelease(this.__obs.map(a), this.owner)); return ret;};
autoRelease.prototype.mapTo = function(a) {var ret; this.children.push(ret = new autoRelease(this.__obs.mapTo(a), this.owner)); return ret;};
autoRelease.prototype.pluck = function(a) {var ret; this.children.push(ret = new autoRelease(this.__obs.pluck(a), this.owner)); return ret;};
autoRelease.prototype.invoke = function(a) {var ret; this.children.push(ret = new autoRelease(this.__obs.invoke(a), this.owner)); return ret;};
autoRelease.prototype.not = function() {var ret; this.children.push(ret = new autoRelease(this.__obs.not(), this.owner)); return ret;};
autoRelease.prototype.timestamp = function() {var ret; this.children.push(ret = new autoRelease(this.__obs.timestamp(), this.owner)); return ret;};
autoRelease.prototype.tap = function(a) {var ret; this.children.push(ret = new autoRelease(this.__obs.tap(a), this.owner)); return ret;};
autoRelease.prototype.filter = function(a) {var ret; this.children.push(ret = new autoRelease(this.__obs.filter(a), this.owner)); return ret;};
autoRelease.prototype.take = function(a) {var ret; this.children.push(ret = new autoRelease(this.__obs.take(a), this.owner)); return ret;};
autoRelease.prototype.takeWhile = function(a) {var ret; this.children.push(ret = new autoRelease(this.__obs.takeWhile(a), this.owner)); return ret;};
autoRelease.prototype.skip = function(a) {var ret; this.children.push(ret = new autoRelease(this.__obs.skip(a), this.owner)); return ret;};
autoRelease.prototype.skipWhile = function(a) {var ret; this.children.push(ret = new autoRelease(this.__obs.skipWhile(a), this.owner)); return ret;};
autoRelease.prototype.skipDuplicates = function(a) {var ret; this.children.push(ret = new autoRelease(this.__obs.skipDuplicates(a), this.owner)); return ret;};
autoRelease.prototype.diff = function(a,b) {var ret; this.children.push(ret = new autoRelease(this.__obs.diff(a,b), this.owner)); return ret;};
autoRelease.prototype.scan = function(a,b) {var ret; this.children.push(ret = new autoRelease(this.__obs.scan(a,b), this.owner)); return ret;};
autoRelease.prototype.reduce = function(a,b) {var ret; this.children.push(ret = new autoRelease(this.__obs.reduce(a,b), this.owner)); return ret;};
autoRelease.prototype.slidingWindow = function(a,b) {var ret; this.children.push(ret = new autoRelease(this.__obs.slidingWindow(a,b), this.owner)); return ret;};
autoRelease.prototype.delay = function(a) {var ret; this.children.push(ret = new autoRelease(this.__obs.delay(a), this.owner)); return ret;};
autoRelease.prototype.throttle = function(a,b) {var ret; this.children.push(ret = new autoRelease(this.__obs.throttle(a,b), this.owner)); return ret;};
autoRelease.prototype.debounce = function(a,b) {var ret; this.children.push(ret = new autoRelease(this.__obs.debounce(a,b), this.owner)); return ret;};
autoRelease.prototype.flatten = function(a) {var ret; this.children.push(ret = new autoRelease(this.__obs.flatten(a), this.owner)); return ret;};
autoRelease.prototype.transduce = function(a) {var ret; this.children.push(ret = new autoRelease(this.__obs.transduce(a), this.owner)); return ret;};
autoRelease.prototype.withHandler = function(a) {var ret; this.children.push(ret = new autoRelease(this.__obs.withHandler(a), this.owner)); return ret;};
autoRelease.prototype.toProperty = function(a) {var ret; this.children.push(ret = new autoRelease(this.__obs.toProperty(a), this.owner)); return ret;};
autoRelease.prototype.changes = function() {var ret; this.children.push(ret = new autoRelease(this.__obs.changes(), this.owner)); return ret;};
autoRelease.prototype.flatMap = function(a) {var ret; this.children.push(ret = new autoRelease(this.__obs.flatMap(a), this.owner)); return ret;};
autoRelease.prototype.flatMapLatest = function(a) {var ret; this.children.push(ret = new autoRelease(this.__obs.flatMapLatest(a), this.owner)); return ret;};
autoRelease.prototype.flatMapFirst = function(a) {var ret; this.children.push(ret = new autoRelease(this.__obs.flatMapFirst(a), this.owner)); return ret;};
autoRelease.prototype.flatMapConcat = function(a) {var ret; this.children.push(ret = new autoRelease(this.__obs.flatMapConcat(a), this.owner)); return ret;};
autoRelease.prototype.flatMapConcurLimit = function(a,b) {var ret; this.children.push(ret = new autoRelease(this.__obs.flatMapConcurLimit(a,b), this.owner)); return ret;};
autoRelease.prototype.awaiting = function(a) {var ret; this.children.push(ret = new autoRelease(this.__obs.awaiting(a), this.owner)); return ret;};
autoRelease.prototype.filterBy = function(a) {var ret; this.children.push(ret = new autoRelease(this.__obs.filterBy(a), this.owner)); return ret;};

// need to add combine, and, or

autoRelease.prototype.emit = function(a, sender) {
  var _sender = sender || this.owner;
  if(_sender) {
    this.__obs.emit({sender:_sender, event:a});
  } else {
    this.__obs.emit(a);
  }

  return this;
}

autoRelease.prototype.end = function() {
  this.__obs.end();
  return this;
}

autoRelease.prototype.on = function(fn, type) {
  if(type === kefir.AUTO_RELEASE_ENDED) {
    this.refEnd.push(fn);
    this.__obs.onEnd(fn);
  } else if(type === kefir.AUTO_RELEASE_BOTH) {
    this.refBoth.push(fn);
    this.__obs.onAny(fn);
  } else {
    this.refValue.push(fn);
    this.__obs.onValue(fn);
  }

  return this;
}

autoRelease.prototype.log = function(name) {
  this.refLog.push(name);
  this.__obs.log(name);
{'fraction_non_alphanumeric': 0.16478439425051336, 'fraction_numerical': 0.000513347022587269, 'mean_word_length': 5.883981154299176, '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': '722817', 'n_tokens_mistral': 3925, 'n_tokens_neox': 3894, 'n_words': 767}