Giter Club home page Giter Club logo

bark-js's Introduction

Bark JS

npm version Travis Issues

Bark parses GS1-128 barcodes and extracts the catalogued data according to the GS1 General Specifications (PDF). It can also parse other SKU-related formats to convert into GTINs in GS1, such as EAN-13, ITF-14 and UPC-A.

How to use it

npm install bark-js

Examples

Let's pretend we scan the box in this photo.

const bark = require('bark-js')

bark( '015730033004265615171019' )
// returns:
{
  symbology: 'unknown',
  elements: [
    {
      ai: '01',
      title: 'GTIN',
      value: '57300330042656',
      raw: '57300330042656'
    },
    {
      ai: '15',
      title: 'BEST BEFORE or BEST BY',
      value: '2017-10-19',
      raw: '171019'
    }
  ],
  originalBarcode: '015730033004265615171019'
}

If you are going to scan simple barcodes (e.g. UPC-A, EAN-13, ITF-14, etc.) you can set the assumeGtin option to treat shorter barcodes (11-14 digits) as GS1-128 with a GTIN AI:

const bark = require('bark-js')

bark( '09002490100094', { assumeGtin: true } )
// returns:
{
  symbology: 'unknown',
  elements: [
    {
      ai: '01',
      title: 'GTIN',
      value: '09002490100094',
      raw: '09002490100094'
    }
  ],
  originalBarcode: '0109002490100094'
}

Depending on your barcode reader, you may receive FNC characters that arent the <GS> (ASCII 29) character. To set the group separator yourself, pass the fnc option:

const bark = require('bark-js')

bark( '10FRIDGEX0109002490100094', { fnc: 'X' } )
// returns:
{
  symbology: 'unknown',
  elements: [
    {
      ai: '10',
      title: 'BATCH/LOT',
      value: 'FRIDGE',
      raw: 'FRIDGEX'
    },
    {
      ai: '01',
      title: 'GTIN',
      value: '09002490100094',
      raw: '09002490100094'
    }
  ],
  originalBarcode: '10FRIDGEX0109002490100094'
}

Depending on the type of elements in your code, the parsers may append additional fields to such as isoCurrencyCode and amount for your convenience:

const bark = require('bark-js')

bark( '393297817999' )
// returns:
{
  symbology: 'unknown',
  elements: [
    {
      ai: '3932',
      title: 'PRICE',
      value: '978179.99',
      isoCurrencyCode: '978',
      amount: '179.99',
      raw: '97817999'
    }
  ],
  originalBarcode: '393297817999'
}

Contributing

Pull requests to Sleavely/Bark-JS are encouraged and appreciated!

bark-js's People

Contributors

dependabot[bot] avatar reialex1 avatar sleavely avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

bark-js's Issues

Error on parsing even the example

Hello,
I was trying your library to parse GS1 codes in a react-native project. But even running the example gives me the following error.
IMG_2007

Travis CI integration is broken

travis-ci.org migrated to travis-ci.com a while back, and it seems like the CI pipeline isn't running anymore. Perhaps it's time to switch out Travis in favor of CircleCI?

Parse Issue

I have two similar barcodes. One will scan correctly and the other will not:
Produces Error (Uncaught Error: Invalid AI at start of barcode: 197):
01108573260055401722081110A2021121092220084115197
Does Not Produce Error:
01108573260055401721102910A1905221042920115956137

GS1 Barcode not being decoded properly.

@Sleavely Lot Code, Qty was not decoded properly for this GS1 Value.

let b = BarkJs('020002160010536011190801374100001234638')
console.log(b)

Giving this Output.

[
{
"ai": "02",
"title": "CONTENT",
"value": "00021600105360",
"raw": "00021600105360"
},
{
"ai": "11",
"title": "PROD DATE",
"value": "2019-08-01",
"raw": "190801"
},
{
"ai": "37",
"title": "COUNT",
"value": "41000012",
"raw": "41000012"
},
{
"ai": "3463",
"title": "WIDTH (yd), log",
"value": "0.8",
"raw": "8"
}
]

Here is the Original barcode for your reference.

image

_this.fixedLength is not a function

Information :-

System:
OS: Windows 10 10.0.19042
CPU: (8) x64 Intel(R) Core(TM) i5-8265U CPU @ 1.60GHz
Memory: 559.27 MB / 7.82 GB
Binaries:
Node: 16.13.1 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.18 - ~\AppData\Roaming\npm\yarn.CMD
npm: 8.1.2 - C:\Program Files\nodejs\npm.CMD
Watchman: Not Found
SDKs:
Android SDK:
API Levels: 28, 30, 33
Build Tools: 30.0.2, 33.0.0
System Images: android-30 | Google APIs Intel x86 Atom
Android NDK: Not Found
Windows SDK: Not Found
IDEs:
Android Studio: Not Found
Visual Studio: Not Found
Languages:
Java: Not Found
npmPackages:
@react-native-community/cli: Not Found
react: 17.0.2 => 17.0.2
react-native: 0.66.4 => 0.66.4
react-native-windows: Not Found
npmGlobalPackages:
react-native: Not Found

I got this error when i tried to parse value of gs128 type barcode which is having expiry date
here is the barcode which i tried to parse
image

here is the error which i am getting
image

Please help me thank you

npm install is incorect

Hello, I was testing your package but please change the help because the correct way to install your package is:

npm install bark-js and not npm install bark

Regards.

Unable to parse a barcode that contains a date

Since I updated to the latest version, the decoding fails as soon as their is a date AI in the barcode.

Tested with AI 11 and 17, same behavior.

After investigation, this is linked to the changes made in d01ae5a

It looks like this is undefined, so I would suggest to go back with exports.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.