New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

hid-barcode-scanner

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hid-barcode-scanner

A JavaScript library for using USB barcode scanners in NodeJS applications.

  • 1.0.6
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

npm

NodeJS USB-Barcode Scanner Library

A JavaScript library for using USB barcode scanners in NodeJS applications.js.

Version Information

  • 1.0.6 - Removed unnecessary console.logs
  • 1.0.5 - Introduced version checking.
  • 1.0.4 - Fixed bugs preventing the use of the getDevices function. This version also returns sting as all lowercase characters.

Intallation

You can install this package by running the following command:

npm i hid-barcode-scanner --save

Usage NodeJS

You can list all devices using the following code:

let getDevices = require('hid-barcode-scanner').getDevices;
console.log(getDevices());

Or search for a specific device using the following:

 let getDeviceByPath = require('./usb-barcode-scanner').getDeviceByPath;
 console.log(getDeviceByPath('/dev/hidraw0'));

let getDevicesByIds = require('./usb-barcode-scanner').getDevices;
console.log(getDevicesByIds(1529,8721));

Depending on the method used, a devices will show up as an array of objects or a single object in the following format:

 {
    vendorId: 1529,
    productId: 8721,
    path: '/dev/hidraw0',
    serialNumber: 'S/N E22A03870',
    manufacturer: 'Datalogic ADC, Inc.',
    product: 'Handheld Barcode Scanner',
    release: 131,
    interface: 0,
    usagePage: 1,
    usage: 6
  }

General usage is as follows:

 let UsbScanner = require('hid-barcode-scanner').UsbScanner;
 let scanner = new UsbScanner({
      vendorId: 1529,
      productId: 8721
 });
 scanner.events.on('data', (data) => {
      console.log(data);
 });
 scanner.events.on('error', (error) => {
      console.log(error);
 });
 scanner.startScanning();

To stop scanning, you can use:

scanner.stopScanning();

Keywords

FAQs

Package last updated on 20 Jun 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc