diff --git a/serialport.js b/serialport.js index c03613e..ff63ed5 100644 --- a/serialport.js +++ b/serialport.js @@ -77,7 +77,8 @@ function SerialPortFactory() { callback = null; } - options = options || {}; + options = (typeof options !== 'function') && options || {}; + openImmediately = (openImmediately === undefined || openImmediately === null) ? true : openImmediately; stream.Stream.call(this); diff --git a/test/serialport-basic.js b/test/serialport-basic.js index cfbfca3..77712fd 100644 --- a/test/serialport-basic.js +++ b/test/serialport-basic.js @@ -50,6 +50,13 @@ describe('SerialPort', function () { var port = new SerialPort('/dev/exists', { databits : 19 }, false, errorCallback); }); + it('allows optional options', function (done) { + var cb = function () {}; + var port = new SerialPort('/dev/exists', cb); + expect(typeof port.options).to.eq('object'); + done(); + }); + }); describe('reading data', function () {