How to use the serialport/package.json.version function in serialport

To help you get started, we’ve selected a few serialport examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Apollon77 / smartmeter-obis / test / patch-virtual-serialport / index.js View on Github external
function VirtualSerialPortFactory() {
    try {
        var SerialPort = require('serialport');
        var serialportPackage = require('serialport/package.json');
        var semver = require('semver');

        // for v2.x serialport API
        if(semver.satisfies(serialportPackage.version, '<3.X')) {
            this.SerialPort = VirtualSerialPort;
            this.parsers = SerialPort.parsers;
            return this;
        }

        VirtualSerialPort.parsers = SerialPort.parsers;
        return VirtualSerialPort;
    } catch (error) {
        console.warn('VirtualSerialPort - NO parsers available');
    }

    return VirtualSerialPort;
}

serialport

Node.js package to access serial ports. Linux, OSX and Windows. Welcome your robotic JavaScript overlords. Better yet, program them!

MIT
Latest version published 1 year ago

Package Health Score

81 / 100
Full package analysis