<commit_before>var EOL = require('os').EOL
  , fs = require('fs')
  , assert = require('assert')
  , path = require('path')
  , touch = require('touch')
  , util = require('util')
  , events = require('events')
  , utils = require('cli-util')
  , uniq = utils.uniq
  , merge = utils.merge;

var stores = {};

function noop(){};

var HistoryStore = function(parent, options, lines) {
  var scope = this;

  options = options || {};
  lines = this.readLines(lines);
  options.flush = options.flush !== undefined ? options.flush : true;
  options.duplicates = options.duplicates !== undefined
    ? options.duplicates : false;
  options.limit = options.limit === 'number' ? options.limit : 2048;

  // flush on process close
  if(options.close) {
    // don't flush on modification
    options.flush = false;
    process.on('exit', function() {
      console.log('flush on exit');
      fs.writeFileSync(scope.file, scope.getLines());
    })
  }

  this.file = options.file;
  this.options = options;
  this._parent = parent;
  this._history = lines;
  this._stream = fs.createWriteStream(this.file, {flags: 'a+'});
  this._stats = null;
  this._position = 0;
  this._success();
}

HistoryStore.prototype.position = function(index) {
  return this._position;
}

HistoryStore.prototype.go = function(index) {
  if(index > -1 && index < this._history.length) {
    this._position = index;
    return this._history[index];
  }
  return false;
}

HistoryStore.prototype.next = function() {
  var pos = this._position + 1;
  if(pos < this._history.length) {
    this._position = pos;
    return this._history[pos];
  }
  return false;
}

HistoryStore.prototype.previous = function() {
  var pos = this._position - 1;
  if(pos > -1 && this._history.length) {
    this._position = pos;
    return this._history[pos];
  }
  return false;
}

/**
 *  Get the underlying history array.
 */
HistoryStore.prototype.history = function() {
  return this._history;
}

/**
 *  Get the underlying file stats.
 */
HistoryStore.prototype.stats = function(cb) {
  var scope = this;
  if(typeof cb === 'function') {<commit_msg>Add positional reset() method.<commit_after>var EOL = require('os').EOL
  , fs = require('fs')
  , assert = require('assert')
  , path = require('path')
  , touch = require('touch')
  , util = require('util')
  , events = require('events')
  , utils = require('cli-util')
  , uniq = utils.uniq
  , merge = utils.merge;

var stores = {};

function noop(){};

var HistoryStore = function(parent, options, lines) {
  var scope = this;

  options = options || {};
  lines = this.readLines(lines);
  options.flush = options.flush !== undefined ? options.flush : true;
  options.duplicates = options.duplicates !== undefined
    ? options.duplicates : false;
  options.limit = options.limit === 'number' ? options.limit : 2048;

  // flush on process close
  if(options.close) {
    // don't flush on modification
    options.flush = false;
    process.on('exit', function() {
      console.log('flush on exit');
      fs.writeFileSync(scope.file, scope.getLines());
    })
  }

  this.file = options.file;
  this.options = options;
  this._parent = parent;
  this._history = lines;
  this._stream = fs.createWriteStream(this.file, {flags: 'a+'});
  this._stats = null;
  this.reset();
  this._success();
}

HistoryStore.prototype.position = function(index) {
  return this._position;
}

HistoryStore.prototype.go = function(index) {
  if(index > -1 && index < this._history.length) {
    this._position = index;
    return this._history[index];
  }
  return false;
}

HistoryStore.prototype.next = function() {
  var pos = this._position + 1;
  if(pos < this._history.length) {
    this._position = pos;
    return this._history[pos];
  }
  return false;
}

HistoryStore.prototype.previous = function() {
  var pos = this._position - 1;
  if(pos > -1 && this._history.length) {
    this._position = pos;
    return this._history[pos];
  }
  return false;
}

HistoryStore.prototype.reset = function() {
  if(!this._history.length) {
    this._position = 0;
  }else{
    this._position = this._history.length - 1;
  }
}

/**
 *  Get the underlying history array.
 */
HistoryStore.prototype.history = function() {
  return this._history;
}

/**
 *  Get the underlying file stats.
 */
HistoryStore.prototype.stats = function(cb) {
  var scope = this;
  if(typeof cb === 'function') {
{'fraction_non_alphanumeric': 0.1547074954296161, 'fraction_numerical': 0.004341864716636197, 'mean_word_length': 3.3422619047619047, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '41095', 'n_tokens_mistral': 1414, 'n_tokens_neox': 1399, 'n_words': 319}