escpos-buffer
Advanced tools
Comparing version 4.0.2 to 4.0.3
import * as path from 'path'; | ||
import { ImageManager } from 'escpos-buffer-image'; | ||
import { Image } from '../../src'; | ||
import { Image, ImageData, Manager } from '../../src'; | ||
class ManagerTest extends Manager { | ||
loadImage(_filename: string): Promise<ImageData> { | ||
return Promise.resolve(null as ImageData); | ||
} | ||
loadImageFromBuffer(_data: Buffer): Promise<ImageData> { | ||
return Promise.resolve(null as ImageData); | ||
} | ||
buildQrcodeImage(_data: string, _size: number): Promise<ImageData> { | ||
return Promise.resolve(null as ImageData); | ||
} | ||
} | ||
describe('proccess images to printing format', () => { | ||
it('instanciate a manager class', () => { | ||
new ManagerTest(); | ||
}); | ||
it('load image from buffer', async () => { | ||
@@ -8,0 +24,0 @@ const imageManager = new ImageManager(); |
import InMemory from '../../src/connection/InMemory'; | ||
import Printer from '../../src/Printer'; | ||
import { Align } from '../../src/actions'; | ||
import { load } from '../helper'; | ||
@@ -15,2 +16,22 @@ | ||
it('change font from model TSP-143', async () => { | ||
const connection = new InMemory(); | ||
const printer = await Printer.CONNECT('TSP-143', connection); | ||
await printer.setColumns(52); | ||
await printer.writeln('Font Changed'); | ||
expect(connection.buffer()).toStrictEqual( | ||
load('tsp-143_font_changed', connection.buffer()), | ||
); | ||
}) | ||
it('cut paper from model TSP-143', async () => { | ||
const connection = new InMemory(); | ||
const printer = await Printer.CONNECT('TSP-143', connection); | ||
await printer.writeln('Cut below', 0, Align.Center); | ||
await printer.cutter(); | ||
expect(connection.buffer()).toStrictEqual( | ||
load('tsp-143_cutter', connection.buffer()), | ||
); | ||
}) | ||
it('activate drawer from model TSP-143', async () => { | ||
@@ -17,0 +38,0 @@ const connection = new InMemory(); |
@@ -269,5 +269,3 @@ declare const capabilities: { | ||
readonly codepages: { | ||
readonly cp1252: "\u001Bt\u0001"; | ||
readonly cp850: "\u001Bt\u0002"; | ||
readonly cp437: "\u001Bt\u0003"; | ||
readonly cp1252: ""; | ||
}; | ||
@@ -274,0 +272,0 @@ }; |
@@ -335,5 +335,3 @@ "use strict"; | ||
codepages: { | ||
cp1252: '\x1Bt\x01', | ||
cp850: '\x1Bt\x02', | ||
cp437: '\x1Bt\x03', | ||
cp1252: '', | ||
}, | ||
@@ -340,0 +338,0 @@ }, |
import Elgin from './Elgin'; | ||
import { Drawer } from '../actions'; | ||
import { Cut, Drawer } from '../actions'; | ||
import { Font } from '../capabilities'; | ||
export default class Diebold extends Elgin { | ||
buzzer(): Promise<void>; | ||
initialize(): Promise<void>; | ||
protected fontChanged(_: Font, __: Font): Promise<void>; | ||
cutter(_: Cut): Promise<void>; | ||
drawer(number: Drawer, on_time: number, off_time: number): Promise<void>; | ||
} |
@@ -12,2 +12,16 @@ "use strict"; | ||
} | ||
initialize() { | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
yield this.setCodepage(this.capabilities.codepage); | ||
yield this.setColumns(this.capabilities.columns); | ||
}); | ||
} | ||
fontChanged(_, __) { | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { }); | ||
} | ||
cutter(_) { | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
return this.connection.write(Buffer.from('\x1Bw', 'ascii')); | ||
}); | ||
} | ||
drawer(number, on_time, off_time) { | ||
@@ -14,0 +28,0 @@ return tslib_1.__awaiter(this, void 0, void 0, function* () { |
@@ -20,3 +20,3 @@ "use strict"; | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
this.connection.write(Buffer.from('\x1B(A\x05\x00ad\x02\x02\x01', 'ascii')); | ||
return this.connection.write(Buffer.from('\x1B(A\x05\x00ad\x02\x02\x01', 'ascii')); | ||
}); | ||
@@ -23,0 +23,0 @@ } |
{ | ||
"name": "escpos-buffer", | ||
"version": "4.0.2", | ||
"version": "4.0.3", | ||
"description": "Library to generate buffer for thermal printers.", | ||
@@ -41,3 +41,3 @@ "author": "GrandChef Team <desenvolvimento@grandchef.com.br>", | ||
"jest": "^29.4.1", | ||
"prettier": "^2.8.3", | ||
"prettier": "^2.8.8", | ||
"rimraf": "^4.1.2", | ||
@@ -44,0 +44,0 @@ "ts-jest": "^29.0.5", |
@@ -354,5 +354,3 @@ const capabilities = { | ||
codepages: { | ||
cp1252: '\x1Bt\x01', | ||
cp850: '\x1Bt\x02', | ||
cp437: '\x1Bt\x03', | ||
cp1252: '', | ||
}, | ||
@@ -359,0 +357,0 @@ }, |
import Elgin from './Elgin'; | ||
import { Drawer } from '../actions'; | ||
import { Cut, Drawer } from '../actions'; | ||
import { Font } from '../capabilities'; | ||
@@ -9,2 +10,13 @@ export default class Diebold extends Elgin { | ||
async initialize(): Promise<void> { | ||
await this.setCodepage(this.capabilities.codepage); | ||
await this.setColumns(this.capabilities.columns); | ||
} | ||
protected async fontChanged(_: Font, __: Font) {} | ||
async cutter(_: Cut): Promise<void> { | ||
return this.connection.write(Buffer.from('\x1Bw', 'ascii')); | ||
} | ||
async drawer( | ||
@@ -11,0 +23,0 @@ number: Drawer, |
@@ -13,3 +13,5 @@ import Epson from './Epson'; | ||
async buzzer(): Promise<void> { | ||
this.connection.write(Buffer.from('\x1B(A\x05\x00ad\x02\x02\x01', 'ascii')); | ||
return this.connection.write( | ||
Buffer.from('\x1B(A\x05\x00ad\x02\x02\x01', 'ascii'), | ||
); | ||
} | ||
@@ -16,0 +18,0 @@ |
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
413439
209
5533