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

qr

v0.2.4

Published

A small library to generate QR codes with libqrencode.

Downloads

1,065

Readme

Node QR

node-qr is a simple NodeJS binding to the libqrencode C library written by Kentaro Fukuchi (http://fukuchi.org/works/qrencode/index.en.html).

Installation

To use node-qr, you will first need to install the libqrencode C library

For Mac OS X (assumed MacPorts installed)

port install qrencode

For Ubuntu Linux

apt-get install qrencode

Others (see instructions on site)

http://fukuchi.org/works/qrencode/index.en.html

Node-qr is available in the Node Package Manager (NPM)

npm install qr

Usage

Currently node-qr only comes with an encoder. The usage is simple

encoder.encode(value, path = null, options = {});

First, require the module

var Encoder = require('qr').Encoder;
var encoder = new Encoder;

The following example will encode a given value and emit an 'end' event with PNG data upon completion

// add an event listener for the 'end' event
// which fires upon encoding completion
encoder.on('end', function(png_data){
    // png_data is an instance of Buffer
    // do something
});
encoder.encode('some value');

Alternatively, you can pass a file path for the PNG data to be saved to

encoder.on('end', function(){
    // if you specify a file path, nothing will be passed to the end listener
    // do something
});
encoder.encode('some value', '/tmp/my_qr_file.png');

If at any time an error occurs, an 'error' event will be emitted

encoder.on('error', function(err){
    // err is an instance of Error
    // do something
});

See the tests in test/qr.js for more ways to use the encoder.

While node-qr and libqrencode can encode images up to 4000 characters, this library makes no attempt to automatically set error correction and version options based on the size of the value (yet, anyway). You are responsible for determining what length your values will be and adjusting the options accordingly.

See 2D QR Code Barcode Generation Guide for more information on limitations of QR Codes and the devices that read them.

Encoder Options

The following options can be passed via the third argument of the encode method, which should be an object

  • background_color: self explanatory
  • foreground_color: self explanatory
  • dot_size: specify the size of dot (pixel). (default=3)
  • margin: specify the width of margin. (default=4)
  • level: specify error correction level from L (lowest) to H (highest). (default=L)
  • case_sensitive: ignore case distinctions and use only upper-case characters. (default=true)
  • version: specify the version of the symbol. (default=1)
  • type: type of image to export ('PNG','EPS','SVG','ANSI','ANSI256','ASCII','ASCIIi','UTF8','ANSIUTF8')

For more information around options, see the docs provided for the libqrencoder library here

Feedback/Pull Requests

Feedback and pull requests are always welcomed. This is a work-in-progress. Any help is greatly appreciated.

Who's Using node-qr?

  • Rax.io (Rackspace Short URL Service) - http://rax.io

Are you using node-qr?

If you are using Node QR in a production environment, I'd love to know! Send me a PM or email if you don't mind being listed in this readme.