lib/parser.js
function parseInt (buffer, size) {
  switch (size) {
    case 1:
      return buffer[buffer.read++];

    case 2:
      return (buffer[buffer.read++] << 8) + buffer[buffer.read++];

    case 4:
      return (buffer[buffer.read++] << 24) + (buffer[buffer.read++] << 16) +
             (buffer[buffer.read++] << 8)  + buffer[buffer.read++];

    case 8:
      return (buffer[buffer.read++] << 56) + (buffer[buffer.read++] << 48) +
             (buffer[buffer.read++] << 40) + (buffer[buffer.read++] << 32) +
             (buffer[buffer.read++] << 24) + (buffer[buffer.read++] << 16) +
             (buffer[buffer.read++] << 8)  + buffer[buffer.read++];

    default:
      throw new Error("cannot parse ints of that size");
  }
}
function parseInt (buffer, size) {
  switch (size) {
    case 1:
      return buffer[buffer.read++];

    case 2:
      return (buffer[buffer.read++] << 8) + buffer[buffer.read++];

    case 4:
      return (buffer[buffer.read++] << 24) + (buffer[buffer.read++] << 16) +
             (buffer[buffer.read++] << 8)  + buffer[buffer.read++];

    case 8:
      return (buffer[buffer.read++] << 56) + (buffer[buffer.read++] << 48) +
             (buffer[buffer.read++] << 40) + (buffer[buffer.read++] << 32) +
             (buffer[buffer.read++] << 24) + (buffer[buffer.read++] << 16) +
             (buffer[buffer.read++] << 8)  + buffer[buffer.read++];

    default:
      throw new Error("cannot parse ints of that size");
  }
}
function parseInt ( buffer , size ) { switch ( size ) { case 1 : return buffer [ buffer . read ++ ] ; case 2 : return ( buffer [ buffer . read ++ ] << 8 ) + buffer [ buffer . read ++ ] ; case 4 : return ( buffer [ buffer . read ++ ] << 24 ) + ( buffer [ buffer . read ++ ] << 16 ) + ( buffer [ buffer . read ++ ] << 8 ) + buffer [ buffer . read ++ ] ; case 8 : return ( buffer [ buffer . read ++ ] << 56 ) + ( buffer [ buffer . read ++ ] << 48 ) + ( buffer [ buffer . read ++ ] << 40 ) + ( buffer [ buffer . read ++ ] << 32 ) + ( buffer [ buffer . read ++ ] << 24 ) + ( buffer [ buffer . read ++ ] << 16 ) + ( buffer [ buffer . read ++ ] << 8 ) + buffer [ buffer . read ++ ] ; default : throw new Error ( "cannot parse ints of that size" ) ; } }
parse Network Byte Order integers. size can be 1,2,4,8
parse Network Byte Order integers . size can be 1 2 4 8