1.0.6 • Published 2 years ago

async-ioctl v1.0.6

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

node-async-ioctl

Asynchronous ioctl for Node.js. Used for 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.
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'))
1.0.6

2 years ago

1.0.6-next.2

2 years ago

1.0.6-next.1

2 years ago

1.0.5

2 years ago

1.0.5-next.2

2 years ago

1.0.5-next.1

2 years ago

1.0.4

2 years ago

1.0.4-next.1

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.2-next.4

2 years ago

1.0.2-next.3

2 years ago

1.0.2-next.2

2 years ago

1.0.2-next.1

2 years ago

1.0.1

2 years ago

1.0.1-next.6

2 years ago

1.0.1-next.5

2 years ago

1.0.1-next.4

2 years ago

1.0.1-next.3

2 years ago

1.0.1-next.2

2 years ago

1.0.1-next.1

2 years ago

1.0.1-next.0

2 years ago

1.0.0

2 years ago