Skip to content

Commit

Permalink
2.0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
thalassa-web committed Jan 18, 2019
1 parent 3ef0d8b commit c309e60
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "physical-barcode-reader-observer",
"version": "2.0.4",
"version": "2.0.5",
"description": "Library which observe keyboard input events to listen HID barcode reader events",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/barcode-type-detector.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {BarcodeTypeDetector} from '../barcode-type-detector';
import { BarcodeTypeDetector } from '../barcode-type-detector';
import { BarcodeType } from '../enums';

test('EAN_13 Validation', () => {
Expand Down
14 changes: 7 additions & 7 deletions src/barcode-type-detector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ const isOnlyDigits = (value: string, length: number): boolean => onlyDigitsRegex
*/
const getEanControlKey = (value: string): number => {
const sumCtrl = value
.slice(0, value.length - 1)
.split('')
// Chars are only digits
.map(digit => parseInt(digit, 10))
// Each even char column index is multiply by 3
// And we make the sum
.reduce((acc, digit, index) => acc + ((index % 2) ? digit : (digit * 3)), 0);
.slice(0, value.length - 1)
.split('')
// Chars are only digits
.map(digit => parseInt(digit, 10))
// Each even char column index is multiply by 3
// And we make the sum
.reduce((acc, digit, index) => acc + (index % 2 ? digit : digit * 3), 0);
return 10 - (sumCtrl % 10);
};
/**
Expand Down

0 comments on commit c309e60

Please sign in to comment.