INNER CODE UNIT · TypeScript

newSpace

mongodb/js-bson · src/binary.ts:198

      const newSpace = ByteUtils.allocate(this.buffer.byteLength + sequence.length);
      newSpace.set(this.buffer, 0);

      // Assign the new buffer
      this.buffer = newSpace;
    }

    if (ArrayBuffer.isView(sequence)) {
      this.buffer.set(ByteUtils.toLocalBufferType(sequence), offset);
      this.position =
        offset + sequence.byteLength > this.position ? offset + sequence.length : this.position;
    } else if (typeof sequence === 'string') {
      throw new BSONError('input cannot be string');
    }
  }

  /**
   * Returns a view of **length** bytes starting at **position**.

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…