<commit_before>
(function(ko, global){

  if(!ko)return;
  /**
   * Subscribable Objects implement the publish-subscribe pattern.
   * @constructor 
   */
  function Subscribable(){

    /**
     * Subscribable can only be called as a constructor.
     */
    if (!(this instanceof Subscribable))return new Subscribable();

    /**
     * This gets the subscribers that were registered with this object. 
     * The event names server as keys here for values which are arrays 
     * containg the subscribers registerd for that event.
     * @type {Object}
     */
    this.subscribers = function(event){
      var result = this._s || (this._s = {});
      if(event)result = result[event] || (result[event] = []);
      return result;
    }

    /**
     * The default event indicates that the value has changed.
     * @type {String}
     */
    var defaultEvent = "change";

    /**
     * All subscribers that were registered with the specified event 
     * parameter will be called. When a custome notify function is 
     * needed hockNotify can be defined to execute object specific logic. 
     * @param  {[type]} value - if defined replaced by options.read
     * @param  {[type]} event - when no specified the default is used
     */
    this.notifySubscribers = function(value, event){
      event = event || defaultEvent;
      var dependencies = this.subscribers(event);
      try{
        if(this.getter)value = this.getter();
      }finally{
        var length = dependencies.length;
        for(var i = 0; i < length; i++){
          if(!dependencies[i]._d){  // _d = diposed
            dependencies[i].cb.call(dependencies[i].context, value);
          }
        }
        for(i = 0; i < length; i++){
          if(dependencies[i]._d){ // _d = diposed
            dependencies.splice(i, 1);
            i--; length--;
          } 
        }
      }
    };

    /**
     * Add a subscriber to this object. When notify is executed the 
     * callback parameter is called with the context specified here.  
     * @param  {Function} cb      - the subscription callback
     * @param  {Any}      context - if true replaced with the context that
     *                              subscribe is called with. 
     * @param  {String}   event   - when no specified the default is used
     */
    this.subscribe = function(cb, context, event){
      if(this.deferEvaluation && this.peek)this.peek();
      event = event || defaultEvent;
      if(typeof cb !== "function")throw new Error("First parameter musst be a function.");
      var dependency = {cb: cb, context: context};
      this.subscribers(event).push(dependency);
      function dispose(){ dependency._d = true; }; // _d = diposed
      return { dispose: dispose };
    };

    /**
     * This copyies all properties from a subscribable object onto another
     * object, which can then be used just like the original subcriber. This 
     * is needed so that a function may become a subscriber. In the case of
     * a function this can't be done using just prototype.
     * @param  {Any} target - this target will become subscribable
     */
    this.copyProperties = function(target){
      for(var i in this)target[i] = this[i];
      target._clonedFrom = this;
      return target;
    };

    /**
     * Extend via properties 
     * @param  {[type]} properties [description]
     * @return {[type]}            [description]
     */
    this.extend = function(properties){
      for(var i in properties)this[i] = properties[i];
      return this;
    }

    /**
     * Returns the number of subscriptions for the specific event name.
     * @return {Integer} Nr. of subscriptions on this object
     */
    this.getSubscriptionsCount = function(){
      var count = 0, dependencies = this.subscribers();
      for(var i in dependencies){
        for(var j in dependencies[i]){
          if(!dependencies[i][j]._d)count++; // _d = diposed
        }
      }
      return count;
    }
  }


  var stack = [];
  function recordDependency(dependency){
    var length = stack.length;
    var last = length > 0 ? stack[length-1] : [];
    for(var i in last)if(last[i] === dependency)return;
    last.push(dependency);
  }
  function recordExecution(func, context, observable){
    if(observable.recording || !func)return observable.value;
    var result = [];
    observable.recording = true;
    stack.push(result);
    var previous = ko.computedContext;
    ko.computedContext = {<commit_msg>Clarification property disposed<commit_after>
(function(ko, global){

  if(!ko)return;
  /**
   * Subscribable Objects implement the publish-subscribe pattern.
   * @constructor 
   */
  function Subscribable(){

    /**
     * Subscribable can only be called as a constructor.
     */
    if (!(this instanceof Subscribable))return new Subscribable();

    /**
     * This gets the subscribers that were registered with this object. 
     * The event names server as keys here for values which are arrays 
     * containg the subscribers registerd for that event.
     * @type {Object}
     */
    this.subscribers = function(event){
      var result = this._s || (this._s = {});
      if(event)result = result[event] || (result[event] = []);
      return result;
    }

    /**
     * The default event indicates that the value has changed.
     * @type {String}
     */
    var defaultEvent = "change";

    /**
     * All subscribers that were registered with the specified event 
     * parameter will be called. When a custome notify function is 
     * needed hockNotify can be defined to execute object specific logic. 
     * @param  {[type]} value - if defined replaced by options.read
     * @param  {[type]} event - when no specified the default is used
     */
    this.notifySubscribers = function(value, event){
      event = event || defaultEvent;
      var dependencies = this.subscribers(event);
      try{
        if(this.getter)value = this.getter();
      }finally{
        var length = dependencies.length;
        for(var i = 0; i < length; i++){
          if(!dependencies[i]._p){ // _p = dependency diposed
            dependencies[i].cb.call(dependencies[i].context, value);
          }
        }
        for(i = 0; i < length; i++){
          if(dependencies[i]._p){ // _p = dependency diposed
            dependencies.splice(i, 1);
            i--; length--;
          } 
        }
      }
    };

    /**
     * Add a subscriber to this object. When notify is executed the 
     * callback parameter is called with the context specified here.  
     * @param  {Function} cb      - the subscription callback
     * @param  {Any}      context - if true replaced with the context that
     *                              subscribe is called with. 
     * @param  {String}   event   - when no specified the default is used
     */
    this.subscribe = function(cb, context, event){
      if(this.deferEvaluation && this.peek)this.peek();
      event = event || defaultEvent;
      if(typeof cb !== "function")throw new Error("First parameter musst be a function.");
      var dependency = {cb: cb, context: context};
      this.subscribers(event).push(dependency);
      function dispose(){ dependency._p = true; }; // _p = dependency diposed
      return { dispose: dispose };
    };

    /**
     * This copyies all properties from a subscribable object onto another
     * object, which can then be used just like the original subcriber. This 
     * is needed so that a function may become a subscriber. In the case of
     * a function this can't be done using just prototype.
     * @param  {Any} target - this target will become subscribable
     */
    this.copyProperties = function(target){
      for(var i in this)target[i] = this[i];
      target._clonedFrom = this;
      return target;
    };

    /**
     * Extend via properties 
     * @param  {[type]} properties [description]
     * @return {[type]}            [description]
     */
    this.extend = function(properties){
      for(var i in properties)this[i] = properties[i];
      return this;
    }

    /**
     * Returns the number of subscriptions for the specific event name.
     * @return {Integer} Nr. of subscriptions on this object
     */
    this.getSubscriptionsCount = function(){
      var count = 0, dependencies = this.subscribers();
      for(var i in dependencies){
        for(var j in dependencies[i]){
          if(!dependencies[i][j]._p)count++; // _p = dependency diposed
        }
      }
      return count;
    }
  }


  var stack = [];
  function recordDependency(dependency){
    var length = stack.length;
    var last = length > 0 ? stack[length-1] : [];
    for(var i in last)if(last[i] === dependency)return;
    last.push(dependency);
  }
  function recordExecution(func, context, observable){
    if(observable.recording || !func)return observable.value;
    var result = [];
    observable.recording = true;
    stack.push(result);
    var previous = ko.computedContext;
    ko.computedContext = {
{'fraction_non_alphanumeric': 0.11201244582731415, 'fraction_numerical': 0.001333481497944216, 'mean_word_length': 2.345724907063197, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '761365', 'n_tokens_mistral': 2549, 'n_tokens_neox': 2437, 'n_words': 824}