node-serialport-bindings-cpp/lib/util.js
Francis Gulotta 414057c4dc Promised based bindings.
- Base bindings class to extend
- Move docs to base binding
- Make all bindings classes
- Ditch push bindings because it doesn't make anything cleaner
2017-01-10 23:02:51 -05:00

20 lines
374 B
JavaScript

'use strict';
function promisify(func) {
return function() {
return new Promise((resolve, reject) => {
const args = Array.prototype.slice.apply(arguments);
args.push((err, data) => {
if (err) {
return reject(err);
}
resolve(data);
});
func.apply(null, args);
});
};
}
module.exports = {
promisify
};