# async-ioctl

> Asynchronous `ioctl` for Node.js. Used for [`node-nbd-client`](https://github.com/fathyb/node-nbd-client), UNIX-only.

Latest version **1.0.6** (published 2022-10-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install async-ioctl
pnpm add async-ioctl
yarn add async-ioctl
bun add async-ioctl
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.6 |
| Published | 2022-10-22 |
| First published | 2022-10-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 40.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | yes |
| Maintainers | fathyb |

## Links

- npm: https://www.npmjs.com/package/async-ioctl
- npm.io page: https://npm.io/package/async-ioctl

## Dependencies (2)

- [nan](https://npm.io/package/nan.md) ^2.17.0
- [node-gyp](https://npm.io/package/node-gyp.md) ^9.3.0

## Recent versions

- 1.0.6 (latest) — 2022-10-22
- 1.0.6-next.2 — 2022-10-22
- 1.0.6-next.1 — 2022-10-22
- 1.0.5 — 2022-10-22
- 1.0.5-next.2 — 2022-10-22
- 1.0.5-next.1 — 2022-10-22
- 1.0.4 — 2022-10-21
- 1.0.4-next.1 — 2022-10-21
- 1.0.3 — 2022-10-21
- 1.0.2 — 2022-10-20
- 1.0.2-next.4 — 2022-10-20
- 1.0.2-next.3 — 2022-10-20
- 1.0.2-next.2 — 2022-10-20
- 1.0.2-next.1 — 2022-10-20
- 1.0.1 — 2022-10-20
- … 8 more at https://npm.io/package/async-ioctl/versions

## README

# node-async-ioctl

Asynchronous `ioctl` for Node.js. Used for [`node-nbd-client`](https://github.com/fathyb/node-nbd-client), UNIX-only.

## Usage

-   `ioctl(fd: number | bigint, request: number | bigint, value: number | bigint | Buffer): Promise<number>`
    -   meant for `ioctl` calls returning immediately. Uses the libuv thread pool.
-   `ioctl.batch(batch: [fd: number | bigint, request: number | bigint, value: number | bigint | Buffer][]): Promise<number[]>`
    -   same as `ioctl(fd, request, value)` except requests can be submitted in batches.
-   `ioctl.blocking(fd: number | bigint, request: number | bigint, value: number | bigint | Buffer): Promise<number>`
    -   meant for `ioctl` calls blocking until something happens. Uses a dedicated thread so more memory and higher latency.

```js
import { open } from 'fs'
import { ioctl } from 'async-ioctl'

// Get number of rows for current terminal
const rows = await ioctl(process.stdout.fd, 0x2000ab00)

async function getBlockDeviceSize(path: string) {
    const device = await open(path)
    const buffer = Buffer.alloc(8)

    await ioctl(device.fd, 0x2000ab00, buffer)

    return buffer
}

// Buffer argument
const result = await ioctl(device.fd, 0x2000ab00, Buffer.from('test'))
// Buffer argument
const result = await ioctl(device.fd, 0x2000ab00, BigInt('13343554'))
```

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