src/RollingHash/rollingHash.js
function(base){
  if(typeof base === 'undefined'){
    throw new Error("Too few arguments in RollingHash constructor");
  }else if(typeof base !== 'number'){
    throw new TypeError("Invalid argument; expected a number in RollingHash constructor");
  }
  
  // The base of the number system
  this.BASE = base;

  // The internal hash value of the window
  this.state = 0;

  // A block of expensive code we will cache in order to optimize runtime
  this.CACHE = 1;

  // The amount of digits a number can hold given the base
  // TODO: unused.. figure out why I thought I needed this
  this.BUFFER_SIZE = Math.log(base) * Math.LOG10E + 1 | 0;

  // The modular inverse of the base
  this.INVERSE_BASE = modInverse(this.BASE, PRIME_BASE) % PRIME_BASE;

  // An offset to add when calculating a modular product, to make sure it can not go negative
  this.OFFSET_IF_NEGATIVE = PRIME_BASE * this.BASE;
}
function(base){
  if(typeof base === 'undefined'){
    throw new Error("Too few arguments in RollingHash constructor");
  }else if(typeof base !== 'number'){
    throw new TypeError("Invalid argument; expected a number in RollingHash constructor");
  }
  
  // The base of the number system
  this.BASE = base;

  // The internal hash value of the window
  this.state = 0;

  // A block of expensive code we will cache in order to optimize runtime
  this.CACHE = 1;

  // The amount of digits a number can hold given the base
  // TODO: unused.. figure out why I thought I needed this
  this.BUFFER_SIZE = Math.log(base) * Math.LOG10E + 1 | 0;

  // The modular inverse of the base
  this.INVERSE_BASE = modInverse(this.BASE, PRIME_BASE) % PRIME_BASE;

  // An offset to add when calculating a modular product, to make sure it can not go negative
  this.OFFSET_IF_NEGATIVE = PRIME_BASE * this.BASE;
}
function ( base ) { if ( typeof base === 'undefined' ) { throw new Error ( "Too few arguments in RollingHash constructor" ) ; } else if ( typeof base !== 'number' ) { throw new TypeError ( "Invalid argument; expected a number in RollingHash constructor" ) ; } // The base of the number system this . BASE = base ; // The internal hash value of the window this . state = 0 ; // A block of expensive code we will cache in order to optimize runtime this . CACHE = 1 ; // The amount of digits a number can hold given the base // TODO: unused.. figure out why I thought I needed this this . BUFFER_SIZE = Math . log ( base ) * Math . LOG10E + 1 | 0 ; // The modular inverse of the base this . INVERSE_BASE = modInverse ( this . BASE , PRIME_BASE ) % PRIME_BASE ; // An offset to add when calculating a modular product, to make sure it can not go negative this . OFFSET_IF_NEGATIVE = PRIME_BASE * this . BASE ; }
Single argument constructor which defines the base of the working
@param {number} the base value of the rolling hash to compute its operations
@return {void}
Single argument constructor which defines the base of the working