Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/reconbot/uv-poll
https://github.com/reconbot/uv-poll
Last synced: 6 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/reconbot/uv-poll
- Owner: reconbot
- Created: 2017-07-09T03:20:12.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-07-09T16:27:07.000Z (over 7 years ago)
- Last Synced: 2024-10-10T22:41:09.300Z (about 1 month ago)
- Language: C++
- Size: 6.84 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# uv-poll
It's like UV_POLL_T but javascriptThis is ripped from [node serialport](https://github.com/EmergingTechnologyAdvisors/node-serialport) internals. It's an event emitter wrapper for [libuv's UV_POLL_T struct](http://docs.libuv.org/en/v1.x/poll.html).
The underlying event stream is continuous so instead of emitting all of them we ask for the next one. This can be done two ways.
- `poll.once(event, callback)` this automatically calls `poll()` for the correct event
- `poll.poll(eventInt)` asks `uv_poll_start` to poll for these additional events```js
const fd = fs.openSync('file')
const poll = new Poller(fd)
poll.once('readable', () => console.log(`fd ${fd} is now readable`))
poll.once('writable', () => console.log(`fd ${fd} is now writable`))
poll.once('disconnect', () => console.log(`fd ${fd} is now disconnect`)) // means not readable or writable
```This is tested pretty heavily in serialport. Happy to land any any improvements, tests, or fixes.