<commit_before>var log = require('./log');

function isIncludedInUp(migration, destination) {
  if(!destination) {
    return true;
  }
  var migrationTest = migration.name.substring(0, Math.min(migration.name.length, destination.length));
  var destinationTest = destination.substring(0, Math.min(migration.name.length, destination.length));
  return migrationTest <= destinationTest;
}

exports.filterUp = function(allMigrations, completedMigrations, destination, count) {
  var sortFn = function(a, b) {
    return a.name.slice(0, a.name.indexOf('-')) - b.name.slice(0, b.name.indexOf('-'));
  };

  return allMigrations.sort(sortFn)
  .filter(function(migration) {
    var hasRun = completedMigrations.some(function(completedMigration) {
      return completedMigration.name === migration.name;
    });
    return !hasRun;
  })
  .filter(function(migration) {
    return isIncludedInUp(migration, destination);
  })
  .slice(0, count);
};

/**
  * Similar to the shadow driver, but we reduce to a subset of an existing
  * driver.
  */
exports.reduceToInterface = function(db, originInterface) {

  var Interface = {};
  Interface._original = {};

  for(var prop in db) {

    if (typeof Interface[prop] === "function" &&
        typeof db[prop] === "function") {

      Interface._original[prop] = db[prop];

      (function(property) {

        Interface[property] = function() { this._original[property].apply(this, arguments); };
      }(prop));
    }
    else if(typeof Interface[prop] === "function")
    {
      Interface[prop] = originInterface[prop];
    }
  }

  for(var prop in originInterface.deprecated) {

    if (typeof Interface[prop] === "function" &&
        typeof db[prop] === "function") {

      Interface._original[prop] = db[prop];

      (function(property) {

        Interface[property] = function() {

          log.warn('This function "' + property
          + '" is deprecated.' + "\n"
          + originInterface.deprecated[property + '_deprecation'] );

        this._original[property].apply(this, arguments);
      };
      }(prop));
    }
    else if(typeof Interface[prop] === "function")
    {
      Interface._original[prop] = originInterface[prop];

      (function(property) {

        Interface[property] = function() {

          log.warn('This function "' + property
          + '" is deprecated.' + "\n"
          + originInterface.deprecated[property + '_deprecation'] );

        this._original[property].apply(this, arguments);
      };
      }(prop));
    }
  }

  for(var prop in originInterface.extend) {

    if (typeof Interface[prop] === "function" &&
        typeof db[prop] === "function") {

      Interface[prop] = originInterface[prop];
    }
    else if(typeof Interface[prop] === "function")
    {
      Interface[prop] = originInterface[prop];
    }
  }

  return Interface;
};

exports.filterDown = function(completedMigrations, count) {
  return completedMigrations.slice(0, count);
};


exports.lpad = function(str, padChar, totalLength) {
  str = str.toString();
  var neededPadding = totalLength - str.length;
  for (var i = 0; i < neededPadding; i++) {
    str = padChar + str;
  }
  return str;
};

exports.shallowCopy = function(obj) {
  var newObj = {};
  for (var prop in obj) {
    newObj[prop] = obj[prop];
  }
  return newObj;
};

exports.toArray = function(obj) {
  var arr = [];
  for (var prop in obj) {
    arr[prop] = obj[prop];
  }
  return arr;
};

exports.isArray = function(obj) {
  return Object.prototype.toString.call(obj) == '[object Array]';
};

exports.isFunction = function(obj) {
  return typeof(obj) == 'function';
};

exports.isString = function(obj) {
  return typeof(obj) == 'string';
};
<commit_msg>add missing extend property<commit_after>var log = require('./log');

function isIncludedInUp(migration, destination) {
  if(!destination) {
    return true;
  }
  var migrationTest = migration.name.substring(0, Math.min(migration.name.length, destination.length));
  var destinationTest = destination.substring(0, Math.min(migration.name.length, destination.length));
  return migrationTest <= destinationTest;
}

exports.filterUp = function(allMigrations, completedMigrations, destination, count) {
  var sortFn = function(a, b) {
    return a.name.slice(0, a.name.indexOf('-')) - b.name.slice(0, b.name.indexOf('-'));
  };

  return allMigrations.sort(sortFn)
  .filter(function(migration) {
    var hasRun = completedMigrations.some(function(completedMigration) {
      return completedMigration.name === migration.name;
    });
    return !hasRun;
  })
  .filter(function(migration) {
    return isIncludedInUp(migration, destination);
  })
  .slice(0, count);
};

/**
  * Similar to the shadow driver, but we reduce to a subset of an existing
  * driver.
  */
exports.reduceToInterface = function(db, originInterface) {

  var Interface = {};
  Interface._original = {};

  for(var prop in db) {

    if (typeof Interface[prop] === "function" &&
        typeof db[prop] === "function") {

      Interface._original[prop] = db[prop];

      (function(property) {

        Interface[property] = function() { this._original[property].apply(this, arguments); };
      }(prop));
    }
    else if(typeof Interface[prop] === "function")
    {
      Interface[prop] = originInterface[prop];
    }
  }

  for(var prop in originInterface.deprecated) {

    if (typeof Interface[prop] === "function" &&
        typeof db[prop] === "function") {

      Interface._original[prop] = db[prop];

      (function(property) {

        Interface[property] = function() {

          log.warn('This function "' + property
          + '" is deprecated.' + "\n"
          + originInterface.deprecated[property + '_deprecation'] );

        this._original[property].apply(this, arguments);
      };
      }(prop));
    }
    else if(typeof Interface[prop] === "function")
    {
      Interface._original[prop] = originInterface[prop];

      (function(property) {

        Interface[property] = function() {

          log.warn('This function "' + property
          + '" is deprecated.' + "\n"
          + originInterface.deprecated[property + '_deprecation'] );

        this._original[property].apply(this, arguments);
      };
      }(prop));
    }
  }

  for(var prop in originInterface.extend) {

    if (typeof Interface[prop] === "function" &&
        typeof db[prop] === "function") {

      Interface[prop] = originInterface.extend[prop];
    }
    else if(typeof Interface[prop] === "function")
    {
      Interface[prop] = originInterface.extend[prop];
    }
  }

  return Interface;
};

exports.filterDown = function(completedMigrations, count) {
  return completedMigrations.slice(0, count);
};


exports.lpad = function(str, padChar, totalLength) {
  str = str.toString();
  var neededPadding = totalLength - str.length;
  for (var i = 0; i < neededPadding; i++) {
    str = padChar + str;
  }
  return str;
};

exports.shallowCopy = function(obj) {
  var newObj = {};
  for (var prop in obj) {
    newObj[prop] = obj[prop];
  }
  return newObj;
};

exports.toArray = function(obj) {
  var arr = [];
  for (var prop in obj) {
    arr[prop] = obj[prop];
  }
  return arr;
};

exports.isArray = function(obj) {
  return Object.prototype.toString.call(obj) == '[object Array]';
};

exports.isFunction = function(obj) {
  return typeof(obj) == 'function';
};

exports.isString = function(obj) {
  return typeof(obj) == 'string';
};

{'fraction_non_alphanumeric': 0.15378400215459198, 'fraction_numerical': 0.0018852679773767843, 'mean_word_length': 3.229498861047836, 'pattern_counts': {'":': 0, '<': 7, '<?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': '4385141', 'n_tokens_mistral': 2330, 'n_tokens_neox': 2243, 'n_words': 477}