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 🙏

© 2024 – Pkg Stats / Ryan Hefner

nyx-printer-react-native

v1.0.1

Published

React native plugin for nyx printer service

Downloads

9

Readme

nyx-printer-react-native

React native plugin for nyx printer service

Installation

npm install nyx-printer-react-native

Usage

import NyxPrinter from "nyx-printer-react-native";

// ...

Printer

const _printTest = async () => {
  try {
    let ret = await NyxPrinter.getPrinterStatus();
    if (ret != PrinterStatus.SDK_OK) {
    appendLog(`printer status: ${PrinterStatus.msg(ret)}`);
    return
    }
    await NyxPrinter.printText("Receipt", { textSize: 48, align: PrintAlign.CENTER });
    await NyxPrinter.printText(`\nOrder Time:\t${Date.now()}\n`, { align: PrintAlign.CENTER });
    let weights = [1, 1, 1, 1];
    let row1 = ["ITEM", "QTY", "PRICE", "TOTAL"];
    let row2 = ["Apple", "1", "2.00", "2.00"];
    let row3 = ["Orange", "1", "2.00", "2.00"];
    let row4 = ["Banana", "1", "2.00", "2.00"];
    let row5 = ["Cherry", "1", "2.00", "2.00"];
    let styles = [
    { align: PrintAlign.CENTER },
    { align: PrintAlign.CENTER },
    { align: PrintAlign.CENTER },
    { align: PrintAlign.CENTER }
    ];
    await NyxPrinter.printTableText(row1, weights, styles);
    await NyxPrinter.printTableText(row2, weights, styles);
    await NyxPrinter.printTableText(row3, weights, styles);
    await NyxPrinter.printTableText(row4, weights, styles);
    await NyxPrinter.printTableText(row5, weights, styles);
    await NyxPrinter.printText("\nOrder Price: \t\t9999.00\n", { align: PrintAlign.CENTER });
    await NyxPrinter.printQrCode(Date.now().toString(), 300, 300, PrintAlign.CENTER);
    await NyxPrinter.printText("\n", {});
    await NyxPrinter.printBarcode(Date.now().toString(), 300, 150, BarcodeTextPosition.TEXT_BELOW, PrintAlign.CENTER);
    await NyxPrinter.printBitmap(imageBase64, BitmapType.BLACK_WHITE, PrintAlign.CENTER);
    await NyxPrinter.printText("\n***Print Complete***", { align: PrintAlign.CENTER });
    await NyxPrinter.printEndAutoOut();
  } catch (e) {
      appendLog(`printTest: ${e}`);
  }
};

LCD

const _showLcd = async () => {
  try {
    await NyxPrinter.configLcd(LcdOpt.INIT);
    await NyxPrinter.showLcdBitmap(imageBase64);
  } catch (e) {
      appendLog(`showLcd: ${e}`);
  }
};

const _resetLcd = async () => {
  try {
    await NyxPrinter.configLcd(LcdOpt.INIT);
    await NyxPrinter.configLcd(LcdOpt.RESET);
  } catch (e) {
      appendLog(`resetLcd: ${e}`);
  }
};

const _wakeupLcd = async () => {
  try {
    await NyxPrinter.configLcd(LcdOpt.INIT);
    await NyxPrinter.configLcd(LcdOpt.WAKEUP);
  } catch (e) {
      appendLog(`wakeupLcd: ${e}`);
  }
};

const _sleepLcd = async () => {
  try {
    await NyxPrinter.configLcd(LcdOpt.INIT);
    await NyxPrinter.configLcd(LcdOpt.SLEEP);
  } catch (e) {
      appendLog(`resetLcd: ${e}`);
  }
};

Scanner

  • Register scanner result listener
React.useEffect(() => {
  // register scanner listener
  DeviceEventEmitter.addListener('onScanResult', (res) => {
    appendLog(`scan result: ${JSON.stringify(res)}`);
  });
  return () => DeviceEventEmitter.removeAllListeners('onScanResult');
}, []);
  • Camera scan
const _cameraScan = async () => {
  try {
    await NyxPrinter.scan({});
  } catch (e) {
    appendLog(`cameraScan: ${e}`);
  }
};
  • Infrared scan: By default, infrared scan will be triggered by the side button. Here is the code for soft tirgger
const _infraredScan = async () => {
  try {
    await NyxPrinter.qscScan();
  } catch (e) {
    appendLog(`infraredScan: ${e}`);
  }
};

Cash Box

const _openCashBox = async () => {
  try {
    await NyxPrinter.openCashBox();
  } catch (e) {
    appendLog(`openCashBox: ${e}`);
  }
};

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT