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 🙏

© 2026 – Pkg Stats / Ryan Hefner

js-epos-driver

v0.0.3

Published

Javascript library to perform main operations on epson fiscal printer

Readme

EposDriver

How To Use

Installl package
npm install js-epos-driver

Import EposDriver from library
import { EposDriver} from 'js-epos-driver';

Initialize EposDriver

var driver = new EposDriver(
      options={
        ipAddress: '192.168.2.224',
        useSSL: false,
        openCashDrawer: false,
        translateFunction: (text) => {return text +'test'},
        roundPr: (price) => {return price},
        responseHandler: (response) => {console.log(response)},
        errorHandler: (status, response) => {
            console.log('ERROR')
            console.log(status)
            console.log(response)
            }
    });

Parameters

  • ipAddress: ipAddres of the printer
  • useSSL: if set to true connection are made through https. SSL must be enabled on the printer
  • translateFunction: function to translate driver messages.
  • roundPr: function to round float numbers. Default use 2 decimal places
  • errorHandler: function to handle errors from driver
  • responseHandler: function to handle response from driver

responseHandler receive a response object having this structure:

response :{  
    res:{  
        success: bool,  
        code: string,
        status: number,
        statusText: string
    },
    addInfo: dict, //debug info from printer. Only if res.success is false
    tagListNames: list, // debug info from printer. Only if res.success is false
    msgPrinter: string //parsed error message. Only if res.success is false
    msg: string //mesage from printer if getStatusOfFilesForADE is called 
    printed: boolean,
    fiscalReceiptNumber: number
    fiscalReceiptAmount: number
    fiscalReceiptDate: string //format YYYY/MM/DD
    zRepNumber: string
}

Methods

printFiscalReceipt(receipt)

receipt:{
    header: String, optional
    footer: String, optional
    orderlines: [
        {
            quantity: Number, //if negative (refund) all orderlines must be negative
            price: Number, //total price of the line
            discount: Number, percentage
            productName: String,
            unitPrice: Number,
            department:  Number //range 1-99 
        }
    ],
    paymentlines: [
        ticket: String,
        amount: Number,
        type: String, 0=cash, 1=checque, 2=credit card, 3=ticket
        typeIndex: Number, Cash – 0 - 5. Credit – 0 Credit card – 1 - 10. Ticket – 1 - 10.
        description: String, optional
    ],
    operatorId: String, optional default 1
    refundFullRefund: Boolean, optional. Mandatory if quantity in orderLines is negative
    refundDate: String, es. 2020/12/08, optinal. Mandatory if quantity in orderLines is negative
    refundReport: String, //must be four digits, optional. Mandatory if quantity in orderLines is negative
    refundDocNum: String, //must be four digits, optional. Mandatory if quantity in orderLines is negative
    refundCashFiscalSerial: String  //fiscal serial number of the printer that issued the original document, optional. Mandatory if quantity in orderLines is negative
    roundingApplied: Number, optional
    message: String, optional
    lotteryCode: String, optional
}

printFiscalXZReport(operatorId)

It prints report and fiscal closure both
operatorId: the operator id. Must be between 1 and 12, Default 1

printFiscalXReport(operatorId)

It prints report operatorId: the operator id. Must be between 1 and 12, Default 1

getStatusOfFilesForADE()

Retrieves the status of files for ADE (Agenzia delle Entrate).

printFiscalReprintLast(operatorId)

Reprint last receipt operatorId: the operator id. Must be between 1 and 12, Default 1

openCashDrawer(operatorId)

Open drawer operatorId: the operator id. Must be between 1 and 12, Default 1

resetPrinter(operatorId)

operatorId: the operator id. Must be between 1 and 12, Default 1 Return the printer to the STATO REGISTRAZIONE state independent of the current state.

  • Close any open non-fiscal receipts.
  • Close any open administrative documents.
  • Cancel any open fiscal receipts.
  • Cancel any open commercial documents.
  • Cancel any open credit notes.
  • Cancel any open direct invoices printing two copies.
  • Cancel any open free invoices printing one copy.
  • Cancel any open box office tickets plus return the printer to the “SCONTRINO FISCALE” mode.
  • Unblock the keyboard that was previously blocked with the 1055 native protocol command.
  • Clean the keyboard buffer.

printDisplayTest(msg, operatorId)

Displays a text message on the printer's display.
operatorId: the operator id. Must be between 1 and 12, Default 1 msg: message to be displayed. The maximum number of characters is 40

clearText(operatorId)

Clears the text from the printer's display.
operatorId: the operator id. Must be between 1 and 12, Default 1

References

https://support.epson.net/setupnavi/?MKN=FP-81II+RT&PINF=menu&LG2=IT
From epson driver spec files

Common attributes

  • operator: Operator ID number (range 1 - 12). The operator attribute can be omitted. In this case, Operator 01 is assumed. A +50 offset can used with printRecItem, printRecRefund and printRecItemVoid (regarding printRecItemVoid, the offset cannot be used if voidLastItem="1"). Normally if the quantity = 1, the quantity line with "1x" is not printed. Adding the offset to the operator attribute instructs the fiscal printer to print the line when the quantity is exactly 1. The offset has no effect with direct invoices.

  • description: String whose maximum length varies depending on the printer model. Currently the maximum is: Fiscal receipts and commercial documents – 38 characters Direct invoices – 37 characters When printing invoices based on the last fiscal receipt, any 38 character descriptions in the fiscal receipt are truncated to 37 characters. Descriptions that exceed limits are truncated. Note that other attribute names with a similar meaning can have higher maximum lengths such as the “data” attribute used with the “printNormal” sub-element.

  • department: Department ID number (range 1 - 99).

  • qauntity: Epson fiscal printers can compute quantities from 0.001 up to 9999.999. EpsonFPMate automatically rounds down quantities with more than three decimal places. If the quantity exceeds 9999.999, an error is returned. Either a comma or a full stop (period) can represent the decimal point. Thousand separators should not be used. The value must not be zero.

  • unitPrice, amount, payment: Epson fiscal printers can accept prices from 0.00 up to 9999999.99. EpsonFPMate automatically rounds down amounts with more than two decimal places. If it exceeds 9999999.99, an error is returned. Either a comma or a full stop (period) can represent the decimal point. Thousand separators should not be used. The unitPrice and payment attributes can be zero but the amount attribute cannot be zero.

  • justification: Set the customer display description justification. The maximum number of characters that can appear on the display on one line is 20, but descriptions can be longer. This parameter tells the fiscal printer whether to take the first 20 characters or the last 20 from the relative description text to use on the display. Set the attribute as follows:

    • 1 = First 20 characters
    • 2 = Last 20 characters
  • font: Fiscal printers support four different font types. Set the attribute as 7 font follows:

    • 1 = Normal
    • 2 = Bold
    • 3 = Double height
    • 4 = Bold and double height

    The font attribute used with barcodes has a different meaning. Please see the ePOS-Print_eng document for an explanation of non-fiscal TM printer fonts.

  • comment: Ignored by the printer. Useful especially for directIO requests.