constructor(buffer: Buffer) {
    this._buffer = buffer;

    if (this._readPosition(0) !== MAGIC_NUMBER) {
      throw new Error('File is not a RAM bundle file');
    }

    this._numModules = this._readPosition(1);
    this._startupCodeLength = this._readPosition(2);

    // The startup code begins after the table of contents, which contains the
    // 3 fields on the header plus 2 entries per module.
    this._startOffset = (HEADER_SIZE + this._numModules * 2) * SIZEOF_UINT32;
  }
Implementation of a RAM bundle parser in JS.

It receives a Buffer as an input and implements two main methods, which are
able to run in constant time no matter the size of the bundle:

getStartupCode(): returns the runtime and the startup code of the bundle.
getModule(): returns the code for the specified module.