npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

barcode-parser

v2.3.0

Published

This project started out as a Typescript port of the Quagga project - https://serratus.github.io/quaggaJS. - but that direction has diverged greatly. This library does not read barcodes but rather parses the value returned by a dedicated barcode scanner.

Downloads

503

Readme

Coverage Status Lint Test and Release semantic-release Commitizen friendly Total alerts Language grade: JavaScript

Barcode-Parsing

this package has a fairly narrow scope and is used in conjunction with an Ionic project to read values provided by a physical wedge scanner and parse out the values. I am working on wrapping up the scanning angular component that consumes this directly.

Usage

    const barcodeParser = new BarcodeParser({
        readers: [
            Symbologies.Code39,
            Symbologies.ITF8,
            ...Symbologies.GTINX // This spreads to support all GTIN lengths 8-14
        ],
        readerConfigurations: [
            {
              symbology: Symbologies.Code39,
              values: [
                {
                  length: 2,
                  start: 0,
                  valueType: 'foo'
                },
                {
                  length: 3,
                  start: 2,
                  valueType: 'bar'
                }
              ]
            }
        ]
    });



    const itfResult = barcodeParser.parse(']I010734074010258');
    // {
    //   symbology: 'itf_14',
    //   rawValue: ']I010734074010258',
    //   checkDigit: 8,
    //   success: true,
    //   values: '1073407401025'
    // }

    // the below input with spaces would never be valid from a scanner, the spaces would instead be an invisible [group seperator](http://www.theasciicode.com.ar/ascii-control-characters/group-separator-ascii-code-29.html). This library replaces the GS character with a space before parsing so it works for both illustrative purposes and testing. 
    const code128Result = barcodeParser.parse(']C100111111111111111111101234 30100 310600100');
    code128Result.pluck(AICode.BatchLot) // '1234'
    code128Result.pluck(AICode.SerialShippingContainerCode) // '111111111111111111'
    code128Result.pluck(AICode.CountOfItems) // '100'
    code128Result.pluck(AICode.ProductNetWeightKg) // .0001

    // {
    //   symbology: 'gs1_128',
    //   rawValue: ']C100111111111111111111101234 30100 310600100',
    //   checkDigit: -1,
    //   success: true,
    //   values: [
    //     {
    //       code: '10',
    //       value: '1234'
    //     },
    //     {
    //       code: '00',
    //       value: '111111111111111111'
    //     },
    //     {
    //       code: '30',
    //       value: '100'
    //     },
    //     {
    //       'code': '310',
    //       'value': 0.0001
    //     }
    //   ]
    // }  

    const code39Result = barcodeParser.parse(']A01234567777777');
    code39Result.success // true
    code39Result.errorMessage // undefined
    code39Result.pluck('foo') // '12'
    code39Result.pluck('bar') // '345'
    code39Result.pluck('bizz') // undefined
    {
      symbology: 'code_39',
      rawValue: ']A01234567777777',
      checkDigit: -1,
      success: true,
      values: [
        {
          code: 'foo',
          value: '12'
        },
        {
          code: 'bar',
          value: '345'
        }
      ]
    }

    const invalidInputResult = barcodeParser.parse(']Z00000000');
    invalidInputResult.success // false
    invalidInputResult.errorMessage // 'No Reader Found'
    // {
    //   symbology: null,
    //   rawValue: ']Z00000000',
    //   checkDigit: -1,
    //   success: false,
    //   values: [],
    //   errorMessage: 'No Reader Found'
    // }