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

simple-barcode-scanner

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

simple-barcode-scanner

Utility to read barcode from devices emulating a fast keyboard

  • 2.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
388
increased by2.37%
Maintainers
1
Weekly downloads
 
Created
Source

Barcode Scanner

npm license gzip size

A simple JavaScript utility to read barcode from devices emulating a fast keyboard.

Table of Contents

Install

# Yarn
yarn add simple-barcode-scanner

# NPM
npm install --save simple-barcode-scanner

Then with a module bundler like rollup or webpack, use as you would anything else:

// using ES6 modules
import BarcodeScanner from "simple-barcode-scanner";

// using CommonJS modules
const BarcodeScanner = require("simple-barcode-scanner");

The UMD build is also available on unpkg:

<script src="https://unpkg.com/simple-barcode-scanner"></script>

You can find the library on window.BarcodeScanner.

Usage

import BarcodeScanner from "simple-barcode-scanner";

const scanner = BarcodeScanner();

// Add a listener
scanner.on((code, event) => {
  event.preventDefault();
  console.log(code);
});

// Remove the listener
scanner.off();

API

BarcodeScanner

Creates a simple function to listen to barcode scanners

Parameters

  • Options Object

    • latency Number Max time duration (in ms) between consecutive inputs

      default: 50

    • minLength Number Min length of a valid barcode

      default: 3

    • element HTMLElement The HTML element to attach the event listener to

      default: document

    • endKeys Array<string> Array of keys indicating end of barcode

      Refer Key Values | MDN

      default: ["Enter"]

    • validKey RegExp Regular expression to check for a valid key in barcode

      Refer Key Values | MDN

      default: /^\w$/

Returns Scanner

Scanner

  • on

    Starts listening for barcode scans and add/replace the listener

    Parameters

    • handler Function Function to call on completion of barcode scan

      Recieves the scanned code and the keyboard event of the last input as the parameters

  • off

    Stop listening for barcode scans and remove the listener

Contribute

First off, thanks for taking the time to contribute! Now, take a moment to be sure your contributions make sense to everyone else.

Development Start:

This project uses Typescript for development and yarn for dependency management.

Reporting Issues

Found a problem? Want a new feature? First of all see if your issue or idea has already been reported. If not, just open a new clear and descriptive issue.

Submitting pull requests

Pull requests are the greatest contributions, so be sure they are focused in scope, and do avoid unrelated commits.

  • Fork it!
  • Clone your fork: git clone https://github.com/<your-username>/simple-barcode-scanner
  • Navigate to the newly cloned directory: cd simple-barcode-scanner
  • Create a new branch for the new feature: git checkout -b my-new-feature
  • Install the tools necessary for development: yarn
  • Make your changes.
  • Commit your changes: git commit -am 'Add some feature'
  • Push to the branch: git push origin my-new-feature
  • Submit a pull request with full remarks documenting your changes.

Keywords

FAQs

Package last updated on 23 May 2019

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