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

cups-queue-listener

v1.4.0

Published

Enables node scripts to listen to CUPS specific events, like succesfull prints, errored prints and queue length.

Downloads

8

Readme

cups-queue-listener

Enables node scripts to listen to CUPS specific events, like succesfull prints, errored prints and queue length.

usage

The exported value from this module is an eventEmitter. You can add listeners to it to be notified of the following events print-error and print-success.
When you add some file to the CUPS queue (for instance by $ lp filename.pdf or by using the cups-print module), you will get the job id and the destination it is queued for.
Emit an print-queued event (see example below) on the cups-queue-listener with that id and destination to enable it sending the following events:

  • queue-update, with the folling data; queue: the number of items currently in the queue, queued: the number of items in the queue which are not yet printed, printed: the number of printed items, destination: the printer for which these items are queued.
  • queue-almost-empty, with data; destination: the destination for which the queue is almost empty (5 items left).
  • all-printed, with data; destination: the destination for which the queue is all printed.

These events are also emitted as destination specific events. they have the same data as above but lack the destination property.

  • queue-update-${destination}
  • queue-almost-empty-${destination}
  • all-printed-${destination}
queueListener.on('queue-update-somePrinterName', (data) => {
  console.log(data);
});

examples

import queueListener from 'cups-queue-listener';
import print from 'cups-print';


queListener
  .on("print-error", (data) => {
     console.log("error printing", data);
   })
   .on("print-success", (data) => {
     console.log("\\o/", data);
   })
   .on("queue-update", (data) => {
     console.log(data);
   })
   .on("queue-almost-empty", ({ destination }) => {
     console.log(`${destination} queue is almost empty`);
   });


// do some print action
const { id, destination } = print('some-pdf-File.pdf');
queueListener.emit('print-queued', { id, destination });