<commit_before>(function(){
  function buildVueDragFor(_, Sortable){

    function mix(source, functions){
      _.forEach(['bind', 'update', 'unbind'],function(value){
          var original = source[value];
          source[value] = function(){
            functions[value].apply(this, arguments);
            return original.apply(this, arguments);
          };
      });
    }
    
    var vueDragFor = {
      install : function(Vue) {
        var forDirective = Vue.directive('for');
        var dragableForDirective = _.clone(forDirective);
        dragableForDirective.params = dragableForDirective.params.concat('root', 'options');

        mix(dragableForDirective, {
          bind : function () {    
            var ctx = this;    
            var options = this.params.options;
            options = _.isString(options)? JSON.parse(options) : options;
            options = _.merge(options,{
              onUpdate: function (evt) {
                var collection = ctx.collection;
                if (!!collection)
                  collection.splice(evt.newIndex, 0, collection.splice(evt.oldIndex, 1)[0] );
              },
              onAdd: function (evt) {
                var directive = evt.from.__directive;
                if ((!!directive) && (!!ctx.collection))
                  ctx.collection.splice(evt.newIndex, 0, directive.collection[evt.oldIndex]);
              },
              onRemove: function (evt) {
                if (!!ctx.collection)
                  ctx.collection.splice(evt.oldIndex, 1);
              }
            });
            var parent = (!!this.params.root) ? document.getElementById(this.params.root) : this.el.parentElement;
            parent.__directive = this;
            this._sortable = new Sortable(parent, options);
          },
          update : function (value){
            if ((!!value) && (!Array.isArray(value)))
              throw new Error('should received an Array');

            this.collection = value;
          },
          unbind : function (){
            this._sortable.destroy();
          }
        });

        Vue.directive('dragable-for', dragableForDirective);
      }
    };
    return vueDragFor;
  }

  if (typeof exports == "object") {
    var _ = require("lodash");
    var Sortable =  require("Sortable");
    module.exports = buildVueDragFor(_, Sortable);
  } else if (typeof define == "function" && define.amd) {
    define(['lodash', 'Sortable'], function(_, Sortable){ return buildVueDragFor(_, Sortable);});<commit_msg>Fix reference to lodash (issue #3)<commit_after>(function(){
  function buildVueDragFor(_, Sortable){

    function mix(source, functions){
      _.forEach(['bind', 'update', 'unbind'],function(value){
          var original = source[value];
          source[value] = function(){
            functions[value].apply(this, arguments);
            return original.apply(this, arguments);
          };
      });
    }
    
    var vueDragFor = {
      install : function(Vue) {
        var forDirective = Vue.directive('for');
        var dragableForDirective = _.clone(forDirective);
        dragableForDirective.params = dragableForDirective.params.concat('root', 'options');

        mix(dragableForDirective, {
          bind : function () {    
            var ctx = this;    
            var options = this.params.options;
            options = _.isString(options)? JSON.parse(options) : options;
            options = _.merge(options,{
              onUpdate: function (evt) {
                var collection = ctx.collection;
                if (!!collection)
                  collection.splice(evt.newIndex, 0, collection.splice(evt.oldIndex, 1)[0] );
              },
              onAdd: function (evt) {
                var directive = evt.from.__directive;
                if ((!!directive) && (!!ctx.collection))
                  ctx.collection.splice(evt.newIndex, 0, directive.collection[evt.oldIndex]);
              },
              onRemove: function (evt) {
                if (!!ctx.collection)
                  ctx.collection.splice(evt.oldIndex, 1);
              }
            });
            var parent = (!!this.params.root) ? document.getElementById(this.params.root) : this.el.parentElement;
            parent.__directive = this;
            this._sortable = new Sortable(parent, options);
          },
          update : function (value){
            if ((!!value) && (!Array.isArray(value)))
              throw new Error('should received an Array');

            this.collection = value;
          },
          unbind : function (){
            this._sortable.destroy();
          }
        });

        Vue.directive('dragable-for', dragableForDirective);
      }
    };
    return vueDragFor;
  }

  if (typeof exports == "object") {
    var _ = require("lodash");
    var Sortable =  require("Sortablejs");
    module.exports = buildVueDragFor(_, Sortable);
  } else if (typeof define == "function" && define.amd) {
    define(['lodash', 'Sortable'], function(_, Sortable){ return buildVueDragFor(_, Sortable);});
{'fraction_non_alphanumeric': 0.13355691457881239, 'fraction_numerical': 0.002170053264943776, 'mean_word_length': 1.9579929988331388, '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': '5592442', 'n_tokens_mistral': 1387, 'n_tokens_neox': 1361, 'n_words': 276}