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

@js-soft/qr-code-scanner

v1.1.2

Published

A SIMPLE qr-code scanner, that works and is simple to use. It will open the camera and wait for a match.

Downloads

6

Readme

QRCodeScanner

This is a SIMPLE qr-code-scanner that will allow you to open the user's camera, scan it and match a pattern or read the string out of the QR Code.

It is highly customizable for you to use it within your page's styles.

How it works

User will click a button, you will trigger the initiate method and a modal will open requesting permission to use the camera (only the first time).
The user will see the camera's output.
When a QRCode is found, it will trigger your onResult method and close the modal.
You can customize the modal and its layer.
You can use a regex to match only what you expect, ensuring the result will not be garbage.

How to use it:

You can require it, or use it as global:

    require(['qr-code-scanner'], function (QRScanner) {...})
    // OR
    window.QRScanner
  • The global QRScanner will only be created IF there is not require/define available in the page.

API

You will call the initiate method, sending the options, like so:

    QRScanner.initiate({
        match: /^[a-zA-Z0-9]{16,18}$/, // optional
        onResult: function (result) { console.info('DONE: ', result); },
        onError: function (err) { console.error('ERR :::: ', err); }, // optional
        onTimeout: function () { console.warn('TIMEOUT'); } // optional
    })

Options

In the options object, you can send:

  • onResult: A function to be triggered when a result is matched
  • onError: A function to be called in case of an error (or device not supported) [optional]
  • onTimeout: Your callback for the timeout event [optional]
  • match: A regular Expression matching what you expect to find in the QRCode (if found something but it does not match what you expected, it will not trigger the onResult) [optional]
  • timeout: A number in ms specifying for how long you will wait for a match. Default: 20000 [optional]
  • parent: The container where the video(from the camera) should be appended to. Default: document.body [optional]
  • lockLayerParent: The container on which the lock-layer will be appended. Default: document.body [optional]
  • className: A CSS class added to the video container. Default: QRScanner-container [optional]
  • lockLayerClassName: A CSS class added to the lockLayer container. Default: QRScanner-lock-layer [optional]
  • LockLayer is the darker layer behind the video.

Example

    import QRScanner from 'qr-code-scanner';

    QRScanner.initiate({
        onResult: (result) => { yourCustomCallback(result); },
        timeout: 10000,
    });

Legacy

This lib uses some ES6 features like let, const and arrow functions, but inherits the reader from Lazar Laszlo's port of ZXing Java library. This project "cleans" some things like global variables and hardcoded ids from the previous projects, fixing some legacy problems.