Security News
OpenJS: “XZ Utils Cyberattack Likely Not an Isolated Incident”
OpenJS is warning of social engineering takeovers targeting open source projects after receiving a credible attempt on the foundation.
barcode-parser
Advanced tools
Weekly downloads
Readme
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.
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'
// }
FAQs
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.
The npm package barcode-parser receives a total of 154 weekly downloads. As such, barcode-parser popularity was classified as not popular.
We found that barcode-parser demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.
Security News
OpenJS is warning of social engineering takeovers targeting open source projects after receiving a credible attempt on the foundation.
Company News
Come meet the Socket team at BSidesSF and RSA! We're sponsoring several fun networking events and we would love to see you there.
Security News
OSI is starting a conversation aimed at removing the excuse of the SaaS loophole for companies navigating licensing and the complexities of doing business with open source.