lib/Lexerific.js
function Lexerific(config, _, FSM, Lexeme, StateGenerator, Token, TreeNode) {
  var _this = this;
  this._ = _;

  // Create a finite state machine for lexing
  this.fsm = new FSM({
    name: 'lexerific',
    debug: true,
    resetAtRoot: true // erase history for every root bound transition
  });

  this.fsm.on('return', function (data) {
    _this.push(data.toObject());
  });

  this.Lexeme = Lexeme;
  this.Token = Token;
  this.stateGenerator = new StateGenerator(this._, this.Token, TreeNode);

  /**
   * Either 'string' or 'token' to determine what type of input stream to expect
   */
  this._mode = config.mode;

  /**
   * In `string` mode, we need a list of regular expression patterns (as strings)
   * to differentiate between text that is important in our lexicon and text
   * that is not.
   */
  this._specialCharacters = config.specialCharacters;

  /**
   * Indicates whether the FSM has been initialized with all of the states
   */
  this._isReady = false;

  // We always read and write token objects
  TransformStream.call(this, {
    objectMode: true,
    readableObjectMode: true,
    writableObjectMode: true
  });
}
function Lexerific(config, _, FSM, Lexeme, StateGenerator, Token, TreeNode) {
  var _this = this;
  this._ = _;

  // Create a finite state machine for lexing
  this.fsm = new FSM({
    name: 'lexerific',
    debug: true,
    resetAtRoot: true // erase history for every root bound transition
  });

  this.fsm.on('return', function (data) {
    _this.push(data.toObject());
  });

  this.Lexeme = Lexeme;
  this.Token = Token;
  this.stateGenerator = new StateGenerator(this._, this.Token, TreeNode);

  /**
   * Either 'string' or 'token' to determine what type of input stream to expect
   */
  this._mode = config.mode;

  /**
   * In `string` mode, we need a list of regular expression patterns (as strings)
   * to differentiate between text that is important in our lexicon and text
   * that is not.
   */
  this._specialCharacters = config.specialCharacters;

  /**
   * Indicates whether the FSM has been initialized with all of the states
   */
  this._isReady = false;

  // We always read and write token objects
  TransformStream.call(this, {
    objectMode: true,
    readableObjectMode: true,
    writableObjectMode: true
  });
}
function Lexerific ( config , _ , FSM , Lexeme , StateGenerator , Token , TreeNode ) { var _this = this ; this . _ = _ ; // Create a finite state machine for lexing this . fsm = new FSM ( { name : 'lexerific' , debug : true , resetAtRoot : true // erase history for every root bound transition } ) ; this . fsm . on ( 'return' , function ( data ) { _this . push ( data . toObject ( ) ) ; } ) ; this . Lexeme = Lexeme ; this . Token = Token ; this . stateGenerator = new StateGenerator ( this . _ , this . Token , TreeNode ) ; /**
   * Either 'string' or 'token' to determine what type of input stream to expect
   */ this . _mode = config . mode ; /**
   * In `string` mode, we need a list of regular expression patterns (as strings)
   * to differentiate between text that is important in our lexicon and text
   * that is not.
   */ this . _specialCharacters = config . specialCharacters ; /**
   * Indicates whether the FSM has been initialized with all of the states
   */ this . _isReady = false ; // We always read and write token objects TransformStream . call ( this , { objectMode : true , readableObjectMode : true , writableObjectMode : true } ) ; }
The Lexerific library extends the Transform stream class.  Depending on the
mode it either takes in buffers as input or a stream of token objects.

Configuration options:
* `mode` - Either `string` or `token` depending on what type of input
should be consumed.  `token` mode is for secondary scanning passes

In `string` mode, there is an extra pre-processing step to divide the raw strings
into special characters and just plain text.
The Lexerific library extends the Transform stream class . Depending on the mode it either takes in buffers as input or a stream of token objects .