{
  "version": 3,
  "sources": ["../../bytebuffer/index.ts", "../utils.ts", "../zlib/index.ts", "../index.ts"],
  "sourcesContent": ["/*\n Copyright 2013-2014 Daniel Wirtz <dcode@dcode.io>\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n */\n\n/**\n * @license bytebuffer.js (c) 2015 Daniel Wirtz <dcode@dcode.io>\n * Backing buffer: ArrayBuffer, Accessor: DataView\n * Released under the Apache License, Version 2.0\n * see: https://github.com/dcodeIO/bytebuffer.js for details\n * @module @xmcl/bytebuffer\n */\n\nexport class ByteBuffer {\n  /**\n   * ByteBuffer version.\n   * @type {string}\n   * @const\n   * @expose\n   */\n  static VERSION = '0.0.1'\n\n  /**\n   * Little endian constant that can be used instead of its boolean value. Evaluates to `true`.\n   * @type {boolean}\n   * @const\n   * @expose\n   */\n  static LITTLE_ENDIAN = true\n\n  /**\n   * Big endian constant that can be used instead of its boolean value. Evaluates to `false`.\n   * @type {boolean}\n   * @const\n   * @expose\n   */\n  static BIG_ENDIAN = false\n\n  /**\n   * Default initial capacity of `16`.\n   * @type {number}\n   * @expose\n   */\n  static DEFAULT_CAPACITY = 16\n\n  /**\n   * Default endianess of `false` for big endian.\n   * @type {boolean}\n   * @expose\n   */\n  static DEFAULT_ENDIAN: boolean = ByteBuffer.BIG_ENDIAN\n\n  /**\n   * Default no assertions flag of `false`.\n   * @type {boolean}\n   * @expose\n   */\n  static DEFAULT_NOASSERT = false\n  /**\n   * Backing ArrayBuffer.\n   * @type {!ArrayBuffer}\n   * @expose\n   */\n  buffer: ArrayBuffer\n  /**\n   * DataView utilized to manipulate the backing buffer. Becomes `null` if the backing buffer has a capacity of `0`.\n   * @type {?DataView}\n   * @expose\n   */\n  view: DataView\n  /**\n   * Absolute read/write offset.\n   * @type {number}\n   * @expose\n   * @see ByteBuffer#flip\n   * @see ByteBuffer#clear\n   */\n  offset: number\n  /**\n   * Marked offset.\n   * @type {number}\n   * @expose\n   * @see ByteBuffer#mark\n   * @see ByteBuffer#reset\n   */\n  markedOffset: number\n  /**\n   * Absolute limit of the contained data. Set to the backing buffer's capacity upon allocation.\n   * @type {number}\n   * @expose\n   * @see ByteBuffer#flip\n   * @see ByteBuffer#clear\n   */\n  limit: number\n  /**\n   * Whether to use little endian byte order, defaults to `false` for big endian.\n   * @type {boolean}\n   * @expose\n   */\n  littleEndian: boolean\n  /**\n   * Whether to skip assertions of offsets and values, defaults to `false`.\n   * @type {boolean}\n   * @expose\n   */\n  noAssert: boolean\n  /**\n   * Constructs a new ByteBuffer.\n   * @class The swiss army knife for binary data in JavaScript.\n   * @exports ByteBuffer\n   * @constructor\n   * @param {number=} capacity Initial capacity. Defaults to {@link ByteBuffer.DEFAULT_CAPACITY}.\n   * @param {boolean=} littleEndian Whether to use little or big endian byte order. Defaults to\n   *  {@link ByteBuffer.DEFAULT_ENDIAN}.\n   * @param {boolean=} noAssert Whether to skip assertions of offsets and values. Defaults to\n   *  {@link ByteBuffer.DEFAULT_NOASSERT}.\n   * @expose\n   */\n  constructor(capacity?: number, littleEndian?: boolean, noAssert?: boolean) {\n    if (typeof capacity === 'undefined') {\n      capacity = ByteBuffer.DEFAULT_CAPACITY\n    }\n    if (typeof littleEndian === 'undefined') {\n      littleEndian = ByteBuffer.DEFAULT_ENDIAN\n    }\n    if (typeof noAssert === 'undefined') {\n      noAssert = ByteBuffer.DEFAULT_NOASSERT\n    }\n    if (!noAssert) {\n      capacity = capacity | 0\n      if (capacity < 0) {\n        throw RangeError('Illegal capacity')\n      }\n      littleEndian = !!littleEndian\n      noAssert = !!noAssert\n    }\n\n    this.buffer = capacity === 0 ? EMPTY_BUFFER : new ArrayBuffer(capacity)\n    this.view = capacity === 0 ? new DataView(EMPTY_BUFFER) : new DataView(this.buffer)\n    this.offset = 0\n    this.markedOffset = -1\n    this.limit = capacity\n    this.littleEndian = littleEndian\n    this.noAssert = noAssert\n  }\n\n  /**\n   * Gets the accessor type.\n   * @returns {Function} `Buffer` under node.js, `Uint8Array` respectively `DataView` in the browser (classes)\n   * @expose\n   */\n  static accessor = function () {\n    return DataView\n  }\n\n  /**\n   * Allocates a new ByteBuffer backed by a buffer of the specified capacity.\n   * @param {number=} capacity Initial capacity. Defaults to {@link ByteBuffer.DEFAULT_CAPACITY}.\n   * @param {boolean=} littleEndian Whether to use little or big endian byte order. Defaults to\n   *  {@link ByteBuffer.DEFAULT_ENDIAN}.\n   * @param {boolean=} noAssert Whether to skip assertions of offsets and values. Defaults to\n   *  {@link ByteBuffer.DEFAULT_NOASSERT}.\n   * @returns {!ByteBuffer}\n   * @expose\n   */\n  static allocate = function (\n    capacity?: number,\n    littleEndian?: boolean,\n    noAssert?: boolean,\n  ): ByteBuffer {\n    return new ByteBuffer(capacity, littleEndian, noAssert)\n  }\n\n  /**\n   * Concatenates multiple ByteBuffers into one.\n   * @param {!Array.<!ByteBuffer|!ArrayBuffer|!Uint8Array>} buffers Buffers to concatenate\n   * @param {(string|boolean)=} encoding String encoding if `buffers` contains a string (\"base64\", \"hex\", \"binary\",\n   *  defaults to \"utf8\")\n   * @param {boolean=} littleEndian Whether to use little or big endian byte order for the resulting ByteBuffer. Defaults\n   *  to {@link ByteBuffer.DEFAULT_ENDIAN}.\n   * @param {boolean=} noAssert Whether to skip assertions of offsets and values for the resulting ByteBuffer. Defaults to\n   *  {@link ByteBuffer.DEFAULT_NOASSERT}.\n   * @returns {!ByteBuffer} Concatenated ByteBuffer\n   * @expose\n   */\n  static concat = function (\n    buffers: Array<ByteBuffer | ArrayBuffer | Uint8Array>,\n    littleEndian?: boolean,\n    noAssert?: boolean,\n  ): ByteBuffer {\n    let capacity = 0\n    const k = buffers.length\n    let length\n    for (let i = 0, length; i < k; ++i) {\n      const buf = buffers[i]\n      if (!(buf instanceof ByteBuffer)) {\n        buffers[i] = ByteBuffer.wrap(buf)\n      }\n      // @ts-ignore\n      length = buffers[i].limit - buffers[i].offset\n      if (length > 0) {\n        capacity += length\n      }\n    }\n    if (capacity === 0) {\n      return new ByteBuffer(0, littleEndian, noAssert)\n    }\n    const bb = new ByteBuffer(capacity, littleEndian, noAssert)\n    let bi\n    const view = new Uint8Array(bb.buffer)\n    let i = 0\n    while (i < k) {\n      bi = buffers[i++]\n      // @ts-ignore\n      length = bi.limit - bi.offset\n      if (length <= 0) {\n        continue\n      }\n      // @ts-ignore\n      view.set(new Uint8Array(bi.buffer).subarray(bi.offset, bi.limit), bb.offset)\n      bb.offset += length\n    }\n    bb.limit = bb.offset\n    bb.offset = 0\n    return bb\n  }\n\n  /**\n   * Gets the backing buffer type.\n   * @returns {Function} `Buffer` under node.js, `ArrayBuffer` in the browser (classes)\n   * @expose\n   */\n  static type = function () {\n    return ArrayBuffer\n  }\n\n  /**\n   * Wraps a buffer or a string. Sets the allocated ByteBuffer's {@link ByteBuffer#offset} to `0` and its\n   *  {@link ByteBuffer#limit} to the length of the wrapped data.\n   * @param {!ByteBuffer|!ArrayBuffer|!Uint8Array|string|!Array.<number>} buffer Anything that can be wrapped\n   * @param {boolean=} littleEndian Whether to use little or big endian byte order. Defaults to\n   *  {@link ByteBuffer.DEFAULT_ENDIAN}.\n   * @param {boolean=} noAssert Whether to skip assertions of offsets and values. Defaults to\n   *  {@link ByteBuffer.DEFAULT_NOASSERT}.\n   * @returns {!ByteBuffer} A ByteBuffer wrapping `buffer`\n   * @expose\n   */\n  static wrap = function (\n    buffer: ArrayBuffer | number[] | Uint8Array,\n    littleEndian?: boolean,\n    noAssert?: boolean,\n  ): ByteBuffer {\n    if (buffer === null || typeof buffer !== 'object') {\n      throw TypeError('Illegal buffer')\n    }\n    let bb\n    if (buffer instanceof ByteBuffer) {\n      bb = buffer.clone()\n      bb.markedOffset = -1\n      return bb\n    }\n    if (buffer instanceof Uint8Array) {\n      // Extract ArrayBuffer from Uint8Array\n      bb = new ByteBuffer(0, littleEndian, noAssert)\n      if (buffer.length > 0) {\n        // Avoid references to more than one EMPTY_BUFFER\n        bb.buffer = buffer.buffer as ArrayBuffer\n        bb.offset = buffer.byteOffset\n        bb.limit = buffer.byteOffset + buffer.byteLength\n        bb.view = new DataView(buffer.buffer)\n      }\n    } else if (buffer instanceof ArrayBuffer) {\n      // Reuse ArrayBuffer\n      bb = new ByteBuffer(0, littleEndian, noAssert)\n      if (buffer.byteLength > 0) {\n        bb.buffer = buffer\n        bb.offset = 0\n        bb.limit = buffer.byteLength\n        bb.view = buffer.byteLength > 0 ? new DataView(buffer) : new DataView(EMPTY_BUFFER)\n      }\n    } else if (Object.prototype.toString.call(buffer) === '[object Array]') {\n      // Create from octets\n      bb = new ByteBuffer(buffer.length, littleEndian, noAssert)\n      bb.limit = buffer.length\n      for (let i = 0; i < buffer.length; ++i) {\n        bb.view.setUint8(i, buffer[i])\n      }\n    } else {\n      throw TypeError('Illegal buffer')\n    } // Otherwise fail\n    return bb\n  }\n\n  /**\n   * Reads the specified number of bytes.\n   * @param {number} length Number of bytes to read\n   * @param {number=} offset Offset to read from. Will use and increase {@link ByteBuffer#offset} by `length` if omitted.\n   * @returns {!ByteBuffer}\n   * @expose\n   */\n  readBytes(length: number, offset?: number): ByteBuffer {\n    const relative = typeof offset === 'undefined'\n    if (relative) {\n      offset = this.offset\n    }\n    if (!this.noAssert) {\n      if (typeof offset !== 'number' || offset % 1 !== 0) {\n        throw TypeError('Illegal offset: ' + offset + ' (not an integer)')\n      }\n      offset >>>= 0\n      if (offset < 0 || offset + length > this.buffer.byteLength) {\n        throw RangeError(\n          'Illegal offset: 0 <= ' + offset + ' (+' + length + ') <= ' + this.buffer.byteLength,\n        )\n      }\n    }\n    const slice = this.slice(offset, offset! + length)\n    if (relative) {\n      this.offset += length\n    }\n    return slice\n  }\n\n  /**\n   * Writes a payload of bytes. This is an alias of {@link ByteBuffer#append}.\n   * @function\n   * @param {!ByteBuffer|!ArrayBuffer|!Uint8Array|string} source Data to write. If `source` is a ByteBuffer, its offsets\n   *  will be modified according to the performed read operation.\n   * @param {(string|number)=} encoding Encoding if `data` is a string (\"base64\", \"hex\", \"binary\", defaults to \"utf8\")\n   * @param {number=} offset Offset to write to. Will use and increase {@link ByteBuffer#offset} by the number of bytes\n   *  written if omitted.\n   * @returns {!ByteBuffer} this\n   * @expose\n   */\n  writeBytes = this.append\n\n  // types/ints/int8\n\n  /**\n   * Writes an 8bit signed integer.\n   * @param {number} value Value to write\n   * @param {number=} offset Offset to write to. Will use and advance {@link ByteBuffer#offset} by `1` if omitted.\n   * @returns {!ByteBuffer} this\n   * @expose\n   */\n  writeInt8(value: number, offset?: number): ByteBuffer {\n    const relative = typeof offset === 'undefined'\n    if (relative) {\n      offset = this.offset\n    }\n    if (!this.noAssert) {\n      if (typeof value !== 'number' || value % 1 !== 0) {\n        throw TypeError('Illegal value: ' + value + ' (not an integer)')\n      }\n      value |= 0\n      if (typeof offset !== 'number' || offset % 1 !== 0) {\n        throw TypeError('Illegal offset: ' + offset + ' (not an integer)')\n      }\n      offset >>>= 0\n      if (offset < 0 || offset + 0 > this.buffer.byteLength) {\n        throw RangeError(\n          'Illegal offset: 0 <= ' + offset + ' (+' + 0 + ') <= ' + this.buffer.byteLength,\n        )\n      }\n    }\n    offset! += 1\n    let capacity0 = this.buffer.byteLength\n    if (offset! > capacity0) {\n      this.resize((capacity0 *= 2) > offset! ? capacity0 : offset!)\n    }\n    offset! -= 1\n    this.view.setInt8(offset!, value)\n    if (relative) {\n      this.offset += 1\n    }\n    return this\n  }\n\n  /**\n   * Writes an 8bit signed integer. This is an alias of {@link ByteBuffer#writeInt8}.\n   * @function\n   * @param {number} value Value to write\n   * @param {number=} offset Offset to write to. Will use and advance {@link ByteBuffer#offset} by `1` if omitted.\n   * @returns {!ByteBuffer} this\n   * @expose\n   */\n  writeByte = this.writeInt8\n\n  /**\n   * Reads an 8bit signed integer.\n   * @param {number=} offset Offset to read from. Will use and advance {@link ByteBuffer#offset} by `1` if omitted.\n   * @returns {number} Value read\n   * @expose\n   */\n  readInt8(offset?: number): number {\n    const relative = typeof offset === 'undefined'\n    if (relative) {\n      offset = this.offset\n    }\n    if (!this.noAssert) {\n      if (typeof offset !== 'number' || offset % 1 !== 0) {\n        throw TypeError('Illegal offset: ' + offset + ' (not an integer)')\n      }\n      offset >>>= 0\n      if (offset < 0 || offset + 1 > this.buffer.byteLength) {\n        throw RangeError(\n          'Illegal offset: 0 <= ' + offset + ' (+' + 1 + ') <= ' + this.buffer.byteLength,\n        )\n      }\n    }\n    const value = this.view.getInt8(offset!)\n    if (relative) {\n      this.offset += 1\n    }\n    return value\n  }\n\n  /**\n   * Reads an 8bit signed integer. This is an alias of {@link ByteBuffer#readInt8}.\n   * @function\n   * @param {number=} offset Offset to read from. Will use and advance {@link ByteBuffer#offset} by `1` if omitted.\n   * @returns {number} Value read\n   * @expose\n   */\n  readByte = this.readInt8\n\n  /**\n   * Writes an 8bit unsigned integer.\n   * @param {number} value Value to write\n   * @param {number=} offset Offset to write to. Will use and advance {@link ByteBuffer#offset} by `1` if omitted.\n   * @returns {!ByteBuffer} this\n   * @expose\n   */\n  writeUint8(value: number, offset?: number): ByteBuffer {\n    const relative = typeof offset === 'undefined'\n    if (relative) {\n      offset = this.offset\n    }\n    if (!this.noAssert) {\n      if (typeof value !== 'number' || value % 1 !== 0) {\n        throw TypeError('Illegal value: ' + value + ' (not an integer)')\n      }\n      value >>>= 0\n      if (typeof offset !== 'number' || offset % 1 !== 0) {\n        throw TypeError('Illegal offset: ' + offset + ' (not an integer)')\n      }\n      offset >>>= 0\n      if (offset < 0 || offset + 0 > this.buffer.byteLength) {\n        throw RangeError(\n          'Illegal offset: 0 <= ' + offset + ' (+' + 0 + ') <= ' + this.buffer.byteLength,\n        )\n      }\n    }\n    offset! += 1\n    let capacity1 = this.buffer.byteLength\n    if (offset! > capacity1) {\n      this.resize((capacity1 *= 2) > offset! ? capacity1 : offset!)\n    }\n    offset! -= 1\n    this.view.setUint8(offset!, value)\n    if (relative) {\n      this.offset += 1\n    }\n    return this\n  }\n\n  /**\n   * Writes an 8bit unsigned integer. This is an alias of {@link ByteBuffer#writeUint8}.\n   * @function\n   * @param {number} value Value to write\n   * @param {number=} offset Offset to write to. Will use and advance {@link ByteBuffer#offset} by `1` if omitted.\n   * @returns {!ByteBuffer} this\n   * @expose\n   */\n  writeUInt8 = this.writeUint8\n\n  /**\n   * Reads an 8bit unsigned integer.\n   * @param {number=} offset Offset to read from. Will use and advance {@link ByteBuffer#offset} by `1` if omitted.\n   * @returns {number} Value read\n   * @expose\n   */\n  readUint8(offset?: number): number {\n    const relative = typeof offset === 'undefined'\n    if (relative) {\n      offset = this.offset\n    }\n    if (!this.noAssert) {\n      if (typeof offset !== 'number' || offset % 1 !== 0) {\n        throw TypeError('Illegal offset: ' + offset + ' (not an integer)')\n      }\n      offset >>>= 0\n      if (offset < 0 || offset + 1 > this.buffer.byteLength) {\n        throw RangeError(\n          'Illegal offset: 0 <= ' + offset + ' (+' + 1 + ') <= ' + this.buffer.byteLength,\n        )\n      }\n    }\n    const value = this.view.getUint8(offset!)\n    if (relative) {\n      this.offset += 1\n    }\n    return value\n  }\n\n  /**\n   * Reads an 8bit unsigned integer. This is an alias of {@link ByteBuffer#readUint8}.\n   * @function\n   * @param {number=} offset Offset to read from. Will use and advance {@link ByteBuffer#offset} by `1` if omitted.\n   * @returns {number} Value read\n   * @expose\n   */\n  readUInt8 = this.readUint8\n\n  // types/ints/int16\n\n  /**\n   * Writes a 16bit signed integer.\n   * @param {number} value Value to write\n   * @param {number=} offset Offset to write to. Will use and advance {@link ByteBuffer#offset} by `2` if omitted.\n   * @throws {TypeError} If `offset` or `value` is not a valid number\n   * @throws {RangeError} If `offset` is out of bounds\n   * @expose\n   */\n  writeInt16(value: number, offset?: number) {\n    const relative = typeof offset === 'undefined'\n    if (relative) {\n      offset = this.offset\n    }\n    if (!this.noAssert) {\n      if (typeof value !== 'number' || value % 1 !== 0) {\n        throw TypeError('Illegal value: ' + value + ' (not an integer)')\n      }\n      value |= 0\n      if (typeof offset !== 'number' || offset % 1 !== 0) {\n        throw TypeError('Illegal offset: ' + offset + ' (not an integer)')\n      }\n      offset >>>= 0\n      if (offset < 0 || offset + 0 > this.buffer.byteLength) {\n        throw RangeError(\n          'Illegal offset: 0 <= ' + offset + ' (+' + 0 + ') <= ' + this.buffer.byteLength,\n        )\n      }\n    }\n    offset! += 2\n    let capacity2 = this.buffer.byteLength\n    if (offset! > capacity2) {\n      this.resize((capacity2 *= 2) > offset! ? capacity2 : offset!)\n    }\n    offset! -= 2\n    this.view.setInt16(offset!, value, this.littleEndian)\n    if (relative) {\n      this.offset += 2\n    }\n    return this\n  }\n\n  /**\n   * Writes a 16bit signed integer. This is an alias of {@link ByteBuffer#writeInt16}.\n   * @function\n   * @param {number} value Value to write\n   * @param {number=} offset Offset to write to. Will use and advance {@link ByteBuffer#offset} by `2` if omitted.\n   * @throws {TypeError} If `offset` or `value` is not a valid number\n   * @throws {RangeError} If `offset` is out of bounds\n   * @expose\n   */\n  writeShort = this.writeInt16\n\n  /**\n   * Reads a 16bit signed integer.\n   * @param {number=} offset Offset to read from. Will use and advance {@link ByteBuffer#offset} by `2` if omitted.\n   * @returns {number} Value read\n   * @throws {TypeError} If `offset` is not a valid number\n   * @throws {RangeError} If `offset` is out of bounds\n   * @expose\n   */\n  readInt16(offset?: number): number {\n    const relative = typeof offset === 'undefined'\n    if (typeof offset === 'undefined') {\n      offset = this.offset\n    }\n    if (!this.noAssert) {\n      if (typeof offset !== 'number' || offset % 1 !== 0) {\n        throw TypeError('Illegal offset: ' + offset + ' (not an integer)')\n      }\n      offset >>>= 0\n      if (offset < 0 || offset + 2 > this.buffer.byteLength) {\n        throw RangeError(\n          'Illegal offset: 0 <= ' + offset + ' (+' + 2 + ') <= ' + this.buffer.byteLength,\n        )\n      }\n    }\n    const value = this.view.getInt16(offset, this.littleEndian)\n    if (relative) {\n      this.offset += 2\n    }\n    return value\n  }\n\n  /**\n   * Reads a 16bit signed integer. This is an alias of {@link ByteBuffer#readInt16}.\n   * @function\n   * @param {number=} offset Offset to read from. Will use and advance {@link ByteBuffer#offset} by `2` if omitted.\n   * @returns {number} Value read\n   * @throws {TypeError} If `offset` is not a valid number\n   * @throws {RangeError} If `offset` is out of bounds\n   * @expose\n   */\n  readShort = this.readInt16\n\n  /**\n   * Writes a 16bit unsigned integer.\n   * @param {number} value Value to write\n   * @param {number=} offset Offset to write to. Will use and advance {@link ByteBuffer#offset} by `2` if omitted.\n   * @throws {TypeError} If `offset` or `value` is not a valid number\n   * @throws {RangeError} If `offset` is out of bounds\n   * @expose\n   */\n  writeUint16(value: number, offset?: number) {\n    const relative = typeof offset === 'undefined'\n    if (relative) {\n      offset = this.offset\n    }\n    if (!this.noAssert) {\n      if (typeof value !== 'number' || value % 1 !== 0) {\n        throw TypeError('Illegal value: ' + value + ' (not an integer)')\n      }\n      value >>>= 0\n      if (typeof offset !== 'number' || offset % 1 !== 0) {\n        throw TypeError('Illegal offset: ' + offset + ' (not an integer)')\n      }\n      offset >>>= 0\n      if (offset < 0 || offset + 0 > this.buffer.byteLength) {\n        throw RangeError(\n          'Illegal offset: 0 <= ' + offset + ' (+' + 0 + ') <= ' + this.buffer.byteLength,\n        )\n      }\n    }\n    offset! += 2\n    let capacity3 = this.buffer.byteLength\n    if (offset! > capacity3) {\n      this.resize((capacity3 *= 2) > offset! ? capacity3 : offset!)\n    }\n    offset! -= 2\n    this.view.setUint16(offset!, value, this.littleEndian)\n    if (relative) {\n      this.offset += 2\n    }\n    return this\n  }\n\n  /**\n   * Writes a 16bit unsigned integer. This is an alias of {@link ByteBuffer#writeUint16}.\n   * @function\n   * @param {number} value Value to write\n   * @param {number=} offset Offset to write to. Will use and advance {@link ByteBuffer#offset} by `2` if omitted.\n   * @throws {TypeError} If `offset` or `value` is not a valid number\n   * @throws {RangeError} If `offset` is out of bounds\n   * @expose\n   */\n  writeUInt16 = this.writeUint16\n\n  /**\n   * Reads a 16bit unsigned integer.\n   * @param {number=} offset Offset to read from. Will use and advance {@link ByteBuffer#offset} by `2` if omitted.\n   * @returns {number} Value read\n   * @throws {TypeError} If `offset` is not a valid number\n   * @throws {RangeError} If `offset` is out of bounds\n   * @expose\n   */\n  readUint16(offset?: number): number {\n    const relative = typeof offset === 'undefined'\n    if (relative) {\n      offset = this.offset\n    }\n    if (!this.noAssert) {\n      if (typeof offset !== 'number' || offset % 1 !== 0) {\n        throw TypeError('Illegal offset: ' + offset + ' (not an integer)')\n      }\n      offset >>>= 0\n      if (offset < 0 || offset + 2 > this.buffer.byteLength) {\n        throw RangeError(\n          'Illegal offset: 0 <= ' + offset + ' (+' + 2 + ') <= ' + this.buffer.byteLength,\n        )\n      }\n    }\n    const value = this.view.getUint16(offset!, this.littleEndian)\n    if (relative) {\n      this.offset += 2\n    }\n    return value\n  }\n\n  /**\n   * Reads a 16bit unsigned integer. This is an alias of {@link ByteBuffer#readUint16}.\n   * @function\n   * @param {number=} offset Offset to read from. Will use and advance {@link ByteBuffer#offset} by `2` if omitted.\n   * @returns {number} Value read\n   * @throws {TypeError} If `offset` is not a valid number\n   * @throws {RangeError} If `offset` is out of bounds\n   * @expose\n   */\n  readUInt16 = this.readUint16\n\n  // types/ints/int32\n\n  /**\n   * Writes a 32bit signed integer.\n   * @param {number} value Value to write\n   * @param {number=} offset Offset to write to. Will use and increase {@link ByteBuffer#offset} by `4` if omitted.\n   * @expose\n   */\n  writeInt32(value: number, offset?: number) {\n    const relative = typeof offset === 'undefined'\n    if (relative) {\n      offset = this.offset\n    }\n    if (!this.noAssert) {\n      if (typeof value !== 'number' || value % 1 !== 0) {\n        throw TypeError('Illegal value: ' + value + ' (not an integer)')\n      }\n      value |= 0\n      if (typeof offset !== 'number' || offset % 1 !== 0) {\n        throw TypeError('Illegal offset: ' + offset + ' (not an integer)')\n      }\n      offset >>>= 0\n      if (offset < 0 || offset + 0 > this.buffer.byteLength) {\n        throw RangeError(\n          'Illegal offset: 0 <= ' + offset + ' (+' + 0 + ') <= ' + this.buffer.byteLength,\n        )\n      }\n    }\n    offset! += 4\n    let capacity4 = this.buffer.byteLength\n    if (offset! > capacity4) {\n      this.resize((capacity4 *= 2) > offset! ? capacity4 : offset!)\n    }\n    offset! -= 4\n    this.view.setInt32(offset!, value, this.littleEndian)\n    if (relative) {\n      this.offset += 4\n    }\n    return this\n  }\n\n  /**\n   * Writes a 32bit signed integer. This is an alias of {@link ByteBuffer#writeInt32}.\n   * @param {number} value Value to write\n   * @param {number=} offset Offset to write to. Will use and increase {@link ByteBuffer#offset} by `4` if omitted.\n   * @expose\n   */\n  writeInt = this.writeInt32\n\n  /**\n   * Reads a 32bit signed integer.\n   * @param {number=} offset Offset to read from. Will use and increase {@link ByteBuffer#offset} by `4` if omitted.\n   * @returns {number} Value read\n   * @expose\n   */\n  readInt32(offset?: number): number {\n    const relative = typeof offset === 'undefined'\n    if (relative) {\n      offset = this.offset\n    }\n    if (!this.noAssert) {\n      if (typeof offset !== 'number' || offset % 1 !== 0) {\n        throw TypeError('Illegal offset: ' + offset + ' (not an integer)')\n      }\n      offset >>>= 0\n      if (offset < 0 || offset + 4 > this.buffer.byteLength) {\n        throw RangeError(\n          'Illegal offset: 0 <= ' + offset + ' (+' + 4 + ') <= ' + this.buffer.byteLength,\n        )\n      }\n    }\n    const value = this.view.getInt32(offset!, this.littleEndian)\n    if (relative) {\n      this.offset += 4\n    }\n    return value\n  }\n\n  /**\n   * Reads a 32bit signed integer. This is an alias of {@link ByteBuffer#readInt32}.\n   * @param {number=} offset Offset to read from. Will use and advance {@link ByteBuffer#offset} by `4` if omitted.\n   * @returns {number} Value read\n   * @expose\n   */\n  readInt = this.readInt32\n\n  /**\n   * Writes a 32bit unsigned integer.\n   * @param {number} value Value to write\n   * @param {number=} offset Offset to write to. Will use and increase {@link ByteBuffer#offset} by `4` if omitted.\n   * @expose\n   */\n  writeUint32(value: number, offset?: number) {\n    const relative = typeof offset === 'undefined'\n    if (relative) {\n      offset = this.offset\n    }\n    if (!this.noAssert) {\n      if (typeof value !== 'number' || value % 1 !== 0) {\n        throw TypeError('Illegal value: ' + value + ' (not an integer)')\n      }\n      value >>>= 0\n      if (typeof offset !== 'number' || offset % 1 !== 0) {\n        throw TypeError('Illegal offset: ' + offset + ' (not an integer)')\n      }\n      offset >>>= 0\n      if (offset < 0 || offset + 0 > this.buffer.byteLength) {\n        throw RangeError(\n          'Illegal offset: 0 <= ' + offset + ' (+' + 0 + ') <= ' + this.buffer.byteLength,\n        )\n      }\n    }\n    offset! += 4\n    let capacity5 = this.buffer.byteLength\n    if (offset! > capacity5) {\n      this.resize((capacity5 *= 2) > offset! ? capacity5 : offset!)\n    }\n    offset! -= 4\n    this.view.setUint32(offset!, value, this.littleEndian)\n    if (relative) {\n      this.offset += 4\n    }\n    return this\n  }\n\n  /**\n   * Writes a 32bit unsigned integer. This is an alias of {@link ByteBuffer#writeUint32}.\n   * @function\n   * @param {number} value Value to write\n   * @param {number=} offset Offset to write to. Will use and increase {@link ByteBuffer#offset} by `4` if omitted.\n   * @expose\n   */\n  writeUInt32 = this.writeUint32\n\n  /**\n   * Reads a 32bit unsigned integer.\n   * @param {number=} offset Offset to read from. Will use and increase {@link ByteBuffer#offset} by `4` if omitted.\n   * @returns {number} Value read\n   * @expose\n   */\n  readUint32(offset?: number): number {\n    const relative = typeof offset === 'undefined'\n    if (relative) {\n      offset = this.offset\n    }\n    if (!this.noAssert) {\n      if (typeof offset !== 'number' || offset % 1 !== 0) {\n        throw TypeError('Illegal offset: ' + offset + ' (not an integer)')\n      }\n      offset >>>= 0\n      if (offset < 0 || offset + 4 > this.buffer.byteLength) {\n        throw RangeError(\n          'Illegal offset: 0 <= ' + offset + ' (+' + 4 + ') <= ' + this.buffer.byteLength,\n        )\n      }\n    }\n    const value = this.view.getUint32(offset!, this.littleEndian)\n    if (relative) {\n      this.offset += 4\n    }\n    return value\n  }\n\n  /**\n   * Reads a 32bit unsigned integer. This is an alias of {@link ByteBuffer#readUint32}.\n   * @function\n   * @param {number=} offset Offset to read from. Will use and increase {@link ByteBuffer#offset} by `4` if omitted.\n   * @returns {number} Value read\n   * @expose\n   */\n  readUInt32 = this.readUint32\n\n  /**\n   * Writes a 32bit float.\n   * @param {number} value Value to write\n   * @param {number=} offset Offset to write to. Will use and increase {@link ByteBuffer#offset} by `4` if omitted.\n   * @returns {!ByteBuffer} this\n   * @expose\n   */\n  writeFloat32(value: number, offset?: number): ByteBuffer {\n    const relative = typeof offset === 'undefined'\n    if (relative) {\n      offset = this.offset\n    }\n    if (!this.noAssert) {\n      if (typeof value !== 'number') {\n        throw TypeError('Illegal value: ' + value + ' (not a number)')\n      }\n      if (typeof offset !== 'number' || offset % 1 !== 0) {\n        throw TypeError('Illegal offset: ' + offset + ' (not an integer)')\n      }\n      offset >>>= 0\n      if (offset < 0 || offset + 0 > this.buffer.byteLength) {\n        throw RangeError(\n          'Illegal offset: 0 <= ' + offset + ' (+' + 0 + ') <= ' + this.buffer.byteLength,\n        )\n      }\n    }\n    offset! += 4\n    let capacity8 = this.buffer.byteLength\n    if (offset! > capacity8) {\n      this.resize((capacity8 *= 2) > offset! ? capacity8 : offset!)\n    }\n    offset! -= 4\n    this.view.setFloat32(offset!, value, this.littleEndian)\n    if (relative) {\n      this.offset += 4\n    }\n    return this\n  }\n\n  /**\n   * Writes a 32bit float. This is an alias of {@link ByteBuffer#writeFloat32}.\n   * @function\n   * @param {number} value Value to write\n   * @param {number=} offset Offset to write to. Will use and increase {@link ByteBuffer#offset} by `4` if omitted.\n   * @returns {!ByteBuffer} this\n   * @expose\n   */\n  writeFloat = this.writeFloat32\n\n  /**\n   * Reads a 32bit float.\n   * @param {number=} offset Offset to read from. Will use and increase {@link ByteBuffer#offset} by `4` if omitted.\n   * @returns {number}\n   * @expose\n   */\n  readFloat32(offset?: number): number {\n    const relative = typeof offset === 'undefined'\n    if (relative) {\n      offset = this.offset\n    }\n    if (!this.noAssert) {\n      if (typeof offset !== 'number' || offset % 1 !== 0) {\n        throw TypeError('Illegal offset: ' + offset + ' (not an integer)')\n      }\n      offset >>>= 0\n      if (offset < 0 || offset + 4 > this.buffer.byteLength) {\n        throw RangeError(\n          'Illegal offset: 0 <= ' + offset + ' (+' + 4 + ') <= ' + this.buffer.byteLength,\n        )\n      }\n    }\n    const value = this.view.getFloat32(offset!, this.littleEndian)\n    if (relative) {\n      this.offset += 4\n    }\n    return value\n  }\n\n  /**\n   * Reads a 32bit float. This is an alias of {@link ByteBuffer#readFloat32}.\n   * @function\n   * @param {number=} offset Offset to read from. Will use and increase {@link ByteBuffer#offset} by `4` if omitted.\n   * @returns {number}\n   * @expose\n   */\n  readFloat = this.readFloat32\n\n  // types/floats/float64\n\n  /**\n   * Writes a 64bit float.\n   * @param {number} value Value to write\n   * @param {number=} offset Offset to write to. Will use and increase {@link ByteBuffer#offset} by `8` if omitted.\n   * @returns {!ByteBuffer} this\n   * @expose\n   */\n  writeFloat64(value: number, offset?: number): ByteBuffer {\n    const relative = typeof offset === 'undefined'\n    if (relative) {\n      offset = this.offset\n    }\n    if (!this.noAssert) {\n      if (typeof value !== 'number') {\n        throw TypeError('Illegal value: ' + value + ' (not a number)')\n      }\n      if (typeof offset !== 'number' || offset % 1 !== 0) {\n        throw TypeError('Illegal offset: ' + offset + ' (not an integer)')\n      }\n      offset >>>= 0\n      if (offset < 0 || offset + 0 > this.buffer.byteLength) {\n        throw RangeError(\n          'Illegal offset: 0 <= ' + offset + ' (+' + 0 + ') <= ' + this.buffer.byteLength,\n        )\n      }\n    }\n    offset! += 8\n    let capacity9 = this.buffer.byteLength\n    if (offset! > capacity9) {\n      this.resize((capacity9 *= 2) > offset! ? capacity9 : offset!)\n    }\n    offset! -= 8\n    this.view.setFloat64(offset!, value, this.littleEndian)\n    if (relative) {\n      this.offset += 8\n    }\n    return this\n  }\n\n  /**\n   * Writes a 64bit float. This is an alias of {@link ByteBuffer#writeFloat64}.\n   * @function\n   * @param {number} value Value to write\n   * @param {number=} offset Offset to write to. Will use and increase {@link ByteBuffer#offset} by `8` if omitted.\n   * @returns {!ByteBuffer} this\n   * @expose\n   */\n  writeDouble = this.writeFloat64\n\n  /**\n   * Reads a 64bit float.\n   * @param {number=} offset Offset to read from. Will use and increase {@link ByteBuffer#offset} by `8` if omitted.\n   * @returns {number}\n   * @expose\n   */\n  readFloat64(offset?: number): number {\n    const relative = typeof offset === 'undefined'\n    if (relative) {\n      offset = this.offset\n    }\n    if (!this.noAssert) {\n      if (typeof offset !== 'number' || offset % 1 !== 0) {\n        throw TypeError('Illegal offset: ' + offset + ' (not an integer)')\n      }\n      offset >>>= 0\n      if (offset < 0 || offset + 8 > this.buffer.byteLength) {\n        throw RangeError(\n          'Illegal offset: 0 <= ' + offset + ' (+' + 8 + ') <= ' + this.buffer.byteLength,\n        )\n      }\n    }\n    const value = this.view.getFloat64(offset!, this.littleEndian)\n    if (relative) {\n      this.offset += 8\n    }\n    return value\n  }\n\n  /**\n   * Reads a 64bit float. This is an alias of {@link ByteBuffer#readFloat64}.\n   * @function\n   * @param {number=} offset Offset to read from. Will use and increase {@link ByteBuffer#offset} by `8` if omitted.\n   * @returns {number}\n   * @expose\n   */\n  readDouble = this.readFloat64\n\n  /**\n   * Appends some data to this ByteBuffer. This will overwrite any contents behind the specified offset up to the appended\n   *  data's length.\n   * @param {!ByteBuffer|!ArrayBuffer|!Uint8Array} source Data to append. If `source` is a ByteBuffer, its offsets\n   *  will be modified according to the performed read operation.\n   * @param {(string|number)=} encoding Encoding if `data` is a string (\"base64\", \"hex\", \"binary\", defaults to \"utf8\")\n   * @param {number=} offset Offset to append at. Will use and increase {@link ByteBuffer#offset} by the number of bytes\n   *  written if omitted.\n   * @returns {!ByteBuffer} this\n   * @expose\n   * @example A relative `<01 02>03.append(<04 05>)` will result in `<01 02 04 05>, 04 05|`\n   * @example An absolute `<01 02>03.append(04 05>, 1)` will result in `<01 04>05, 04 05|`\n   */\n  append(source: ByteBuffer | ArrayBuffer | Uint8Array, offset?: number): ByteBuffer {\n    const relative = typeof offset === 'undefined'\n    if (relative) {\n      offset = this.offset\n    }\n    if (!this.noAssert) {\n      if (typeof offset !== 'number' || offset % 1 !== 0) {\n        throw TypeError('Illegal offset: ' + offset + ' (not an integer)')\n      }\n      offset >>>= 0\n      if (offset < 0 || offset + 0 > this.buffer.byteLength) {\n        throw RangeError(\n          'Illegal offset: 0 <= ' + offset + ' (+' + 0 + ') <= ' + this.buffer.byteLength,\n        )\n      }\n    }\n    if (!(source instanceof ByteBuffer)) {\n      source = ByteBuffer.wrap(source)\n    }\n    const length = source.limit - source.offset\n    if (length <= 0) {\n      return this\n    } // Nothing to append\n    offset! += length\n    let capacity16 = this.buffer.byteLength\n    if (offset! > capacity16) {\n      this.resize((capacity16 *= 2) > offset! ? capacity16 : offset!)\n    }\n    offset! -= length\n    new Uint8Array(this.buffer, offset).set(\n      new Uint8Array(source.buffer).subarray(source.offset, source.limit),\n    )\n    source.offset += length\n    if (relative) {\n      this.offset += length\n    }\n    return this\n  }\n\n  /**\n     * Appends this ByteBuffer's contents to another ByteBuffer. This will overwrite any contents at and after the\n        specified offset up to the length of this ByteBuffer's data.\n     * @param {!ByteBuffer} target Target ByteBuffer\n     * @param {number=} offset Offset to append to. Will use and increase {@link ByteBuffer#offset} by the number of bytes\n     *  read if omitted.\n     * @returns {!ByteBuffer} this\n     * @expose\n     * @see ByteBuffer#append\n     */\n  appendTo(target: ByteBuffer, offset?: number): ByteBuffer {\n    target.append(this, offset)\n    return this\n  }\n\n  /**\n   * Enables or disables assertions of argument types and offsets. Assertions are enabled by default but you can opt to\n   *  disable them if your code already makes sure that everything is valid.\n   * @param {boolean} assert `true` to enable assertions, otherwise `false`\n   * @returns {!ByteBuffer} this\n   * @expose\n   */\n  assert(assert: boolean): ByteBuffer {\n    this.noAssert = !assert\n    return this\n  }\n\n  /**\n   * Gets the capacity of this ByteBuffer's backing buffer.\n   * @returns {number} Capacity of the backing buffer\n   * @expose\n   */\n  capacity(): number {\n    return this.buffer.byteLength\n  }\n\n  /**\n   * Clears this ByteBuffer's offsets by setting {@link ByteBuffer#offset} to `0` and {@link ByteBuffer#limit} to the\n   *  backing buffer's capacity. Discards {@link ByteBuffer#markedOffset}.\n   * @returns {!ByteBuffer} this\n   * @expose\n   */\n  clear(): ByteBuffer {\n    this.offset = 0\n    this.limit = this.buffer.byteLength\n    this.markedOffset = -1\n    return this\n  }\n\n  /**\n   * Creates a cloned instance of this ByteBuffer, preset with this ByteBuffer's values for {@link ByteBuffer#offset},\n   *  {@link ByteBuffer#markedOffset} and {@link ByteBuffer#limit}.\n   * @param {boolean=} copy Whether to copy the backing buffer or to return another view on the same, defaults to `false`\n   * @returns {!ByteBuffer} Cloned instance\n   * @expose\n   */\n  clone(copy?: boolean): ByteBuffer {\n    const bb = new ByteBuffer(0, this.littleEndian, this.noAssert)\n    if (copy) {\n      bb.buffer = new ArrayBuffer(this.buffer.byteLength)\n      new Uint8Array(bb.buffer).set(this.buffer as any)\n      bb.view = new DataView(bb.buffer)\n    } else {\n      bb.buffer = this.buffer\n      bb.view = this.view\n    }\n    bb.offset = this.offset\n    bb.markedOffset = this.markedOffset\n    bb.limit = this.limit\n    return bb\n  }\n\n  /**\n   * Compacts this ByteBuffer to be backed by a {@link ByteBuffer#buffer} of its contents' length. Contents are the bytes\n   *  between {@link ByteBuffer#offset} and {@link ByteBuffer#limit}. Will set `offset = 0` and `limit = capacity` and\n   *  adapt {@link ByteBuffer#markedOffset} to the same relative position if set.\n   * @param {number=} begin Offset to start at, defaults to {@link ByteBuffer#offset}\n   * @param {number=} end Offset to end at, defaults to {@link ByteBuffer#limit}\n   * @returns {!ByteBuffer} this\n   * @expose\n   */\n  compact(begin: number | undefined, end: number | undefined): ByteBuffer {\n    if (typeof begin === 'undefined') {\n      begin = this.offset\n    }\n    if (typeof end === 'undefined') {\n      end = this.limit\n    }\n    if (!this.noAssert) {\n      if (typeof begin !== 'number' || begin % 1 !== 0) {\n        throw TypeError('Illegal begin: Not an integer')\n      }\n      begin >>>= 0\n      if (typeof end !== 'number' || end % 1 !== 0) {\n        throw TypeError('Illegal end: Not an integer')\n      }\n      end >>>= 0\n      if (begin < 0 || begin > end || end > this.buffer.byteLength) {\n        throw RangeError(\n          'Illegal range: 0 <= ' + begin + ' <= ' + end + ' <= ' + this.buffer.byteLength,\n        )\n      }\n    }\n    if (begin === 0 && end === this.buffer.byteLength) {\n      return this\n    } // Already compacted\n    const len = end - begin\n    if (len === 0) {\n      this.buffer = EMPTY_BUFFER\n      this.view = new DataView(EMPTY_BUFFER)\n      if (this.markedOffset >= 0) {\n        this.markedOffset -= begin\n      }\n      this.offset = 0\n      this.limit = 0\n      return this\n    }\n    const buffer = new ArrayBuffer(len)\n    new Uint8Array(buffer).set(new Uint8Array(this.buffer).subarray(begin, end))\n    this.buffer = buffer\n    this.view = new DataView(buffer)\n    if (this.markedOffset >= 0) {\n      this.markedOffset -= begin\n    }\n    this.offset = 0\n    this.limit = len\n    return this\n  }\n\n  /**\n   * Creates a copy of this ByteBuffer's contents. Contents are the bytes between {@link ByteBuffer#offset} and\n   *  {@link ByteBuffer#limit}.\n   * @param {number=} begin Begin offset, defaults to {@link ByteBuffer#offset}.\n   * @param {number=} end End offset, defaults to {@link ByteBuffer#limit}.\n   * @returns {!ByteBuffer} Copy\n   * @expose\n   */\n  copy(begin: number | undefined, end: number | undefined): ByteBuffer {\n    if (typeof begin === 'undefined') {\n      begin = this.offset\n    }\n    if (typeof end === 'undefined') {\n      end = this.limit\n    }\n    if (!this.noAssert) {\n      if (typeof begin !== 'number' || begin % 1 !== 0) {\n        throw TypeError('Illegal begin: Not an integer')\n      }\n      begin >>>= 0\n      if (typeof end !== 'number' || end % 1 !== 0) {\n        throw TypeError('Illegal end: Not an integer')\n      }\n      end >>>= 0\n      if (begin < 0 || begin > end || end > this.buffer.byteLength) {\n        throw RangeError(\n          'Illegal range: 0 <= ' + begin + ' <= ' + end + ' <= ' + this.buffer.byteLength,\n        )\n      }\n    }\n    if (begin === end) {\n      return new ByteBuffer(0, this.littleEndian, this.noAssert)\n    }\n    const capacity = end - begin\n    const bb = new ByteBuffer(capacity, this.littleEndian, this.noAssert)\n    bb.offset = 0\n    bb.limit = capacity\n    if (bb.markedOffset >= 0) {\n      bb.markedOffset -= begin\n    }\n    this.copyTo(bb, 0, begin, end)\n    return bb\n  }\n\n  /**\n   * Copies this ByteBuffer's contents to another ByteBuffer. Contents are the bytes between {@link ByteBuffer#offset} and\n   *  {@link ByteBuffer#limit}.\n   * @param {!ByteBuffer} target Target ByteBuffer\n   * @param {number=} targetOffset Offset to copy to. Will use and increase the target's {@link ByteBuffer#offset}\n   *  by the number of bytes copied if omitted.\n   * @param {number=} sourceOffset Offset to start copying from. Will use and increase {@link ByteBuffer#offset} by the\n   *  number of bytes copied if omitted.\n   * @param {number=} sourceLimit Offset to end copying from, defaults to {@link ByteBuffer#limit}\n   * @returns {!ByteBuffer} this\n   * @expose\n   */\n  copyTo(\n    target: ByteBuffer,\n    targetOffset?: number,\n    sourceOffset?: number,\n    sourceLimit?: number,\n  ): ByteBuffer {\n    let relative, targetRelative\n    if (!this.noAssert) {\n      if (!(target instanceof ByteBuffer)) {\n        throw TypeError('Illegal target: Not a ByteBuffer')\n      }\n    }\n    // eslint-disable-next-line no-cond-assign\n    targetOffset = (targetRelative = typeof targetOffset === 'undefined')\n      ? target.offset\n      : targetOffset | 0\n    // eslint-disable-next-line no-cond-assign\n    sourceOffset = (relative = typeof sourceOffset === 'undefined') ? this.offset : sourceOffset | 0\n    sourceLimit = typeof sourceLimit === 'undefined' ? this.limit : sourceLimit | 0\n\n    if (targetOffset < 0 || targetOffset > target.buffer.byteLength) {\n      throw RangeError(\n        'Illegal target range: 0 <= ' + targetOffset + ' <= ' + target.buffer.byteLength,\n      )\n    }\n    if (sourceOffset < 0 || sourceLimit > this.buffer.byteLength) {\n      throw RangeError(\n        'Illegal source range: 0 <= ' + sourceOffset + ' <= ' + this.buffer.byteLength,\n      )\n    }\n\n    const len = sourceLimit - sourceOffset\n    if (len === 0) {\n      return target\n    } // Nothing to copy\n\n    target.ensureCapacity(targetOffset + len)\n\n    new Uint8Array(target.buffer).set(\n      new Uint8Array(this.buffer).subarray(sourceOffset, sourceLimit),\n      targetOffset,\n    )\n\n    if (relative) {\n      this.offset += len\n    }\n    if (targetRelative) {\n      target.offset += len\n    }\n\n    return this\n  }\n\n  /**\n   * Makes sure that this ByteBuffer is backed by a {@link ByteBuffer#buffer} of at least the specified capacity. If the\n   *  current capacity is exceeded, it will be doubled. If double the current capacity is less than the required capacity,\n   *  the required capacity will be used instead.\n   * @param {number} capacity Required capacity\n   * @returns {!ByteBuffer} this\n   * @expose\n   */\n  ensureCapacity(capacity: number): ByteBuffer {\n    let current = this.buffer.byteLength\n    if (current < capacity) {\n      return this.resize((current *= 2) > capacity ? current : capacity)\n    }\n    return this\n  }\n\n  /**\n   * Overwrites this ByteBuffer's contents with the specified value. Contents are the bytes between\n   *  {@link ByteBuffer#offset} and {@link ByteBuffer#limit}.\n   * @param {number|string} value Byte value to fill with. If given as a string, the first character is used.\n   * @param {number=} begin Begin offset. Will use and increase {@link ByteBuffer#offset} by the number of bytes\n   *  written if omitted. defaults to {@link ByteBuffer#offset}.\n   * @param {number=} end End offset, defaults to {@link ByteBuffer#limit}.\n   * @returns {!ByteBuffer} this\n   * @expose\n   * @example `someByteBuffer.clear().fill(0)` fills the entire backing buffer with zeroes\n   */\n  fill(value: number | string, begin?: number, end?: number): ByteBuffer {\n    const relative = typeof begin === 'undefined'\n    if (relative) {\n      begin = this.offset\n    }\n    if (typeof value === 'string' && value.length > 0) {\n      value = value.charCodeAt(0)\n    }\n    if (typeof begin === 'undefined') {\n      begin = this.offset\n    }\n    if (typeof end === 'undefined') {\n      end = this.limit\n    }\n    if (!this.noAssert) {\n      if (typeof value !== 'number' || value % 1 !== 0) {\n        throw TypeError('Illegal value: ' + value + ' (not an integer)')\n      }\n      value |= 0\n      if (typeof begin !== 'number' || begin % 1 !== 0) {\n        throw TypeError('Illegal begin: Not an integer')\n      }\n      begin >>>= 0\n      if (typeof end !== 'number' || end % 1 !== 0) {\n        throw TypeError('Illegal end: Not an integer')\n      }\n      end >>>= 0\n      if (begin < 0 || begin > end || end > this.buffer.byteLength) {\n        throw RangeError(\n          'Illegal range: 0 <= ' + begin + ' <= ' + end + ' <= ' + this.buffer.byteLength,\n        )\n      }\n    }\n    if (begin >= end) {\n      return this\n    } // Nothing to fill\n    while (begin < end) {\n      this.view.setUint8(begin++, value as number)\n    }\n    if (relative) {\n      this.offset = begin\n    }\n    return this\n  }\n\n  /**\n   * Makes this ByteBuffer ready for a new sequence of write or relative read operations. Sets `limit = offset` and\n   *  `offset = 0`. Make sure always to flip a ByteBuffer when all relative read or write operations are complete.\n   * @returns {!ByteBuffer} this\n   * @expose\n   */\n  flip(): ByteBuffer {\n    this.limit = this.offset\n    this.offset = 0\n    return this\n  }\n\n  /**\n   * Marks an offset on this ByteBuffer to be used later.\n   * @param {number=} offset Offset to mark. Defaults to {@link ByteBuffer#offset}.\n   * @returns {!ByteBuffer} this\n   * @throws {TypeError} If `offset` is not a valid number\n   * @throws {RangeError} If `offset` is out of bounds\n   * @see ByteBuffer#reset\n   * @expose\n   */\n  mark(offset?: number): ByteBuffer {\n    offset = typeof offset === 'undefined' ? this.offset : offset\n    if (!this.noAssert) {\n      if (typeof offset !== 'number' || offset % 1 !== 0) {\n        throw TypeError('Illegal offset: ' + offset + ' (not an integer)')\n      }\n      offset >>>= 0\n      if (offset < 0 || offset + 0 > this.buffer.byteLength) {\n        throw RangeError(\n          'Illegal offset: 0 <= ' + offset + ' (+' + 0 + ') <= ' + this.buffer.byteLength,\n        )\n      }\n    }\n    this.markedOffset = offset\n    return this\n  }\n\n  /**\n   * Sets the byte order.\n   * @param {boolean} littleEndian `true` for little endian byte order, `false` for big endian\n   * @returns {!ByteBuffer} this\n   * @expose\n   */\n  order(littleEndian: boolean): ByteBuffer {\n    if (!this.noAssert) {\n      if (typeof littleEndian !== 'boolean') {\n        throw TypeError('Illegal littleEndian: Not a boolean')\n      }\n    }\n    this.littleEndian = !!littleEndian\n    return this\n  }\n\n  /**\n   * Switches (to) little endian byte order.\n   * @param {boolean=} littleEndian Defaults to `true`, otherwise uses big endian\n   * @returns {!ByteBuffer} this\n   * @expose\n   */\n  LE(littleEndian: boolean | undefined): ByteBuffer {\n    this.littleEndian = typeof littleEndian !== 'undefined' ? !!littleEndian : true\n    return this\n  }\n\n  /**\n   * Switches (to) big endian byte order.\n   * @param {boolean=} bigEndian Defaults to `true`, otherwise uses little endian\n   * @returns {!ByteBuffer} this\n   * @expose\n   */\n  BE(bigEndian: boolean | undefined): ByteBuffer {\n    this.littleEndian = typeof bigEndian !== 'undefined' ? !bigEndian : false\n    return this\n  }\n\n  /**\n   * Prepends some data to this ByteBuffer. This will overwrite any contents before the specified offset up to the\n   *  prepended data's length. If there is not enough space available before the specified `offset`, the backing buffer\n   *  will be resized and its contents moved accordingly.\n   * @param {!ByteBuffer|!ArrayBuffer} source Data to prepend. If `source` is a ByteBuffer, its offset will be\n   *  modified according to the performed read operation.\n   * @param {(string|number)=} encoding Encoding if `data` is a string (\"base64\", \"hex\", \"binary\", defaults to \"utf8\")\n   * @param {number=} offset Offset to prepend at. Will use and decrease {@link ByteBuffer#offset} by the number of bytes\n   *  prepended if omitted.\n   * @returns {!ByteBuffer} this\n   * @expose\n   * @example A relative `00<01 02 03>.prepend(<04 05>)` results in `<04 05 01 02 03>, 04 05|`\n   * @example An absolute `00<01 02 03>.prepend(<04 05>, 2)` results in `04<05 02 03>, 04 05|`\n   */\n  prepend(source: ByteBuffer | ArrayBuffer, offset?: number): ByteBuffer {\n    const relative = typeof offset === 'undefined'\n    if (relative) {\n      offset = this.offset\n    }\n    if (!this.noAssert) {\n      if (typeof offset !== 'number' || offset % 1 !== 0) {\n        throw TypeError('Illegal offset: ' + offset + ' (not an integer)')\n      }\n      offset >>>= 0\n      if (offset < 0 || offset + 0 > this.buffer.byteLength) {\n        throw RangeError(\n          'Illegal offset: 0 <= ' + offset + ' (+' + 0 + ') <= ' + this.buffer.byteLength,\n        )\n      }\n    }\n    if (!(source instanceof ByteBuffer)) {\n      source = ByteBuffer.wrap(source)\n    }\n    const len = source.limit - source.offset\n    if (len <= 0) {\n      return this\n    } // Nothing to prepend\n    const diff = len - offset!\n    if (diff > 0) {\n      // Not enough space before offset, so resize + move\n      const buffer = new ArrayBuffer(this.buffer.byteLength + diff)\n      const arrayView = new Uint8Array(buffer)\n      arrayView.set(new Uint8Array(this.buffer).subarray(offset, this.buffer.byteLength), len)\n      this.buffer = buffer\n      this.view = new DataView(buffer)\n      this.offset += diff\n      if (this.markedOffset >= 0) {\n        this.markedOffset += diff\n      }\n      this.limit += diff\n      offset! += diff\n    } else {\n      const arrayView = new Uint8Array(this.buffer)\n      arrayView.set(\n        new Uint8Array(source.buffer).subarray(source.offset, source.limit),\n        offset! - len,\n      )\n    }\n\n    source.offset = source.limit\n    if (relative) {\n      this.offset -= len\n    }\n    return this\n  }\n\n  /**\n   * Prepends this ByteBuffer to another ByteBuffer. This will overwrite any contents before the specified offset up to the\n   *  prepended data's length. If there is not enough space available before the specified `offset`, the backing buffer\n   *  will be resized and its contents moved accordingly.\n   * @param {!ByteBuffer} target Target ByteBuffer\n   * @param {number=} offset Offset to prepend at. Will use and decrease {@link ByteBuffer#offset} by the number of bytes\n   *  prepended if omitted.\n   * @returns {!ByteBuffer} this\n   * @expose\n   * @see ByteBuffer#prepend\n   */\n  prependTo(target: ByteBuffer, offset?: number): ByteBuffer {\n    target.prepend(this, offset)\n    return this\n  }\n\n  /**\n   * Gets the number of remaining readable bytes. Contents are the bytes between {@link ByteBuffer#offset} and\n   *  {@link ByteBuffer#limit}, so this returns `limit - offset`.\n   * @returns {number} Remaining readable bytes. May be negative if `offset > limit`.\n   * @expose\n   */\n  remaining(): number {\n    return this.limit - this.offset\n  }\n\n  /**\n   * Resets this ByteBuffer's {@link ByteBuffer#offset}. If an offset has been marked through {@link ByteBuffer#mark}\n   *  before, `offset` will be set to {@link ByteBuffer#markedOffset}, which will then be discarded. If no offset has been\n   *  marked, sets `offset = 0`.\n   * @returns {!ByteBuffer} this\n   * @see ByteBuffer#mark\n   * @expose\n   */\n  reset(): ByteBuffer {\n    if (this.markedOffset >= 0) {\n      this.offset = this.markedOffset\n      this.markedOffset = -1\n    } else {\n      this.offset = 0\n    }\n    return this\n  }\n\n  /**\n   * Resizes this ByteBuffer to be backed by a buffer of at least the given capacity. Will do nothing if already that\n   *  large or larger.\n   * @param {number} capacity Capacity required\n   * @returns {!ByteBuffer} this\n   * @throws {TypeError} If `capacity` is not a number\n   * @throws {RangeError} If `capacity < 0`\n   * @expose\n   */\n  resize(capacity: number): ByteBuffer {\n    if (!this.noAssert) {\n      if (typeof capacity !== 'number' || capacity % 1 !== 0) {\n        throw TypeError('Illegal capacity: ' + capacity + ' (not an integer)')\n      }\n      capacity |= 0\n      if (capacity < 0) {\n        throw RangeError('Illegal capacity: 0 <= ' + capacity)\n      }\n    }\n    if (this.buffer.byteLength < capacity) {\n      const buffer = new ArrayBuffer(capacity)\n      new Uint8Array(buffer).set(new Uint8Array(this.buffer))\n      this.buffer = buffer\n      this.view = new DataView(buffer)\n    }\n    return this\n  }\n\n  /**\n   * Reverses this ByteBuffer's contents.\n   * @param {number=} begin Offset to start at, defaults to {@link ByteBuffer#offset}\n   * @param {number=} end Offset to end at, defaults to {@link ByteBuffer#limit}\n   * @returns {!ByteBuffer} this\n   * @expose\n   */\n  reverse(begin: number | undefined, end: number | undefined): ByteBuffer {\n    if (typeof begin === 'undefined') {\n      begin = this.offset\n    }\n    if (typeof end === 'undefined') {\n      end = this.limit\n    }\n    if (!this.noAssert) {\n      if (typeof begin !== 'number' || begin % 1 !== 0) {\n        throw TypeError('Illegal begin: Not an integer')\n      }\n      begin >>>= 0\n      if (typeof end !== 'number' || end % 1 !== 0) {\n        throw TypeError('Illegal end: Not an integer')\n      }\n      end >>>= 0\n      if (begin < 0 || begin > end || end > this.buffer.byteLength) {\n        throw RangeError(\n          'Illegal range: 0 <= ' + begin + ' <= ' + end + ' <= ' + this.buffer.byteLength,\n        )\n      }\n    }\n    if (begin === end) {\n      return this\n    } // Nothing to reverse\n    Array.prototype.reverse.call(new Uint8Array(this.buffer).subarray(begin, end))\n    this.view = new DataView(this.buffer) // FIXME: Why exactly is this necessary?\n    return this\n  }\n\n  /**\n   * Skips the next `length` bytes. This will just advance\n   * @param {number} length Number of bytes to skip. May also be negative to move the offset back.\n   * @returns {!ByteBuffer} this\n   * @expose\n   */\n  skip(length: number): ByteBuffer {\n    if (!this.noAssert) {\n      if (typeof length !== 'number' || length % 1 !== 0) {\n        throw TypeError('Illegal length: ' + length + ' (not an integer)')\n      }\n      length |= 0\n    }\n    const offset = this.offset + length\n    if (!this.noAssert) {\n      if (offset < 0 || offset > this.buffer.byteLength) {\n        throw RangeError(\n          'Illegal length: 0 <= ' + this.offset + ' + ' + length + ' <= ' + this.buffer.byteLength,\n        )\n      }\n    }\n    this.offset = offset\n    return this\n  }\n\n  /**\n   * Slices this ByteBuffer by creating a cloned instance with `offset = begin` and `limit = end`.\n   * @param {number=} begin Begin offset, defaults to {@link ByteBuffer#offset}.\n   * @param {number=} end End offset, defaults to {@link ByteBuffer#limit}.\n   * @returns {!ByteBuffer} Clone of this ByteBuffer with slicing applied, backed by the same {@link ByteBuffer#buffer}\n   * @expose\n   */\n  slice(begin?: number, end?: number): ByteBuffer {\n    if (typeof begin === 'undefined') {\n      begin = this.offset\n    }\n    if (typeof end === 'undefined') {\n      end = this.limit\n    }\n    if (!this.noAssert) {\n      if (typeof begin !== 'number' || begin % 1 !== 0) {\n        throw TypeError('Illegal begin: Not an integer')\n      }\n      begin >>>= 0\n      if (typeof end !== 'number' || end % 1 !== 0) {\n        throw TypeError('Illegal end: Not an integer')\n      }\n      end >>>= 0\n      if (begin < 0 || begin > end || end > this.buffer.byteLength) {\n        throw RangeError(\n          'Illegal range: 0 <= ' + begin + ' <= ' + end + ' <= ' + this.buffer.byteLength,\n        )\n      }\n    }\n    const bb = this.clone()\n    bb.offset = begin\n    bb.limit = end\n    return bb\n  }\n\n  /**\n   * Writes a 64bit signed integer.\n   * @param {number|bigint} value Value to write\n   * @param {number=} offset Offset to write to. Will use and increase {@link ByteBuffer#offset} by `8` if omitted.\n   * @returns {!ByteBuffer} this\n   * @expose\n   */\n  writeInt64(value: bigint | number, offset?: number): ByteBuffer {\n    const relative = typeof offset === 'undefined'\n    if (typeof offset === 'undefined') {\n      offset = this.offset\n    }\n    if (!this.noAssert) {\n      if (typeof value === 'number') {\n        value = BigInt(value)\n      }\n      if (typeof offset !== 'number' || offset % 1 !== 0) {\n        throw TypeError('Illegal offset: ' + offset + ' (not an integer)')\n      }\n      offset >>>= 0\n      if (offset < 0 || offset + 0 > this.buffer.byteLength) {\n        throw RangeError(\n          'Illegal offset: 0 <= ' + offset + ' (+' + 0 + ') <= ' + this.buffer.byteLength,\n        )\n      }\n    }\n    if (typeof value === 'number') {\n      value = BigInt(value)\n    }\n    offset += 8\n    let capacity6 = this.buffer.byteLength\n    if (offset > capacity6) {\n      this.resize((capacity6 *= 2) > offset ? capacity6 : offset)\n    }\n    offset -= 8\n    this.view.setBigInt64(offset, value, this.littleEndian)\n    if (relative) {\n      this.offset += 8\n    }\n    return this\n  }\n\n  /**\n   * Writes a 64bit signed integer. This is an alias of {@link ByteBuffer#writeInt64}.\n   * @param {number|!bigint} value Value to write\n   * @param {number=} offset Offset to write to. Will use and increase {@link ByteBuffer#offset} by `8` if omitted.\n   * @returns {!ByteBuffer} this\n   * @expose\n   */\n  writeLong = this.writeInt64\n\n  /**\n   * Reads a 64bit signed integer.\n   * @param {number=} offset Offset to read from. Will use and increase {@link ByteBuffer#offset} by `8` if omitted.\n   * @returns {!bigint}\n   * @expose\n   */\n  readInt64(offset?: number): bigint {\n    const relative = typeof offset === 'undefined'\n    if (relative) {\n      offset = this.offset\n    }\n    if (!this.noAssert) {\n      if (typeof offset !== 'number' || offset % 1 !== 0) {\n        throw TypeError('Illegal offset: ' + offset + ' (not an integer)')\n      }\n      offset >>>= 0\n      if (offset < 0 || offset + 8 > this.buffer.byteLength) {\n        throw RangeError(\n          'Illegal offset: 0 <= ' + offset + ' (+' + 8 + ') <= ' + this.buffer.byteLength,\n        )\n      }\n    }\n    const value = this.view.getBigInt64(offset!, this.littleEndian)\n    if (relative) {\n      this.offset += 8\n    }\n    return value\n  }\n\n  /**\n   * Reads a 64bit signed integer. This is an alias of {@link ByteBuffer#readInt64}.\n   * @param {number=} offset Offset to read from. Will use and increase {@link ByteBuffer#offset} by `8` if omitted.\n   * @returns {!bigint}\n   * @expose\n   */\n  readLong = this.readInt64\n\n  /**\n   * Writes a 64bit unsigned integer.\n   * @param {number|!bigint} value Value to write\n   * @param {number=} offset Offset to write to. Will use and increase {@link ByteBuffer#offset} by `8` if omitted.\n   * @returns {!ByteBuffer} this\n   * @expose\n   */\n  writeUint64(value: number | bigint, offset?: number): ByteBuffer {\n    const relative = typeof offset === 'undefined'\n    if (typeof offset === 'undefined') {\n      offset = this.offset\n    }\n    if (!this.noAssert) {\n      if (typeof value === 'number') {\n        value = BigInt(value)\n      }\n      if (typeof offset !== 'number' || offset % 1 !== 0) {\n        throw TypeError('Illegal offset: ' + offset + ' (not an integer)')\n      }\n      offset >>>= 0\n      if (offset < 0 || offset + 0 > this.buffer.byteLength) {\n        throw RangeError(\n          'Illegal offset: 0 <= ' + offset + ' (+' + 0 + ') <= ' + this.buffer.byteLength,\n        )\n      }\n    }\n    if (typeof value === 'number') {\n      value = BigInt(value)\n    }\n    offset += 8\n    let capacity7 = this.buffer.byteLength\n    if (offset > capacity7) {\n      this.resize((capacity7 *= 2) > offset ? capacity7 : offset)\n    }\n    offset -= 8\n    this.view.setBigUint64(offset, value, this.littleEndian)\n    if (relative) {\n      this.offset += 8\n    }\n    return this\n  }\n\n  /**\n   * Writes a 64bit unsigned integer. This is an alias of {@link ByteBuffer#writeUint64}.\n   * @function\n   * @param {number|!bigint} value Value to write\n   * @param {number=} offset Offset to write to. Will use and increase {@link ByteBuffer#offset} by `8` if omitted.\n   * @returns {!ByteBuffer} this\n   * @expose\n   */\n  writeUInt64 = this.writeUint64\n\n  /**\n   * Reads a 64bit unsigned integer.\n   * @param {number=} offset Offset to read from. Will use and increase {@link ByteBuffer#offset} by `8` if omitted.\n   * @returns {!bigint}\n   * @expose\n   */\n  readUint64(offset?: number): bigint {\n    const relative = typeof offset === 'undefined'\n    if (relative) {\n      offset = this.offset\n    }\n    if (!this.noAssert) {\n      if (typeof offset !== 'number' || offset % 1 !== 0) {\n        throw TypeError('Illegal offset: ' + offset + ' (not an integer)')\n      }\n      offset >>>= 0\n      if (offset < 0 || offset + 8 > this.buffer.byteLength) {\n        throw RangeError(\n          'Illegal offset: 0 <= ' + offset + ' (+' + 8 + ') <= ' + this.buffer.byteLength,\n        )\n      }\n    }\n    const value = this.view.getBigUint64(offset!, this.littleEndian)\n    if (relative) {\n      this.offset += 8\n    }\n    return value\n  }\n\n  /**\n   * Reads a 64bit unsigned integer. This is an alias of {@link ByteBuffer#readUint64}.\n   * @function\n   * @param {number=} offset Offset to read from. Will use and increase {@link ByteBuffer#offset} by `8` if omitted.\n   * @returns {!Long}\n   * @expose\n   */\n  readUInt64 = this.readUint64\n\n  /**\n   * Returns a copy of the backing buffer that contains this ByteBuffer's contents. Contents are the bytes between\n   *  {@link ByteBuffer#offset} and {@link ByteBuffer#limit}.\n   * @param {boolean=} forceCopy If `true` returns a copy, otherwise returns a view referencing the same memory if\n   *  possible. Defaults to `false`\n   * @returns {!ArrayBuffer} Contents as an ArrayBuffer\n   * @expose\n   */\n  toBuffer(forceCopy?: boolean): ArrayBuffer {\n    let offset = this.offset\n    let limit = this.limit\n    if (!this.noAssert) {\n      if (typeof offset !== 'number' || offset % 1 !== 0) {\n        throw TypeError('Illegal offset: Not an integer')\n      }\n      offset >>>= 0\n      if (typeof limit !== 'number' || limit % 1 !== 0) {\n        throw TypeError('Illegal limit: Not an integer')\n      }\n      limit >>>= 0\n      if (offset < 0 || offset > limit || limit > this.buffer.byteLength) {\n        throw RangeError(\n          'Illegal range: 0 <= ' + offset + ' <= ' + limit + ' <= ' + this.buffer.byteLength,\n        )\n      }\n    }\n    if (!forceCopy) {\n      // NOTE: It's not possible to have another ArrayBuffer reference the same memory as the backing buffer. This is\n      // possible with Uint8Array#subarray only, but we have to return an ArrayBuffer by contract. So:\n      if (offset === 0 && limit === this.buffer.byteLength) {\n        return this.buffer\n      }\n\n      return this.buffer.slice(offset, limit)\n    }\n    if (offset === limit) {\n      return EMPTY_BUFFER\n    }\n    const buffer = new ArrayBuffer(limit - offset)\n    new Uint8Array(buffer).set(new Uint8Array(this.buffer).subarray(offset, limit), 0)\n    return buffer\n  }\n\n  /**\n   * Returns a raw buffer compacted to contain this ByteBuffer's contents. Contents are the bytes between\n   *  {@link ByteBuffer#offset} and {@link ByteBuffer#limit}. This is an alias of {@link ByteBuffer#toBuffer}.\n   * @function\n   * @param {boolean=} forceCopy If `true` returns a copy, otherwise returns a view referencing the same memory.\n   *  Defaults to `false`\n   * @returns {!ArrayBuffer} Contents as an ArrayBuffer\n   * @expose\n   */\n  toArrayBuffer = this.toBuffer\n}\n\n// helpers\n\n/**\n * @type {!ArrayBuffer}\n * @inner\n */\nconst EMPTY_BUFFER: ArrayBuffer = new ArrayBuffer(0)\n", "import { ByteBuffer } from '@xmcl/bytebuffer'\nimport type { ReadContext, WriteContext } from './index'\n\nexport function writeUTF8(out: ByteBuffer, str = '', context: WriteContext) {\n  const strlen = str.length\n  let utflen = 0\n  let c: number\n\n  /* use charAt instead of copying String to char array */\n  for (let idx = 0; idx < strlen; idx++) {\n    c = str.charCodeAt(idx)\n    if (c >= 0x0001 && c <= 0x007f) {\n      utflen++\n    } else if (c > 0x07ff) {\n      utflen += 3\n    } else {\n      utflen += 2\n    }\n  }\n\n  if (utflen > 65535) {\n    throw new RangeError('encoded string too long: ' + utflen + ' bytes')\n  }\n\n  out.writeInt16(utflen)\n  if (utflen > 0) {\n    out.writeBytes(context.encoder.encode(str))\n  }\n}\n\nexport function readUTF8(buff: ByteBuffer, context: ReadContext) {\n  const utflen = buff.readInt16()\n  const result = context.decoder.decode(buff.buffer.slice(buff.offset, buff.offset + utflen))\n  buff.offset += utflen\n  return result\n}\n", "import {\n  deflate as ideflate,\n  deflateSync,\n  gunzip as igunzip,\n  gunzipSync,\n  gzip as igzip,\n  gzipSync,\n  inflate as iinflate,\n  inflateSync,\n} from 'zlib'\nimport { promisify } from 'util'\n\nexport const gzip: (buf: Uint8Array) => Promise<Uint8Array> = promisify(igzip) as any\nexport const ungzip: (buf: Uint8Array) => Promise<Uint8Array> = promisify(igunzip) as any\nexport const inflate: (buf: Uint8Array) => Promise<Uint8Array> = promisify(iinflate) as any\nexport const deflate: (buf: Uint8Array) => Promise<Uint8Array> = promisify(ideflate) as any\n\nexport { gzipSync, gunzipSync, inflateSync, deflateSync }\n", "/**\n * The nbt module provides nbt {@link serialize} and {@link deserialize} functions.\n *\n * @packageDocumentation\n * @module @xmcl/nbt\n */\n\nimport { ByteBuffer } from '@xmcl/bytebuffer'\nimport { readUTF8, writeUTF8 } from './utils'\nimport {\n  ungzip,\n  inflate,\n  gunzipSync,\n  gzip,\n  gzipSync,\n  inflateSync,\n  deflateSync,\n  deflate,\n} from './zlib'\n\ntype Constructor<T> = new (...args: any) => T\n\nexport const kNBTPrototype = Symbol('NBTPrototype')\nexport const kNBTConstructor = Symbol('NBTConstructor')\n\nexport type TagType = TagTypePrimitive | typeof TagType.List | typeof TagType.Compound\n\nexport type TagTypePrimitive =\n  | typeof TagType.End\n  | typeof TagType.Byte\n  | typeof TagType.Short\n  | typeof TagType.Int\n  | typeof TagType.Long\n  | typeof TagType.Float\n  | typeof TagType.Double\n  | typeof TagType.ByteArray\n  | typeof TagType.String\n  | typeof TagType.IntArray\n  | typeof TagType.LongArray\n\n/**\n * Ensure the plain object or prototype object has correctly setup the NBTPrototype.\n *\n * @returns The NBTPrototype object\n */\nfunction ensurePrototype(object: object & { constructor?: Constructor<any> }) {\n  let nbtPrototype = getPrototypeOf(object)\n  // no prototype, create linked structure\n  if (!nbtPrototype) {\n    nbtPrototype = createPrototypeObject({}, object.constructor)\n    // link the prototype chain\n    setPrototypeOf(object, nbtPrototype)\n\n    // link the parent prototype chain\n    const parentProtoType = Object.getPrototypeOf(object)\n    if (parentProtoType !== Object.prototype) {\n      const parentPrototype = ensurePrototype(parentProtoType)\n      Object.setPrototypeOf(nbtPrototype, parentPrototype)\n    }\n  }\n  return nbtPrototype\n}\n\n/**\n * Annotate the type of a field\n */\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport function TagType<T>(type: TagType | Constructor<T> | Schema) {\n  return (clzPrototype: any, key: string) => {\n    const nbtPrototype = ensurePrototype(clzPrototype)\n    nbtPrototype[key] = type\n  }\n}\n\n/**\n * Construct the object from schema or constructor.\n *\n * - If pass-in value type is a schema object, it create a prototype with constructor constructing the object with this schema as NBTPrototype.\n * - If pass-in value is a constructor, it will try to take the NBTPrototype on the constructor to create object.\n */\nfunction constructObject(valueType: CompoundSchema | Constructor<any> | undefined): any {\n  if (!valueType) {\n    return {}\n  }\n  const prot =\n    typeof valueType === 'object' ? createPrototypeObject(valueType) : getPrototypeOf(valueType)\n  if (prot) return prot[kNBTConstructor]()\n  if (!prot) {\n    // value is constructor but no tag decodated yet.\n    // in this case we just return a empty object.\n    return {}\n  }\n}\n\nfunction createPrototypeObject(\n  schema: CompoundSchema,\n  constructor?: Constructor<any>,\n): NBTPrototype {\n  const proto: any = {\n    ...schema,\n  }\n  Object.defineProperty(proto, kNBTConstructor, {\n    value: () => {\n      let object: any\n      if (constructor) {\n        try {\n          object = new constructor()\n        } catch {\n          object = {}\n          Object.setPrototypeOf(object, constructor.prototype)\n        }\n      } else {\n        object = {}\n      }\n      Object.defineProperty(object, kNBTPrototype, { value: proto })\n      return object\n    },\n  })\n  return proto\n}\n\n/**\n * Get NBT schema for this object or a class.\n *\n * If the param is a object, any modifications on this prototype will only affact this object.\n * If the param is a class, any modifications on this prototype will affact all object under this class\n *\n * @param object The object or class\n */\nexport function getPrototypeOf(object: object | ((...p: any[]) => any)): NBTPrototype | undefined {\n  const targetObject = typeof object === 'function' ? object.prototype : object\n  return targetObject[kNBTPrototype]\n}\n\n/**\n * Set and change the NBT prototype of this object or class\n * @param object A object or a class function\n * @param nbtPrototype The nbt prototype\n */\nexport function setPrototypeOf(\n  object: object | ((...p: any[]) => any),\n  nbtPrototype: NBTPrototype,\n) {\n  const target = typeof object === 'function' ? object.prototype : object\n  Object.defineProperty(target, kNBTPrototype, { value: nbtPrototype })\n}\n\nfunction isTagType(n: number): n is TagType {\n  return n >= 0 && n <= 12\n}\n\n// eslint-disable-next-line @typescript-eslint/no-namespace, @typescript-eslint/no-redeclare\nexport namespace TagType {\n  export const End = 0 as const\n  export const Byte = 1 as const\n  export const Short = 2 as const\n  export const Int = 3 as const\n  export const Long = 4 as const\n  export const Float = 5 as const\n  export const Double = 6 as const\n  export const ByteArray = 7 as const\n  export const String = 8 as const\n  export const List = 9 as const\n  export const Compound = 10 as const\n  export const IntArray = 11 as const\n  export const LongArray = 12 as const\n\n  export function getName(tagType: TagType) {\n    return [\n      'End',\n      'Byte',\n      'Short',\n      'Int',\n      'Long',\n      'Float',\n      'Double',\n      'ByteArray',\n      'String',\n      'List',\n      'Compound',\n      'IntArray',\n      'LongArray',\n    ][tagType]\n  }\n}\n\nexport type Schema = ListSchema | CompoundSchema | Constructor<any>\nexport type ListSchema = [TagType | Schema]\nexport type CompoundSchema = { [key: string]: TagType | Schema }\n\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport interface NBTPrototype extends CompoundSchema {\n  [kNBTConstructor]: () => any\n}\n\nexport interface TagCoder {\n  write(buf: ByteBuffer, context: ReadContext): any\n  read(buf: ByteBuffer, value: any, context: WriteContext): void\n}\n\nconst coders: TagCoder[] = [\n  { write: (buf) => undefined, read(buf, v) {} }, // end\n  {\n    write: (buf) => buf.readByte(),\n    read(buf, v = 0) {\n      buf.writeByte(v)\n    },\n  }, // byte\n  {\n    write: (buf) => buf.readShort(),\n    read(buf, v = 0) {\n      buf.writeShort(v)\n    },\n  }, // short\n  {\n    write: (buf) => buf.readInt(),\n    read(buf, v = 0) {\n      buf.writeInt(v)\n    },\n  }, // int\n  {\n    write: (buf) => buf.readInt64(),\n    read(buf, v = 0) {\n      buf.writeInt64(v)\n    },\n  }, // long\n  {\n    write: (buf) => buf.readFloat(),\n    read(buf, v = 0) {\n      buf.writeFloat(v)\n    },\n  }, // float\n  {\n    write: (buf) => buf.readDouble(),\n    read(buf, v = 0) {\n      buf.writeDouble(v)\n    },\n  }, // double\n  {\n    // byte array\n    write(buf) {\n      const arr = new Array(buf.readInt())\n      for (let i = 0; i < arr.length; i++) {\n        arr[i] = buf.readByte()\n      }\n      return arr\n    },\n    read(buf, arr = []) {\n      buf.writeInt(arr.length)\n      for (let i = 0; i < arr.length; i++) {\n        buf.writeByte(arr[i])\n      }\n    },\n  },\n  {\n    write: (buf, context) => readUTF8(buf, context),\n    read: (buf, v = '', context) => writeUTF8(buf, v, context),\n  }, // string\n  {\n    // list\n    write(buf, context) {\n      const listType = buf.readByte()\n\n      assertTag(listType)\n\n      const len = buf.readInt()\n      const list = new Array(len)\n\n      if (context.schema) {\n        assertListSchema(context.schema)\n      }\n\n      if (!!context.schema && typeof context.schema === 'number' && listType !== context.schema) {\n        // ignore the value if we know the type mismatched\n        return list\n      }\n\n      const childContext = context.fork(context.schema ? context.schema[0] : listType)\n      const shouldInspectChildType = !childContext.schema\n\n      for (let i = 0; i < len; i++) {\n        // console.log(`[read] ${shouldInspectChildType ? 'inspecting' : ''} -> [${i}]: ${JSON.stringify(nextContext.valueType)} ${TagType.getName(listType)}`);\n        list[i] = coders[listType].write(buf, childContext)\n        // console.log(`[read] ${shouldInspectChildType ? 'inspecting' : ''} <- [${i}]: ${JSON.stringify(nextContext.valueType)} ${TagType.getName(listType)} ${JSON.stringify(list[i])}`);\n      }\n\n      if (shouldInspectChildType) {\n        context.inspect = childContext.inspect || [childContext.tagType]\n      }\n\n      return list\n    },\n    read(buf, value: any[] = [], context) {\n      assertListSchema(context.schema)\n\n      const valueType = context.schema[0]\n      const childContext = context.fork(valueType)\n      const tagType = childContext.tagType\n      const writer = coders[tagType]\n\n      assertTag(tagType)\n\n      if ((tagType === TagType.Compound || tagType === TagType.List) && !childContext.schema) {\n        // skip for undefined property\n        return\n      }\n\n      try {\n        buf.writeByte(tagType)\n        buf.writeInt(value.length)\n        for (const v of value) {\n          writer.read(buf, v, childContext)\n        }\n      } catch (e) {\n        if (e instanceof TypeError) {\n          throw new TypeError(`Require ${TagType.getName(tagType)} but found ${typeof value}`)\n        }\n      }\n    },\n  },\n  {\n    // tag compound\n    write(buf, context) {\n      assertCompoundSchema(context.schema)\n\n      const object = constructObject(context.schema) // create from constructor\n      const nbtPrototype = ensurePrototype(object as any)\n      const knowingType = !!context.schema\n\n      for (let tag = 0; (tag = buf.readByte()) !== TagType.End; ) {\n        const reader = coders[tag]\n\n        const key = readUTF8(buf, context)\n        // not reader or illegal tag type\n        assertTag(tag)\n\n        let childContext: ReadContext\n        if (knowingType) {\n          const valueType = nbtPrototype[key]\n          // Field is not in the schema, or its on-disk tag type does not match\n          // the schema's. We still must read and discard the value so the\n          // buffer cursor stays aligned for the following fields; simply\n          // `continue`-ing would desync the stream and corrupt the rest of the\n          // compound (e.g. newer `servers.dat` adds `preventsChatReports` /\n          // `hidden` bytes that older schemas don't know about).\n          if (\n            typeof valueType === 'undefined' ||\n            (typeof valueType === 'number' && valueType !== tag)\n          ) {\n            reader.write(buf, context.fork(tag))\n            continue\n          }\n          childContext = context.fork(valueType)\n        } else {\n          childContext = context.fork(tag)\n        }\n\n        const shouldInspectChildType = !childContext.schema\n        object[key] = reader.write(buf, childContext)\n        if (shouldInspectChildType) {\n          nbtPrototype[key] = childContext.inspect || childContext.tagType\n        }\n      }\n      if (!knowingType) {\n        context.inspect = nbtPrototype\n      }\n\n      return object\n    },\n    read(buf, object = {}, context) {\n      assertCompoundSchema(context.schema)\n\n      const schema =\n        (context.schema\n          ? context.schema instanceof Function\n            ? getPrototypeOf(context.schema)\n            : context.schema\n          : getPrototypeOf(object)) || ({} as CompoundSchema)\n\n      for (const [key, value] of Object.entries(object)) {\n        const valueType = schema[key]\n\n        if (typeof valueType === 'undefined') {\n          // skip for undefined property\n          continue\n        }\n\n        const childContext = context.fork(valueType)\n        const tagType = childContext.tagType\n        const writer = coders[tagType]\n\n        assertTag(tagType)\n\n        if (!childContext.schema && (tagType === TagType.Compound || tagType === TagType.List)) {\n          // skip for undefined property\n          continue\n        }\n        // console.log(`Write ${key}: ${TagType.getName(tagType)} ${JSON.stringify(childContext.schema)} ${childContext.schema} ${childContext.schema instanceof Array}`)\n        try {\n          buf.writeByte(tagType)\n          writeUTF8(buf, key, context)\n          writer.read(buf, value, childContext)\n        } catch (e) {\n          if (e instanceof TypeError) {\n            throw new TypeError(`Required ${TagType.getName(tagType)} but found ${typeof value}`)\n          }\n        }\n      }\n      buf.writeByte(TagType.End)\n    },\n  },\n  {\n    // int array\n    write(buf) {\n      const arr = new Array(buf.readInt())\n      for (let i = 0; i < arr.length; i++) {\n        arr[i] = buf.readInt()\n      }\n      return arr\n    },\n    read(buf, v = []) {\n      buf.writeInt(v.length)\n      for (let i = 0; i < v.length; i++) {\n        buf.writeInt(v[i])\n      }\n    },\n  },\n  {\n    // long array\n    write(buf) {\n      const len = buf.readInt()\n      const arr: bigint[] = new Array(len)\n      for (let i = 0; i < len; i++) {\n        arr[i] = buf.readInt64()\n      }\n      return arr\n    },\n    read(buf, v = []) {\n      buf.writeInt(v.length)\n      for (let i = 0; i < v.length; i++) {\n        buf.writeInt64(v[i])\n      }\n    },\n  },\n]\n\nexport interface SerializationOption {\n  compressed?: true | 'deflate' | 'gzip'\n  /**\n   * IO override for serialization\n   */\n  io?: { [tagType: number]: TagCoder }\n\n  /**\n   * Used for serialize function. Assign the filename for it.\n   */\n  filename?: string\n}\n\nexport interface DeserializationOption<T> {\n  compressed?: true | 'deflate' | 'gzip'\n  /**\n   * IO override for serialization\n   */\n  io?: { [tagType: number]: TagCoder }\n\n  type?: Constructor<T>\n}\n\n/**\n * Serialzie an nbt typed json object into NBT binary\n * @param object The json\n * @param compressed Should we compress it\n */\nexport async function serialize(\n  object: object,\n  option: SerializationOption = {},\n): Promise<Uint8Array> {\n  const buff = writeRootTag(\n    object,\n    undefined,\n    option.filename || '',\n    Object.assign({}, coders, option.io),\n  )\n  return normalizeBuffer(buff, option.compressed)\n}\n\n/**\n * Deserialize the nbt binary into json\n * @param fileData The nbt binary\n */\nexport async function deserialize<T>(\n  fileData: Uint8Array,\n  option: DeserializationOption<T> = {},\n): Promise<T> {\n  const doUnzip = normalizeCompress(fileData, option.compressed)\n  const bb = ByteBuffer.wrap(\n    doUnzip === 'none'\n      ? fileData\n      : doUnzip === 'gzip'\n        ? await ungzip(fileData)\n        : await inflate(fileData),\n  )\n\n  return readRootTag(bb, Object.assign({}, coders, option.io), option.type)\n}\n\n/**\n * Serialzie an nbt typed json object into NBT binary\n * @param object The json\n */\nexport function serializeSync(object: object, option: SerializationOption = {}): Uint8Array {\n  const buff = writeRootTag(\n    object,\n    undefined,\n    option.filename || '',\n    Object.assign({}, coders, option.io),\n  )\n  return normalizeBufferSync(buff, option.compressed)\n}\n\n/**\n * Deserialize the nbt binary into json\n * @param fileData The nbt binary\n * @param compressed Should we compress it\n */\nexport function deserializeSync<T>(fileData: Uint8Array, option: DeserializationOption<T> = {}): T {\n  const doUnzip = normalizeCompress(fileData, option.compressed)\n  const bb = ByteBuffer.wrap(\n    doUnzip === 'none'\n      ? fileData\n      : doUnzip === 'gzip'\n        ? gunzipSync(fileData)\n        : inflateSync(fileData),\n  )\n\n  return readRootTag(bb, Object.assign({}, coders, option.io), option.type)\n}\n\nfunction normalizeCompress(\n  fileData: Uint8Array,\n  compressed?: true | 'deflate' | 'gzip',\n): 'none' | 'gzip' | 'deflate' {\n  let doUnzip: 'none' | 'gzip' | 'deflate'\n  if (typeof compressed === 'undefined') {\n    doUnzip = 'none'\n  } else if (typeof compressed === 'boolean' && compressed) {\n    doUnzip = 'gzip'\n  } else {\n    doUnzip = compressed\n  }\n  return doUnzip\n}\n\nfunction normalizeBuffer(buff: Uint8Array, compressed?: true | 'deflate' | 'gzip') {\n  if (!compressed) {\n    return buff\n  }\n  if (compressed === 'deflate') {\n    return deflate(buff)\n  }\n  return gzip(buff)\n}\nfunction normalizeBufferSync(buff: Uint8Array, compressed?: true | 'deflate' | 'gzip') {\n  if (!compressed) {\n    return buff\n  }\n  if (compressed === 'deflate') {\n    return deflateSync(buff)\n  }\n  return gzipSync(buff)\n}\n\nfunction readRootTag(buffer: ByteBuffer, io: ArrayLike<TagCoder>, type?: Constructor<any>) {\n  const rootType = buffer.readByte()\n  if (rootType === TagType.End) {\n    throw new Error('NBTEnd')\n  }\n  if (rootType !== TagType.Compound) {\n    throw new Error('Root tag must be a named compound tag. ' + rootType)\n  }\n  const context = new ReadContext(type, TagType.Compound)\n  const name = readUTF8(buffer, context) // I think this is the nameProperty of the file...\n  const value = io[TagType.Compound].write(buffer, context)\n  return value\n}\n\nfunction writeRootTag(\n  value: any,\n  type: Schema | undefined,\n  filename: string,\n  coders: TagCoder[],\n): Uint8Array {\n  const buffer = new ByteBuffer()\n  buffer.writeByte(TagType.Compound)\n  const context = new WriteContext(type, 10)\n\n  writeUTF8(buffer, filename || '', context)\n  coders[TagType.Compound].read(buffer, value, context)\n\n  return new Uint8Array(buffer.flip().buffer.slice(0, buffer.limit))\n}\n\nfunction assertListSchema<T>(v: T | T[]): asserts v is T[] {\n  if (!(v instanceof Array)) {\n    throw new Error('IllegalState')\n  }\n}\nfunction assertCompoundSchema(v: Schema | undefined): asserts v is CompoundSchema | undefined {\n  if (v instanceof Array) {\n    throw new Error('IllegalState')\n  }\n}\nfunction assertTag(v: number): asserts v is TagType {\n  if (!isTagType(v)) {\n    throw new Error('Unknown type ' + v)\n  }\n}\n\nexport class ReadContext {\n  public inspect: Schema | undefined\n  #decoder: TextDecoder | undefined\n  constructor(\n    public schema: Schema | undefined,\n    public tagType: TagType,\n  ) {}\n\n  get decoder() {\n    if (!this.#decoder) {\n      this.#decoder = new TextDecoder()\n    }\n    return this.#decoder\n  }\n\n  fork(schemaOrTagType: TagType | Schema) {\n    if (typeof schemaOrTagType === 'number') {\n      return new ReadContext(undefined, schemaOrTagType)\n    }\n    return new ReadContext(\n      schemaOrTagType,\n      typeof schemaOrTagType === 'number'\n        ? schemaOrTagType\n        : schemaOrTagType instanceof Array\n          ? TagType.List\n          : TagType.Compound,\n    )\n  }\n}\n\nexport class WriteContext {\n  #encoder: TextEncoder | undefined\n  constructor(\n    readonly schema: Schema | undefined,\n    readonly tagType: TagType,\n  ) {}\n\n  get encoder() {\n    if (!this.#encoder) {\n      this.#encoder = new TextEncoder()\n    }\n    return this.#encoder\n  }\n\n  fork(schemaOrTagType: TagType | Schema): WriteContext {\n    if (schemaOrTagType === TagType.Compound) {\n      throw new Error('IllegalState')\n    }\n    return new WriteContext(\n      typeof schemaOrTagType === 'number' ? undefined : schemaOrTagType,\n      typeof schemaOrTagType === 'number'\n        ? schemaOrTagType\n        : schemaOrTagType instanceof Array\n          ? TagType.List\n          : TagType.Compound,\n    )\n  }\n}\n"],
  "mappings": ";AAwBO,IAAM,aAAN,MAAM,YAAW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOtB,OAAO,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQjB,OAAO,gBAAgB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQvB,OAAO,aAAa;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOpB,OAAO,mBAAmB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAO1B,OAAO,iBAA0B,YAAW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAO5C,OAAO,mBAAmB;AAAA;A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