Gracefully close the connection and release all OS/hardware resources.
Safe to call even if the connection was never opened (no-op in that case).
Promise that resolves when the connection is fully closed.
Establish a connection to the printer.
Promise that resolves when the connection is ready to accept data.
DeviceNotFoundError if the device cannot be reached or the connection times out.
Read bytes from the printer.
Used to retrieve status bytes or responses to ESC/POS real-time status
commands (DLE EOT).
Optionallength: numberMaximum number of bytes to read. If omitted, returns the first full data chunk received.
Promise resolving with a Buffer containing received data.
DeviceNotFoundError if the connection is not open.
Write raw bytes to the printer.
The returned promise resolves when the write has been accepted by the underlying transport layer — not necessarily when the printer has physically processed the data.
Buffer containing the raw bytes to transmit.
Promise that resolves on successful acceptance by the transport.
DeviceNotFoundError if the connection is not open.
Hardware-agnostic contract for a printer transport layer.
All concrete printer classes (Network, Usb) implement this interface so that higher-level code can treat any transport uniformly. Pass an
IPrinterConnectionto a dependency-injection boundary or a test double to decouple printing logic from hardware.Example
Since
1.0.0