<commit_before>var deepEqual = require('deep-equal');

module.exports = function(Tembo){
  'use strict';
  Tembo._.upCall = function(lifecycleMethod,instance){
    if (instance.component){
      if (instance.component.componentWillUnmount){
        instance.component[lifecycleMethod]();
      }else{
        Tembo._.upCall(lifecycleMethod,instance.component);
      }
    }else{
      console.log('if your code reach this line, send-me a e-mail <EMAIL> . I would love to work with you in my new project');
    }
  };

  Tembo._.patchAttributes = function(component,newComponent){

    var instance = component.instance;
    var oldProps = component.props;
    var newProps = newComponent.props;

    Object.keys(newProps).forEach(function(key){
      if (key === 'data-tamboId') return;
      if (key === 'children') return;
      if (oldProps[key] === newProps[key]) return;
      Tembo.$.setProp(instance,key,newProps[key]);
    });
  };

  Tembo._.patchChildren = function(instance,newInstance){

    var SilentDiff = {};
    var children = Tembo.$.getChildren(intstance);
    children.forEach(function(element){
      var id = Tembo.$.getId(element);
      if (!SilentDiff[id]) SilentDiff[id] = {};

      SilentDiff[id].a = element;
    });

    var newChildren = Tembo.$.getChildren(newInstance);
    newChildren.forEach(function(element){
      var id = Tembo.$.getId(element);
      if (!SilentDiff[id]) SilentDiff[id] = {};
      SilentDiff[id].b = element;
    });

    Object.keys(SilentDiff).forEach(function(key){
      var patch = SilentDiff[key];
      if (patch.a === void 0 && patch.b !== void 0){
        Tembo._.upCall('componentWillMount',patch.b);
        Tembo.$.appendChild(instance,patch.b);
      }else if (patch.a !== void 0 && patch.b === void 0){
        Tembo._.upCall('componentWillUnmount',patch.a);
        Tembo.$.removeChild(instance,patch.a);
      } // else{
      // if a !== b
      // Tembo._.upCall('componentWillUpdate',patch.a,patch.b);
      // Tembo.$.replace(instance,patch.a,patch.b);
      // }
    });

    // newInstance.attributes,function(attr){
    // instance.setAttribute(attr.localName,attr.value);
    // });
  };

  Tembo._.patchText = function(instance,newInstance){
    var children = Tembo.$.getChildren(newInstance);
    if (!children.length || children.length === 1 && Tembo.$.isText(children[0])){
      var oldChildren = Tembo.$.getChildren(newInstance);
      if (oldChildren.length){
        oldChildren.forEach(function(child){
          Tembo._.upCall('componentWillUnmount',child);
          Tembo.$.removeChild(instance,child);
        });
      }
      Tembo.$.setText(instance,Tembo.$.getText(newInstance));
      return true;
    }
  };

  //File : src/Tembo._.deeplyCompare.js

  Tembo._.deeplyCompare = function(element,reRenderedElement){

    var instance = element;
    var newInstance = reRenderedElement;

    var dirty = Tembo._.compareChildren(element, reRenderedElement);

    newInstance.instance = newInstance.render();
    newInstance.instance.component = newInstance;

    Tembo._.patchAttributes(instance,newInstance);
    if (!Tembo._.patchText(instance.instance,newInstance.instance)){
      Tembo._.patchChildren(instance.instance,newInstance.instance);
    }

    return false;

  };

  Tembo._.compareChildren = function(element,newElement){
    var oldChildren = element.props.children;
    var newChildren = newElement.props.children;

    if (oldChildren.length === newChildren.length === 0){
      return false;
    }
    var dirty = false;
    var l = Math.min(oldChildren.length,newChildren.length);
    for(var i = 0; i < l; i++){
      var oldChild = oldChildren[i];
      var newChild = newChildren[i];
      if (!Tembo._.deeplyCompare(oldChild,newChild)){
        dirty = true;
      }
    }

    var diff = oldChildren.length - newChildren.length;
    if (diff > 0){
      while(diff-- !== 0){
        Tembo.removeChild(element,oldChildren[diff + l]);
      }
      dirty = true;
    }else if (diff < 0){
      diff *= -1;
      while(diff-- !== 0){
        Tembo.appendChild(element,newChildren[diff + l]);
      }
      dirty = true;
    }

    return dirty;
  };
};<commit_msg>comparing in its own folder<commit_after>var deepEqual = require('deep-equal');

