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

qrize

v1.0.0

Published

JavaScript library for generating tiny QR codes of your web pages

Downloads

82

Readme

qrize

Build Status Coverage Status

JavaScript library for generating tiny QR codes for your web pages.

Table of Contents

Live demo

https://qrize.me

Why qrize?

qrize integrates with URL shortener service, giving you tiny QR codes no matter how long a URL is.

Compare these QR codes that lead to the same long address (313 symbols):

| Regular QR code :hankey: | QR code you get with qrize :+1: | |-------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------| | Regular QR code | QR code you get with qrize |

Having QR codes smaller makes it more reader-friendly, saves space on page and is awesome. Visit qrize.me for general information.

How to install?

To install qrize with Yarn, run:

yarn add qrize

To install qrize with npm, run:

npm install --save qrize

If you don’t want to use npm to manage client packages, qrize package also provides a single-file distribution, which is hosted on a CDN:

<script src="https://unpkg.com/qrize/dist/qrize.umd.js"></script>

How to use?

import Qrize from "qrize";

const qrize = new Qrize({
  element: document.getElementById("qr-target")
});
qrize.createImg({ url: "http://example.com" });

That's it. An element with id #qr-target will contain <img> tag representing a QR code that leads to http://example.com.

If you use UMD package from CDN, Qrize constuctor is available globally.

API

Constructor

Qrize constuctor takes an options object as a parameter and these are available properties:

| Name | Type | Required | Description | |----------|-------------|----------|--------------------------------------------------------------------------------------------------------------------------------------------------------| | element | DOM Element | yes | Container element for the generated QR code. | | cellSize | Number | no | Size of each grid cell in pixels. Default: 2. | | margin | Number | no | Size of margin around the QR code in pixels. Note that you might want to leave some space around your QR code in order to make it readable. Default: 0. |

Methods

Instantiated object returned by new Qrize() has three methods with pretty straightforward purposes:

  • createImg()
  • createSvg()
  • createTable()

Each method can take (not requred) an options object with following parameters:

| Name | Type | Required | Description | |-----------|----------|----------|----------------------------------------------------------------------------------------------------------------------------------------------| | url | String | no | A URL that QR code will lead to. Defaults to a current page address. Default: window.location.href. | | onSuccess | Function | no | A callback that will be called after successful QR code build. Is invoked with an object that has two properties: hash and provided url. | | onFailure | Function | no | A callback that will be called after an attempt to build a QR code has been failed. |

Static Methods

There are also static Qrize methods that communicate with qrize.me API directly:

  • getHash() - get unique hash id of the given URL. Options properties:

| Name | Type | Required | Description | |-----------|----------|----------|------------------------------------------------------------------------------------------------------------------------------------------| | url | String | yes | A URL you want to get a hash id of. | | onSuccess | Function | no | A callback that will be called on successful API response. Is invoked with an object that has two properties: hash and provided url. | | onFailure | Function | no | A callback that will be called if request failed. Is invoked with two arguments: error status code and error message. |

  • getUrl() - get URL of the given hash id. Options properties:

| Name | Type | Required | Description | |-----------|----------|----------|------------------------------------------------------------------------------------------------------------------------------------------| | hash | String | yes | A hash id you want to get a URL of. | | onSuccess | Function | no | A callback that will be called on successful API response. Is invoked with an object that has two properties: url and provided hash. | | onFailure | Function | no | A callback that will be called if request failed. Is invoked with two arguments: error status code and error message. |

You probably won't need them, but if you will, you can use them like this:

import Qrize from "qrize";

Qrize.getHash({
  url: 'http://example.com',
  onSuccess({ hash }) {
    console.log(hash);
  }
})

Qrize.getUrl({
  hash: '8jLDWGQ',
  onSuccess({ url }) {
    console.log(url);
  }
})

LICENSE

MIT

QR Code is registered trademark of DENSO WAVE INCORPORATED.

http://www.qrcode.com/en/faq.html#patentH2Title