node-serialport-bindings-cpp/lib/bindings.js
Francis Gulotta 6945217c0b Isolate the bindings (#755)
- Test requiring the library as part of the build processes on all platforms
 - move all js code into ./lib
 - move all the easy stuff into ./lib/bindings the rest will bring breaking changes probably
2016-04-15 23:54:58 -04:00

34 lines
784 B
JavaScript

'use strict';
var bindings = require('bindings')('serialport.node');
var listUnix = require('./list-unix');
var linux = process.platform !== 'win32' && process.platform !== 'darwin';
function listLinux(callback) {
callback = callback || function(err) {
if (err) { this.emit('error', err) }
}.bind(this);
return listUnix(callback);
};
var platformOptions = {};
if (process.platform !== 'win32') {
platformOptions = {
vmin: 1,
vtime: 0
};
}
module.exports = {
close: bindings.close,
drain: bindings.drain,
flush: bindings.flush,
list: linux ? listLinux : bindings.list,
open: bindings.open,
SerialportPoller: bindings.SerialportPoller,
set: bindings.set,
update: bindings.update,
write: bindings.write,
platformOptions: platformOptions
};