Socket
Socket
Sign inDemoInstall

javascript-barcode-reader

Package Overview
Dependencies
86
Maintainers
1
Versions
51
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    javascript-barcode-reader

Barcode reader solution in Javascript for Browser and Node.js


Version published
Maintainers
1
Install size
15.9 MB
Created

Readme

Source

Javascript-Barcode-Reader

A Barcode scanner capapable of reading Code128 (UCC/EAN-128), Code93, Code39, Standard/Industrial 2 of 5, Interleaved 2 of 5, Codabar and EAN-13 barcodes in javascript for Node.js and Browsers.

Build Status
NPM

Demo

http://mubaidr.js.org/Javascript-Barcode-Reader/

Available decoders

  • EAN-13
  • EAN-8
  • Code 39
  • Code 93
  • Code 2 of 5 (Industrial & Interleaved)
  • Codabar
  • Code 128 (UCC/EAN-128)

Install

Recommended way to install is by using package manager (npm, yarn etc):

npm install javascript-barcode-reader

or use cdn:

<script src="//unpkg.com/javascript-barcode-reader/dist/javascript-barcode-reader.min.js"></script>

or download manually:

javascript-barcode-reader.js

How to use

Node.js

const javascriptBarcodeReader = require('javascript-barcode-reader')
Using promise
javascriptBarcodeReader(
  Image /* Image file Path || {data: pixelArray, width, height} || HTML5 Canvas ImageData */,
  {
    barcode: 'code-2of5',
    type: 'industrial', //optional type
  }
)
  .then(code => {
    console.log(code)
  })
  .catch(err => {
    console.log(err)
  })
Using await
try {
  const code = await javascriptBarcodeReader(
    Image /* Image file Path || {data: pixelArray, width, height} || HTML5 Canvas ImageData */,
    {
      barcode: 'code-2of5',
      type: 'industrial', //optional type
    }
  )
} catch (err) {
  console.log(err)
}

Browser

javascriptBarcodeReader will be available as global in Browsers.

Using promise

javascriptBarcodeReader(
  Image /* Image ID || HTML5 Image || HTML5 Canvas || HTML5 Canvas ImageData || Image URL */,
  {
    barcode: 'code-2of5',
    type: 'industrial', //optional type
  }
)
  .then(code => {
    console.log(code)
  })
  .catch(err => {
    console.log(err)
  })
Using await
try {
  const code = await javascriptBarcodeReader(
    Image /* Image ID || HTML5 Image || HTML5 Canvas || HTML5 Canvas ImageData || Image URL */,
    {
      barcode: 'code-2of5',
      type: 'industrial', //optional type
    }
  )
} catch (err) {
  console.log(err)
}

Tips

  • Make sure the barcode image is the only thing in the image. Otherwise this script will most probably fail.

Known Issues

This script does not implement logic to locate/rotate barcode in the given image.

Contributing

All the modules are contianed in src directory. If you implement a new module or update an existing one, then make sure to add/run tests by running:

npm test

Tests are defined in the __tests__ directory using Jest.

There is no need to run build script before creating pull request.

Licence

MIT License

Copyright (c) 2018 Muhammad Ubaid Raza

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Keywords

FAQs

Last updated on 28 Oct 2018

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc