UNPKG

@stacksjs/qrx

Version:

QR & Bar Code generating & reading. Lightweight & powerful.

17 lines (15 loc) 408 B
export declare class EAN2 extends Barcode { constructor(data: string, options: any) { super(data, options) } valid(): boolean { return this.data.search(/^\d{2}$/) !== -1 } encode(): { text: string, data: string } { const structure = EAN2_STRUCTURE[Number.parseInt(this.data) % 4] return { data: `1011${encode(this.data, structure, '01')}`, text: this.text, } } }