# quickbit-native

> libquickbit JavaScript bindings for Node.js

Latest version **2.4.8** (published 2025-08-21) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install quickbit-native
pnpm add quickbit-native
yarn add quickbit-native
bun add quickbit-native
```

## Health

**Score 35/100 (D)** — status: stable.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: stale.

## Facts

| | |
|---|---|
| Version | 2.4.8 |
| Published | 2025-08-21 |
| First published | 2022-09-05 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 1.9 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Holepunch |
| Maintainers | mafintosh, kasperisager |

## Links

- npm: https://www.npmjs.com/package/quickbit-native
- Repository: https://github.com/holepunchto/quickbit-native
- Homepage: https://github.com/holepunchto/quickbit-native#readme
- Issues: https://github.com/holepunchto/quickbit-native/issues
- npm.io page: https://npm.io/package/quickbit-native

## Dependencies (1)

- [require-addon](https://npm.io/package/require-addon.md) ^1.1.0

## Recent versions

- 2.4.8 (latest) — 2025-08-21
- 2.4.7 — 2025-08-21
- 2.4.6 — 2025-05-23
- 2.4.5 — 2025-05-13
- 2.4.4 — 2025-05-05
- 2.4.3 — 2025-05-05
- 2.4.2 — 2025-04-23
- 2.4.1 — 2025-04-23
- 2.4.0 — 2025-04-22
- 2.3.6 — 2025-02-20
- 2.3.5 — 2025-02-11
- 2.3.4 — 2024-11-13
- 2.3.3 — 2024-10-22
- 2.3.2 — 2024-10-01
- 2.3.1 — 2024-09-13
- … 31 more at https://npm.io/package/quickbit-native/versions

## README

# quickbit-native

https://github.com/holepunchto/libquickbit JavaScript bindings for Node.js.

```sh
npm install quickbit-native
```

## Usage

```js
const { get, set, findFirst } = require('quickbit-native')

const field = Buffer.alloc(256) // 2048 bits

const changed = set(field, 1000)
// true

get(field, 1000)
// true

findFirst(field, true)
// 1000
```

## API

#### `const b = get(field, bit)`

Get the given bit, which will either be `true` (set) or `false` (unset).

#### `const changed = set(field, bit[, value])`

Set the given bit to `value`, which defaults to `true`. Returns `true` if the bit changed, otherwise `false`.

#### `field = fill(field, value[, start[, end]])`

Fill the given bit range with `value`. `start` defaults to `0` and `end` defaults to the bit length of the field. Returns the modified field.

#### `clear(field, chunk)`

Clear the bits from `field` that are set in the `{ field, offset }` chunk.

#### `const i = findFirst(field, value[, position])`

Return the index of the first occurrence of `value`, or `-1` if not found. If `position` is given, return the first index that is greater than or equal to `position`.

#### `const i = findLast(field, value[, position])`

Return the index of the last occurrence of `value`, or `-1` if not found. If `position` is given, return the last index that is less than or equal to `position`.

### Indexing

#### `const index = Index.from(fieldOrChunks)`

Construct an index of the bits in a bit field or an array of sparse `{ field, offset }` chunks.

#### `const changed = index.update(bit)`

Update the given bit in the index.

#### `const position = index.skipFirst(value[, position])`

Skip the first parts of the index that contain nothing but `value`. If the index contains _only_ `value`, the last index of the field is returned.

#### `const position = index.skipLast(value[, position])`

Skip the last parts of the index that contain nothing but `value`. If the index contains _only_ `value`, the first index of the field is returned.

## License

Apache-2.0

---
_Source: https://npm.io/package/quickbit-native · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
