reyiyo / virtual-serialport

A drop-in virtual replacement for node-serialport's SerialPort object
37 stars 13 forks source link

virtual-serialport shouldn't have synchronous emitters #3

Closed qdot closed 8 years ago

qdot commented 8 years ago

I was trying to use the virtual-serialport package to mock some code that worked fine with node-serialport and actual hardware. However, virtual-serialport makes synchronous emit() calls, meaning that instead of being able to assign callbacks/event handlers after open/write/etc, callbacks execute during the call (.write() calls emit("data") which calls all callbacks right then). Emits should be wrapped in something like setImmediate in order to simulate expected usage.