
Security News
Axios Maintainer Confirms Social Engineering Attack Behind npm Compromise
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.
browserprint-es
Advanced tools
npm i browserprint-es
yarn add browserprint-es
This is a direct port of BrowserPrint in an easier to consume and use format with modern development - adhering closely to the original API while allowing async/await and full IDE intellisense and typings + comments support.
The minified version provided by Zebra doesn't provide typings/intellisense. Although there is a separate JSDoc it's not that intuitive and cannot be brought into development flow/IDE like a commented ES version. The minified script won't bundle and integrate with your build (ie: tree shaking).
Generated from TypeScript source for automatic typings!
This project is backwards compatible with original callback signatures, but has been extended with async/await:
import BrowserPrint, { Device, Configuration} from 'browserprint-es'
let defaultDevice: Device | null = null;
let localDevices: Record<string, Device[]> = {};
let applicationConfiguration: Configuration | null = null;
BrowserPrint.getDefaultDevice(
'printer',
(response: Device | null) => {
console.log('got default device', response);
defaultDevice = response;
},
(err) => console.error(err)
)
BrowserPrint.getLocalDevices(
(response) => {localDevices = response},
(err) => console.error('error local devices:', err)
)
BrowserPrint.getApplicationConfiguration(
(response) => {configuration = response},
(err) => console.error('error application config:', err)
)
Above can be written instead with async/await. Examples:
TypeScript
// async/await (Promises) available on some methods (so far)
// NOTE: declaration types not necessary - added to describe return types
import BrowserPrint, { Device, Configuration } from 'browserprint-es'
const device: Device | null = await BrowserPrint.getDefaultDeviceAsync('printer');
const localDevices: Record<string, Device[]> = await BrowserPrint.getLocalDevicesAsync();
const applicationConfiguration: Configuration | null = await BrowserPrint.getConfiguration();
JavaScript
import BrowserPrint from 'browserprint-es'
const device = await BrowserPrint.getDefaultDeviceAsync('printer');
const localDevices = await BrowserPrint.getLocalDevicesAsync();
const applicationConfiguration = await BrowserPrint.getConfiguration();
// These are static methods (call directly)
BrowserPrint.bindFieldToReadData(device, field, readInterval, onReadCallback)
BrowserPrint.convert(resource, device, options, finishedCallback, errorCallback)
BrowserPrint.convert(resource, device, options, finishedCallback, errorCallback)
BrowserPrint.getApplicationConfiguration(finishedCallback, errorCallback)
BrowserPrint.getDefaultDevice(type, finishedCallback, errorCallback)
BrowserPrint.getLocalDevices(finishedCallback, errorCallback, typeFilter)
BrowserPrint.loadFileFromUrl(url, finishedCallback, errorCallback)
BrowserPrint.readOnInterval(device, callback, readInterval)
BrowserPrint.stopReadOnInterval(device)
// properties:
const deviceType: string = device.deviceType
const name: string = device.name
const readRetries: number = device.readRetries
// methods:
device.convertAndSendFile(resource, finishedCallback, errorCallback, options)
device.read(finishedCallback, errorCallback)
device.readAllAvailable(finishedCallback, errorCallback, retries)
device.readUntilStringReceived(receivedString, finishedCallback, errorCallback, retries)
device.send(dataToSend, finishedCallback, errorCallback)
device.sendFile(resource, finishedCallback, errorCallback)
device.sendThenRead(dataToSend, finishedCallback, errorCallback)
device.sendThenReadAllAvailable(dataToSend, finishedCallback, errorCallback, retries)
device.sendThenReadUntilStringReceived(dataToSend, receivedString, finishedCallback, errorCallback, retries)
// deprecated - will be removed in a future version
device.sendUrl(urlOfResource, finishedCallback, errorCallback, options)
The "BrowserPrint-Zebra" API adds objects like Configuration, Status, Info and most importantly the Printer class to abstract and simplify communication with Device
especially to decoding of responses to strongly typed objects
// not static methods like BrowserPrint
// Printer instance methods used to communicate with devices.
const printer = new Printer(device);
printer.getConfiguration(success, failure)
printer.getConvertedResource(resource, options, success, failure)
printer.getInfo(success, failure)
printer.getSGD(setting, success, failure)
printer.getStatus(success, failure)
printer.isPrinterReady(success, failure)
printer.printImageAsLabel(resource, options, success, failure)
printer.query(command, success, failure)
printer.setSGD(setting, value, success, failure)
printer.setThenGetSGD(setting, value, success, failure)
printer.storeConvertedResource(resource, options, success, failure)
Adding this brought in the useful Printer object that makes it easier to get Status/isPrinterReady/Info/Configuration/etc.
ie:
import BrowserPrint, { Device, Printer, Status } from 'browserprint-es'
const device: Device | null = await BrowserPrint.getDefaultDeviceAsync();
const printer: Printer = new Printer(device! /* assume above call is a valid printer */);
// same as device.send("~hs"), but you need to parse the response yourself
// ie: this is a response:
// <0x02>030,0,0,1245,000,0,0,0,000,0,0,0<0x03>
// <0x02>000,0,0,0,0,2,4,0,00000000,1,000<0x03>
// <0x02>1234,0<0x03>
// <0x02>030,0,0,1245,000,0,0,0,000,0,0,0<0x03>
// <0x02>000,0,0,0,0,2,4,0,00000000,1,000<0x03>
// <0x02>1234,
// This calls device.send("~/hs") and parses responses like above for you and even ensures entire response is ready before returning in some cases:
const status: Status | null = await printer.getStatusAsync()
For testing locally without needing a printer (and saving paper) - check out the BrowserPrint emulator: github.com/brianzinn/zebra-emulator
FAQs
BrowserPrint ES
We found that browserprint-es demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.