diff --git a/README.md b/README.md index 03d9309d..a415167b 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,6 @@ Supported barcodes: * EAN-2 * UPC (A) * [CODE39](https://github.com/lindell/JsBarcode/wiki/CODE39) -* [ITF](https://github.com/lindell/JsBarcode/wiki/ITF) * [ITF-14](https://github.com/lindell/JsBarcode/wiki/ITF-14) * [MSI](https://github.com/lindell/JsBarcode/wiki/MSI) * MSI10 diff --git a/src/barcodes/ITF/index.js b/src/barcodes/ITF/index.js deleted file mode 100644 index 25298171..00000000 --- a/src/barcodes/ITF/index.js +++ /dev/null @@ -1,58 +0,0 @@ -class ITF{ - constructor(string){ - this.string = string; - - this.binaryRepresentation = { - "0":"00110" - , "1":"10001" - , "2":"01001" - , "3":"11000" - , "4":"00101" - , "5":"10100" - , "6":"01100" - , "7":"00011" - , "8":"10010" - , "9":"01010" - }; - } - - valid(){ - return this.string.search(/^([0-9]{2})+$/) !== -1; - } - - encode(){ - // Always add the same start bits - var result = "1010"; - - // Calculate all the digit pairs - for(var i = 0; i < this.string.length; i += 2){ - result += this.calculatePair(this.string.substr(i, 2)); - } - - // Always add the same end bits - result += "11101"; - - return { - data: result, - text: this.string - }; - } - - // Calculate the data of a number pair - calculatePair(numberPair){ - var result = ""; - - var number1Struct = this.binaryRepresentation[numberPair[0]]; - var number2Struct = this.binaryRepresentation[numberPair[1]]; - - // Take every second bit and add to the result - for(var i = 0; i < 5; i++){ - result += (number1Struct[i] == "1") ? "111" : "1"; - result += (number2Struct[i] == "1") ? "000" : "0"; - } - - return result; - } -} - -export default ITF; diff --git a/src/barcodes/index.js b/src/barcodes/index.js index bdad03ab..8c8abdd4 100644 --- a/src/barcodes/index.js +++ b/src/barcodes/index.js @@ -2,7 +2,6 @@ import CODE39 from './CODE39/'; import {CODE128, CODE128A, CODE128B, CODE128C} from './CODE128/'; import {EAN13, EAN8, EAN5, EAN2, UPC} from './EAN_UPC/'; import ITF14 from './ITF14/'; -import ITF from './ITF/'; import {MSI, MSI10, MSI11, MSI1010, MSI1110} from './MSI/'; import pharmacode from './pharmacode/'; import GenericBarcode from './GenericBarcode/'; @@ -12,7 +11,6 @@ export default { CODE128, CODE128A, CODE128B, CODE128C, EAN13, EAN8, EAN5, EAN2, UPC, ITF14, - ITF, MSI, MSI10, MSI11, MSI1010, MSI1110, pharmacode, GenericBarcode diff --git a/test/browser/tests.js b/test/browser/tests.js index a91c69e4..986f4836 100644 --- a/test/browser/tests.js +++ b/test/browser/tests.js @@ -12,7 +12,6 @@ function createTests(newTest){ newTest("590123412345", {format: "EAN13", width: 3}); newTest("96385074", {format: "EAN8", width: 1}); newTest("9638507", {format: "EAN8", width: 1}); - newTest("12345678", {format: "ITF", width: 1}); newTest("98765432109213", {format: "ITF14", width: 1}); newTest("12345", {format: "pharmacode", width: 1}); newTest("133742", {format: "CODE128C", width: 1}); diff --git a/test/node/ITF.test.js b/test/node/ITF.test.js deleted file mode 100644 index 09b3268d..00000000 --- a/test/node/ITF.test.js +++ /dev/null @@ -1,29 +0,0 @@ -var assert = require('assert'); -var JsBarcode = require('../../bin/node/JsBarcode.js'); -var Canvas = require("canvas"); - - -describe('ITF', function() { - it('should be able to include the encoder(s)', function () { - ITF = JsBarcode.getModule("ITF"); - }); - - it('should be able to encode normal text', function () { - var enc = new ITF("123456"); - assert.equal("101011101000101011100011101110100010100011101000111000101011101" - , enc.encode().data); - }); - - it('should return getText correct', function () { - var enc = new ITF("123456"); - assert.equal("123456", enc.encode().text); - }); - - it('should warn with invalid text', function () { - var enc = new ITF("12345"); - assert.equal(false, enc.valid()); - - var enc = new ITF("1234AB"); - assert.equal(false, enc.valid()); - }); -});