Function ensureBufferAligned

  • Ensures that the given buffer is aligned to the given alignment. If alignment is not specified, the default alignment of 32 is used. If the buffer is already aligned, it is returned. If the buffer is not aligned, a new aligned buffer is created with bufferAlignedAllocUnsafe or bufferAlignedAllocShared and the data is copied.

    Parameters

    • buffer:
          | ArrayBuffer
          | SharedArrayBuffer
          | Int8Array
          | Uint8Array
          | Uint8ClampedArray
          | Buffer

      The buffer to align.

    • Optionalalignment: number

      The alignment to align to.

    Returns Buffer

    The aligned buffer. Can be the same as the input buffer if it was already aligned. Can be a new buffer if the input buffer was not aligned.

    RoaringBitmap32