module.exports = function(Tembo){
  'use strict';
  Tembo._.upCall = function(lifecycleMethod,instance){
    if (instance.component){
      if (instance.component.componentWillUnmount){
        instance.component[lifecycleMethod]();
      }else{
        Tembo._.upCall(lifecycleMethod,instance.component);
      }
    }else{
      console.log('if your code reach this line, send-me a e-mail <EMAIL> . I would love to work with you in my new project');
    }
  };

  Tembo._.patchAttributes = function(component,newComponent){

    var instance = component.instance;
    var oldProps = component.props;
    var newProps = newComponent.props;

    Object.keys(newProps).forEach(function(key){
      if (key === 'data-tamboId') return;
      if (key === 'children') return;
      if (oldProps[key] === newProps[key]) return;
      Tembo.$.setProp(instance,key,newProps[key]);
    });
  };

  Tembo._.patchChildren = function(instance,newInstance){

    var SilentDiff = {};
    var children = Tembo.$.getChildren(intstance);
    children.forEach(function(element){
      var id = Tembo.$.getId(element);
      if (!SilentDiff[id]) SilentDiff[id] = {};

      SilentDiff[id].a = element;
    });

    var newChildren = Tembo.$.getChildren(newInstance);
    newChildren.forEach(function(element){
      var id = Tembo.$.getId(element);
      if (!SilentDiff[id]) SilentDiff[id] = {};
      SilentDiff[id].b = element;
    });

    Object.keys(SilentDiff).forEach(function(key){
      var patch = SilentDiff[key];
      if (patch.a === void 0 && patch.b !== void 0){
        Tembo._.upCall('componentWillMount',patch.b);
        Tembo.$.appendChild(instance,patch.b);
      }else if (patch.a !== void 0 && patch.b === void 0){
        Tembo._.upCall('componentWillUnmount',patch.a);
        Tembo.$.removeChild(instance,patch.a);
      } // else{
      // if a !== b
      // Tembo._.upCall('componentWillUpdate',patch.a,patch.b);
      // Tembo.$.replace(instance,patch.a,patch.b);
      // }
    });

    // newInstance.attributes,function(attr){
    // instance.setAttribute(attr.localName,attr.value);
    // });
  };

  Tembo._.patchText = function(instance,newInstance){
    var children = Tembo.$.getChildren(newInstance);
    if (!children.length || children.length === 1 && Tembo.$.isText(children[0])){
      var oldChildren = Tembo.$.getChildren(newInstance);
      if (oldChildren.length){
        oldChildren.forEach(function(child){
          Tembo._.upCall('componentWillUnmount',child);
          Tembo.$.removeChild(instance,child);
        });
      }
      Tembo.$.setText(instance,Tembo.$.getText(newInstance));
      return true;
    }
  };

  //File : src/Tembo._.deeplyCompare.js

  Tembo._.deeplyCompare = function(element,reRenderedElement){

    var instance = element;
    var newInstance = reRenderedElement;

    var dirty = Tembo._.compareChildren(element, reRenderedElement);

    newInstance.instance = newInstance.render();
    newInstance.instance.component = newInstance;

    Tembo._.patchAttributes(instance,newInstance);
    if (!Tembo._.patchText(instance.instance,newInstance.instance)){
      Tembo._.patchChildren(instance.instance,newInstance.instance);
    }

    return false;

  };
};
{'fraction_non_alphanumeric': 0.15246995994659546, 'fraction_numerical': 0.0025367156208277704, 'mean_word_length': 3.0339256865912763, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 6, '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': '6871136', 'n_tokens_mistral': 2345, 'n_tokens_neox': 2283, 'n_words': 401}