assertNatNumber = n => {
  if (Number.isSafeInteger(n) && /** @type {number} */ (n) >= 0) {
    return;
  }
  throw TypeError(`must be a non-negative integer, got ${n}`);
}
@typedef {{
  length: number,
  index: number,
  bytes: Uint8Array,
  data: DataView,
  capacity: number,
}} BufferWriterState