How to use the bindings.Poller function in bindings

To help you get started, we’ve selected a few bindings examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github serialport / node-serialport / packages / bindings / lib / poller.js View on Github external
const debug = require('debug')
const logger = debug('serialport/bindings/poller')
const EventEmitter = require('events')
const PollerBindings = require('bindings')('bindings.node').Poller

const EVENTS = {
  UV_READABLE: 0b0001,
  UV_WRITABLE: 0b0010,
  UV_DISCONNECT: 0b0100,
}

function handleEvent(error, eventFlag) {
  if (error) {
    logger('error', error)
    this.emit('readable', error)
    this.emit('writable', error)
    this.emit('disconnect', error)
    return
  }
  if (eventFlag & EVENTS.UV_READABLE) {
github rdmtc / RedMatic / prebuilt / armv6l / lib / node_modules / node-red-contrib-johnny-five / node_modules / @serialport / bindings / lib / poller.js View on Github external
const debug = require('debug')
const logger = debug('serialport/bindings/poller')
const EventEmitter = require('events')
const FDPoller = require('bindings')('bindings.node').Poller

const EVENTS = {
  UV_READABLE: 1,
  UV_WRITABLE: 2,
  UV_DISCONNECT: 4,
}

function handleEvent(error, eventFlag) {
  if (error) {
    logger('error', error)
    this.emit('readable', error)
    this.emit('writable', error)
    this.emit('disconnect', error)
    return
  }
  if (eventFlag & EVENTS.UV_READABLE) {