posix-select

1.3.0 • Public • Published

Posix-Select

Posix style select(2) for when everything else fails and all hope is lost, an example of such an occurance is when you want to read data from a driver like tuntaposx, node-serialport will not work, as its not a serial port, fs.createReadStream etc also fail with IO Errors as the device is not immediately ready (BUG?).

As of now it exports a function that returns a Promise. You can call the function as

const select = require('posix-select');
const timeout = 1000; //1 second, this is passed in ms

select({
    read: [/* Get fds from somewhere */],
    write: [/* Get fds from somewhere */],
    errors: [/* Get fds from somwhere */]
}, timeout).then((readyTo) => {
    // Descriptor is ready to read, now call `fs.read`.
    console.log(readyTo.read);
});

In future we may implement a poller, although I want to research why fs.createReadStream / fs.createWriteStream fail.

Dependents (0)

Package Sidebar

Install

npm i posix-select

Weekly Downloads

2

Version

1.3.0

License

MIT

Last publish

Collaborators

  • darkyen00