# roaringBitset

> **roaringBitset**(`options?`): [`Bitset`](/reference/knotkit/bitset/interfaces/bitset/)

Defined in: [packages/bitset/src/roaring-bitset.ts:25](https://github.com/jkomyno/knotkit/blob/ef04dc6fd5182dca281abddf3e1dcb13118c15a4/packages/bitset/src/roaring-bitset.ts#L25)

A bitset of unsigned 32-bit ids over 65,536-id chunks, each a sorted id array or an 8 KB bitmap.

This is the recommended layout: memory follows the ids actually stored, so a caller that does not yet know how far its ids range does not pay for the span. Chunked containers also make `isDisjointFrom` and `intersectionSize` stop at the first chunk that decides them.

## Parameters

### options?

[`BitsetOptions`](/reference/knotkit/bitset/interfaces/bitsetoptions/)

Optional `items`, added as if by `add`.

## Returns

[`Bitset`](/reference/knotkit/bitset/interfaces/bitset/)

## Throws

With code `INVALID_ID` when an item is not in `0 … BITSET_MAX_ID`.

## Example

```ts
const seen = roaringBitset({ items: [3, 65_536] })
seen.has(3) // true
seen.size // 2
```
