/* options: {vendorId:Int, hidMap: Obj} defaults: {vendorId:1534, hidMap:{30: '1', 31: '2', 32: '3', 33: '4',34: '5',35: '6', 36: '7', 37: '8', 38: '9',39: '0',40: 'e'}} */ function usbScanner(options) { var opts = options || {}; this.init(opts); EventEmitter.call(this); }
function DBus (runtime) { EventEmitter.call(this) this.runtime = runtime this.component = runtime.component }
/** * SerialPort device * @param {[type]} port * @param {[type]} options */ function Serial(port, options){ var self = this; options = options || { baudRate: 9600, autoOpen: false }; const SerialPort = require('serialport'); this.device = new SerialPort(port, options); this.device.on('close', function() { self.emit('disconnect', self.device); self.device = null; }); EventEmitter.call(this); return this; }
function MyEventEmitter() { EventEmitter.call(this); doFirstJob(); setImmediate(() => this.emit('myEvent')); }
function Socket (options) { EventEmitter.call(this) options = options || { network: 0 } var wsUrl = Socket.wsUrlForNetwork(options.network) var socket = new WebSocket(wsUrl) this.close = socket.close.bind(socket) this.getReadyState = function () { return socket.readyState } this.op = function (op, data) { var message = JSON.stringify(extend({ op: op }, data || {})) var send = socket.send.bind(socket, message) if (socket.readyState === WebSocket.CONNECTING) socket.on('open', send) else if (socket.readyState === WebSocket.OPEN) send() } socket.on('message', function (message) { message = JSON.parse(message) this.emit(message.op, message.x) }.bind(this)) socket.on('open', this.emit.bind(this, 'open')) socket.on('close', this.emit.bind(this, 'close')) socket.on('error', this.emit.bind(this, 'error')) }
on(eventName, listener) { // if the instance has an error handler set then we don't need to // skips error logging if (eventName.toLowerCase() === 'error') { this.errorListenerSet = true; } super.on.call(this, eventName, listener); }
/** * Mock for SerialPort */ var SerialPortMock = function(path, options, callback) { EventEmitter.call(this); this._openFlag = false; if (callback) { callback(null); } Object.defineProperty(this, "isOpen", { enumerable: true, get: function() { return this._openFlag; } }); }
/** * Class making ModbusRTU calls fun and easy. * * @param {SerialPort} port the serial port to use. */ var ModbusRTU = function(port) { // the serial port to use this._port = port; // state variables this._transactions = {}; this._timeout = null; // timeout in msec before unanswered request throws timeout error this._unitID = 1; // Flag to indicate whether debug mode (pass-through of raw // request/response) is enabled. this._debugEnabled = false; this._onReceive = _onReceive.bind(this); EventEmitter.call(this); }
// Creates a new HttpFetcher - maxParallel is handled by the browser, so we'll ignore it function HttpFetcher(accept, customHeaders) { EventEmitter.call(this); this._accept = accept || 'application/ld+json;q=1.0'; this._customHeaders = customHeaders || {}; }
EventEmitter.call(this);
var Socket = function() { EventEmitter.call(this); this.destroyed = false; }
var Socket = function() { EventEmitter.call(this); }
function SocketIO(){ //we are mocking the socketio service EventEmitter.call(this); }
var Server = function() { EventEmitter.call(this); }
function Emitter() { EventEmitter.call(this) }