1
0
Fork 0
BangleApps/apps/cards/EAN.js

45 lines
759 B
JavaScript
Raw Normal View History

const constants = require("cards.constants.js");
2024-04-08 19:40:53 +00:00
const encode = require("cards.encode.js");
2024-04-09 07:19:15 +00:00
const Barcode = require("cards.Barcode.js");
2024-04-08 19:40:53 +00:00
// Base class for EAN8 & EAN13
class EAN extends Barcode {
constructor(data, options) {
super(data, options);
}
leftText(from, to) {
return this.text.substr(from, to);
}
leftEncode(data, structure) {
return encode(data, structure);
}
rightText(from, to) {
return this.text.substr(from, to);
}
rightEncode(data, structure) {
return encode(data, structure);
}
2024-04-09 07:19:15 +00:00
encode() {
2024-04-08 19:40:53 +00:00
const data = [
constants.SIDE_BIN,
2024-04-08 19:40:53 +00:00
this.leftEncode(),
constants.MIDDLE_BIN,
2024-04-08 19:40:53 +00:00
this.rightEncode(),
constants.SIDE_BIN
2024-04-08 19:40:53 +00:00
];
return {
data: data.join(''),
text: this.text
};
}
}
module.exports = EAN;