index.js
function Converter() {

  // Validate arguments
  if (arguments.length === 1) {

    this._bl = 2;

    if (typeof arguments[0] !== "function")
      throw new TypeError("Converter requires at least a callback function");
    else
      this._fx = arguments[0];

  } else if (arguments.length >= 2) {

    this._bl = arguments[0];
    if (this._bl !== 1 && this._bl !== 2 && this._bl !== 4)
      throw new TypeError("Prefix length must be 1, 2 or 4");

    if (typeof arguments[1] !== "function")
      throw new TypeError("Converter requires a callback function");
    else
      this._fx = arguments[1];

  } else {
    throw new Error("cannot construct a converter without a callback");
  }

  this.flush();
}
function Converter() {

  // Validate arguments
  if (arguments.length === 1) {

    this._bl = 2;

    if (typeof arguments[0] !== "function")
      throw new TypeError("Converter requires at least a callback function");
    else
      this._fx = arguments[0];

  } else if (arguments.length >= 2) {

    this._bl = arguments[0];
    if (this._bl !== 1 && this._bl !== 2 && this._bl !== 4)
      throw new TypeError("Prefix length must be 1, 2 or 4");

    if (typeof arguments[1] !== "function")
      throw new TypeError("Converter requires a callback function");
    else
      this._fx = arguments[1];

  } else {
    throw new Error("cannot construct a converter without a callback");
  }

  this.flush();
}
function Converter ( ) { // Validate arguments if ( arguments . length === 1 ) { this . _bl = 2 ; if ( typeof arguments [ 0 ] !== "function" ) throw new TypeError ( "Converter requires at least a callback function" ) ; else this . _fx = arguments [ 0 ] ; } else if ( arguments . length >= 2 ) { this . _bl = arguments [ 0 ] ; if ( this . _bl !== 1 && this . _bl !== 2 && this . _bl !== 4 ) throw new TypeError ( "Prefix length must be 1, 2 or 4" ) ; if ( typeof arguments [ 1 ] !== "function" ) throw new TypeError ( "Converter requires a callback function" ) ; else this . _fx = arguments [ 1 ] ; } else { throw new Error ( "cannot construct a converter without a callback" ) ; } this . flush ( ) ; }
Takes in a series of Buffers and calls back whenever a fixed-length
message has been completely processed.

@param {Integer} [prefixLength] - The length in bytes of the size prefix.
This argument is optional. The default length is 2 bytes, but can also be 1
or 4 bytes.

@param {Function} callback - This will be called every time a new message has
been completely processed.
Takes in a series of Buffers and calls back whenever a fixed - length message has been completely processed .