npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@cutos/device-tspl-printer

v3.4.1

Published

@cutos/device-tspl-printer is a JavaScript library that provides a unified interface for accessing and controlling printers that support the TSPL command set.

Readme

Introduction

@cutos/device-tspl-printer is a JavaScript library that provides a unified interface for accessing and controlling printers that support the TSPL command set. Developers can use this interface to send and receive data, configure printer parameters, and handle printer events.

TSPL Printer SDK

Installation

npm install @cutos/core

npm install @cutos/device-tspl-printer

Import dependencies

import {CoreAPI} from '@cutos/core';
import {DeviceTSPLPrinter} from '@cutos/device-tspl-printer';

DeviceTSPLPrinter

Constructor, create TSPL printer device instance

let devTSPLPrinter = new DeviceTSPLPrinter(name);
  • name: TSPL Printer device name
Example:
devTSPLPrinter = new DeviceTSPLPrinter('device-tspl-printer');

DeviceTSPLPrinter.init

TSPL Printer device initialization

devTSPLPrinter.init(callback);
  • callback: callback function
Example:
devTSPLPrinter.init((result, error) => {
	if (!error) {
		console.log('onDeviceCreate', result)
	} else {
		console.log(error)
	}
});

DeviceTSPLPrinter.connect

Connect TSPL Printer

devTSPLPrinter.connect(path, callback);
  • path: device port
  • callback: callback function
Example:
 devTSPLPrinter.connect('/ttyS1', (response) => {
	console.log(response)
})
  • Return response example:
{
  "status": true,
  "msg": "already connected"
}

DeviceTSPLPrinter.setLabelSize

Set the label size (width and height) for printing

devTSPLPrinter.setLabelSize(width, height);
  • width: label width
  • height: label height

DeviceTSPLPrinter.setLabelGap

Configures the gap between consecutive labels (for gap-sensing printers)

devTSPLPrinter.setLabelGap(gap);
  • gap: label gap,unit:mm

DeviceTSPLPrinter.setDirection

Defines the printout direction and mirror image.

devTSPLPrinter.setDirection(direction, mirror)
  • direction: Feed Direction 0 or 1
  • mirror: 0:Print normal image;1: Print mirror image
Example:
devTSPLPrinter.setDirection(0, 0)

DeviceTSPLPrinter.setClearBuff

Clears the printer's command buffer

devTSPLPrinter.setClearBuff()

DeviceTSPLPrinter.addBox

Draws a rectangle/box on the label.

devTSPLPrinter.addBox(x, y, width, height, thick)
  • x:Specify x-coordinate of upper left corner (in dots)
  • y:Specify y-coordinate of upper left corner (in dots)
  • width:Specify x-coordinate of lower right corner (in dots)
  • height:Specify y-coordinate of lower right corner (in dots)
  • thick:Line thickness (in dots)
Example:
devTSPLPrinter.addBox(0, 0, 46 * 8, 37 * 8, 8)

DeviceTSPLPrinter.addText

devTSPLPrinter.addText(text, x, y)
  • text: prints text on label
  • x:The x-coordinate of the text
  • y:The y-coordinate of the text
Example:
devTSPLPrinter.addText("hello world", 64, 224)

DeviceTSPLPrinter.addQRCode

devTSPLPrinter.addQRCode(content, x, y)
  • content: QR code content
  • x:The upper left corner x-coordinate of the QR code
  • y:The upper left corner y-coordinate of the QR code
Example:
devTSPLPrinter.addQRCode('POWERED BY CUTOS', 136, 50)

DeviceTSPLPrinter.print

Print content

devTSPLPrinter.print(callback)
  • callback: callback function
Example:
devTSPLPrinter.print((result, error) => {
	console.log(result, error)
})