escpos-buffer
Advanced tools
Comparing version 1.5.0 to 1.6.0
@@ -59,2 +59,33 @@ import Model from '../../src/Model' | ||
}) | ||
it('cut paper partially from model VOX', () => { | ||
const connection = new InMemory() | ||
const printer = new Printer(new Model('VOX'), connection) | ||
printer.writeln('Cut below', 0, Align.Center) | ||
printer.cutter() | ||
expect(connection.buffer()).toStrictEqual(load('vox_cutter', connection.buffer())) | ||
}) | ||
it('write bold text from model VOX', () => { | ||
const connection = new InMemory() | ||
const printer = new Printer(new Model('VOX'), connection) | ||
printer.writeln('Bold text', Style.Bold, Align.Center) | ||
expect(connection.buffer()).toStrictEqual(load('vox_bold_text', connection.buffer())) | ||
}) | ||
it('write text with double width and height from model VOX', () => { | ||
const connection = new InMemory() | ||
const printer = new Printer(new Model('VOX'), connection) | ||
printer.writeln('Large Text', Style.DoubleWidth + Style.DoubleHeight, Align.Center) | ||
expect(connection.buffer()).toStrictEqual(load('vox_large_text', connection.buffer())) | ||
}) | ||
it('draw qrcode from model VOX', async () => { | ||
const connection = new InMemory() | ||
const printer = new Printer(new Model('VOX'), connection) | ||
printer.alignment = Align.Center | ||
await printer.qrcode('https://github.com/grandchef/escpos-buffer') | ||
printer.alignment = Align.Left | ||
expect(connection.buffer()).toStrictEqual(load('vox_qrcode', connection.buffer())) | ||
}) | ||
}) |
@@ -86,3 +86,3 @@ "use strict"; | ||
columns: 48, | ||
feed: 5, | ||
feed: 4, | ||
fonts: [ | ||
@@ -89,0 +89,0 @@ { |
@@ -59,3 +59,3 @@ "use strict"; | ||
static FIND(model) { | ||
let profile = capabilities_1.default.models.find((profile) => profile['model'] == model); | ||
const profile = capabilities_1.default.models.find((profile) => profile['model'] == model); | ||
if (!profile) { | ||
@@ -62,0 +62,0 @@ throw new Error(`Printer model "${model}" not supported`); |
@@ -8,5 +8,4 @@ "use strict"; | ||
cutter(mode) { | ||
if (mode == Printer_1.Cut.Full) { | ||
this.connection.write(Buffer.from('\x1Bw', 'ascii')); | ||
return; | ||
if (this.capabilities.model == 'I9') { | ||
return this.connection.write(Buffer.from('\x1DV0', 'ascii')); | ||
} | ||
@@ -16,3 +15,3 @@ super.cutter(mode); | ||
buzzer() { | ||
this.connection.write(Buffer.from('\x1B(A\x04\x00\x01\xFF\x00\xFF', 'ascii')); | ||
this.connection.write(Buffer.from('\x1B(A\x05\x00ad\x02\x02\x01', 'ascii')); | ||
} | ||
@@ -28,2 +27,5 @@ drawer(number, on_time, _) { | ||
setStyle(style, enable) { | ||
if (this.capabilities.model == 'I9') { | ||
return super.setStyle(style, enable); | ||
} | ||
if (enable) { | ||
@@ -44,2 +46,5 @@ if (Printer_1.Style.Bold == style) { | ||
setMode(mode, enable) { | ||
if (this.capabilities.model == 'I9') { | ||
return super.setMode(mode, enable); | ||
} | ||
if (enable) { | ||
@@ -63,3 +68,9 @@ if (mode & Printer_1.Style.DoubleWidth) { | ||
qrcode(data, size) { | ||
const _super = Object.create(null, { | ||
qrcode: { get: () => super.qrcode } | ||
}); | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
if (this.capabilities.model == 'I9') { | ||
return _super.qrcode.call(this, data, size); | ||
} | ||
const type = String.fromCharCode(2); | ||
@@ -66,0 +77,0 @@ const error = 'M'; |
@@ -9,4 +9,5 @@ const { Printer, Style, Align, Drawer, Model, InMemory } = require('../') | ||
printer.writeln('Bold Text -> complete line text.[]123456', Style.Bold) | ||
printer.writeln('Double height', Style.DoubleHeight | Style.Bold, Align.Center) | ||
printer.writeln('Áçênts R$ 5,00', Style.DoubleWidth | Style.DoubleWidth, Align.Center) | ||
printer.writeln('Double Height', Style.DoubleHeight | Style.Bold, Align.Center) | ||
printer.writeln('Double Width', Style.DoubleWidth, Align.Center) | ||
printer.writeln('Áçênts R$ 5,00', Style.DoubleWidth | Style.DoubleHeight, Align.Center) | ||
printer.feed(6) | ||
@@ -13,0 +14,0 @@ printer.buzzer() |
@@ -8,5 +8,5 @@ const { Printer, Style, Align, Drawer, Model, InMemory, Image } = require('../') | ||
const modelName = args[0] || 'MP-4200 TH' | ||
const capability = Model.EXPAND(modelName) | ||
const capability = Model.EXPAND(Model.FIND(modelName)) | ||
const model = new Model(modelName) | ||
const { feed } = capability | ||
const model = new Model(modelName) | ||
const connection = new InMemory() | ||
@@ -13,0 +13,0 @@ const printer = new Printer(model, connection) |
{ | ||
"name": "escpos-buffer", | ||
"version": "1.5.0", | ||
"version": "1.6.0", | ||
"description": "Library to generate buffer for thermal printers.", | ||
@@ -5,0 +5,0 @@ "author": "GrandChef Team <desenvolvimento@grandchef.com.br>", |
@@ -165,3 +165,3 @@ export type Font = { | ||
columns: 48, | ||
feed: 5, | ||
feed: 4, | ||
fonts: [ | ||
@@ -168,0 +168,0 @@ { |
@@ -64,3 +64,3 @@ import { Profile } from './profile'; | ||
static FIND(model: string): object { | ||
let profile = capabilities.models.find( | ||
const profile = capabilities.models.find( | ||
(profile: object) => profile['model'] == model, | ||
@@ -67,0 +67,0 @@ ); |
@@ -6,5 +6,4 @@ import Epson from './Epson'; | ||
cutter(mode: Cut): void { | ||
if (mode == Cut.Full) { | ||
this.connection.write(Buffer.from('\x1Bw', 'ascii')); | ||
return; | ||
if (this.capabilities.model == 'I9') { | ||
return this.connection.write(Buffer.from('\x1DV0', 'ascii')); | ||
} | ||
@@ -15,5 +14,3 @@ super.cutter(mode); | ||
buzzer(): void { | ||
this.connection.write( | ||
Buffer.from('\x1B(A\x04\x00\x01\xFF\x00\xFF', 'ascii'), | ||
); | ||
this.connection.write(Buffer.from('\x1B(A\x05\x00ad\x02\x02\x01', 'ascii')); | ||
} | ||
@@ -35,2 +32,5 @@ | ||
protected setStyle(style: Style, enable: boolean): void { | ||
if (this.capabilities.model == 'I9') { | ||
return super.setStyle(style, enable); | ||
} | ||
if (enable) { | ||
@@ -53,2 +53,5 @@ // enable styles | ||
protected setMode(mode: number, enable: boolean): void { | ||
if (this.capabilities.model == 'I9') { | ||
return super.setMode(mode, enable); | ||
} | ||
if (enable) { | ||
@@ -72,2 +75,5 @@ if (mode & Style.DoubleWidth) { | ||
async qrcode(data: string, size: number) { | ||
if (this.capabilities.model == 'I9') { | ||
return super.qrcode(data, size); | ||
} | ||
const type = String.fromCharCode(2); | ||
@@ -74,0 +80,0 @@ const error = 'M'; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
349543
186
4557