2024-04-09 07:19:15 +00:00
|
|
|
import { SIDE_BIN, MIDDLE_BIN } from './constants';
|
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 = [
|
|
|
|
SIDE_BIN,
|
|
|
|
this.leftEncode(),
|
|
|
|
MIDDLE_BIN,
|
|
|
|
this.rightEncode(),
|
|
|
|
SIDE_BIN
|
|
|
|
];
|
|
|
|
|
|
|
|
return {
|
|
|
|
data: data.join(''),
|
|
|
|
text: this.text
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = EAN;
|