https://github.com/sleavely/bark-js
🔬 Parse barcode inputs 🏷️ in a unified GS1-128 format 📦🌐
https://github.com/sleavely/bark-js
barcode barcode-inputs barcodes gs1 npm
Last synced: 7 days ago
JSON representation
🔬 Parse barcode inputs 🏷️ in a unified GS1-128 format 📦🌐
- Host: GitHub
- URL: https://github.com/sleavely/bark-js
- Owner: Sleavely
- License: other
- Created: 2016-03-23T12:32:39.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2023-03-03T11:25:53.000Z (about 2 years ago)
- Last Synced: 2025-04-08T14:41:24.552Z (about 1 month ago)
- Topics: barcode, barcode-inputs, barcodes, gs1, npm
- Language: JavaScript
- Homepage:
- Size: 343 KB
- Stars: 30
- Watchers: 6
- Forks: 8
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Bark JS
[  ](https://npmjs.org/package/bark-js "View this project on npm") [  ](https://travis-ci.org/Sleavely/Bark-JS) [  ](https://github.com/Sleavely/Bark-JS/issues)
Bark parses GS1-128 barcodes and extracts the catalogued data according to the [GS1 General Specifications (PDF)](https://www.gs1.org/sites/default/files/docs/barcodes/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](https://goo.gl/photos/HCE7WrNHDKvQL5ei8).
```javascript
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:
```javascript
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 `` (ASCII 29) character. To set the group separator yourself, pass the `fnc` option:
```javascript
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:
```javascript
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!