usb-barcode-scanner
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

Typed usb-barcode scanner

A typed library for using USB barcode scanners in Node.js with support for Typescript.

On Linux and Mac, you have to run your application with root privileges.

Intallation

You can install this package by running the following command:

npm i usb-barcode-scanner --save

Or using yarn:

yarn add usb-barcode-scanner

Usage Typescript

You can list all devices using the following code:

import { getDevices } from 'usb-barcode-scanner';
 
console.log(getDevices());
import { UsbScanner } from 'usb-barcode-scanner';
 
let scanner = new UsbScanner({
    vendorId: 1155,
    productId: 22352
    /** You could also initialize the scanner by giving entering the path variable:
     *  path: 'IOService:/AppleACPI etc...'
    **/  
});
 
scanner.on('data', (data) => {
    console.log(data);
});
 
scanner.startScanning();

To stop scanning, you can use:

scanner.stopScanning();

Usage Vanilla JS

You can list all devices using the following code:

let getDevices = require('usb-barcode-scanner').getDevices;
 
console.log(getDevices());
let UsbScanner = require('usb-barcode-scanner').UsbScanner;
 
let scanner = new UsbScanner({
    vendorId: 1155,
    productId: 22352
});
 
scanner.on('data', (data) => {
    console.log(data);
});
 
scanner.startScanning();

To stop scanning, you can use:

scanner.stopScanning();

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.2
    6
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.2
    6
  • 1.0.1
    0
  • 1.0.0
    0

Package Sidebar

Install

npm i usb-barcode-scanner

Weekly Downloads

6

Version

1.0.2

License

MIT

Unpacked Size

37.1 kB

Total Files

17

Last publish

Collaborators

  • mikerovers