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

@snowshoe/stamp_listener

v0.1.1

Published

A zero-dependency ES6 listener class for simple stamp detection.

Downloads

1

Readme

SnowShoe Stamp Listener

A zero-dependency ES6 listener class for simple stamp detection.

Installation

npm install @snowshoe/stamp_listener --save

Usage

Simple Stamp Detection

import StampListener from '@snowshoe/stamp_listener';

const stampListener = new StampListener();

stampListener.listen((stampDataPoints, reEnableStampScreen) => {
    // "stampDataPoints" contains the array of data points,
    // it can be passed to the stamp API in this format:
    const stampApiRequestPayload = {data: stampDataPoints};

    // Renable the stamp screen when you're finished, 
    // (a good place for this is the finally() call of an HTTP client):
    reEnableStampScreen();
})

Listener Configuration Options

import StampListener from '@snowshoe/stamp_listener';

const stampListener = new StampListener({
    stampScreenElementId: 'stamp-screen',   // The ID of a specific element - "window" object used by default.
    preventScrolling: true,                 // Disable scrolling - useful on mobile. 
    preventZooming: true,                   // Disable zooming - useful on mobile.
});

Use an HTTP Client to Authenticate Stamp Data

You can use whichever client you want, but this example uses Axios:

import StampListener from '@snowshoe/stamp_listener';
import axios from 'axios';

// Setup the HTTP client with the SnowShoe API base URL and your SnoeShoe API key:
let httpClient = axios.create({
    baseURL: 'https://api.snowshoestamp.com',
    headers: {
        // You will receive a 401 response if this key isn't set...
        post: {'SnowShoe-Api-Key': 'YOUR_SNOWSHOE_API_KEY'} 
    }
});

const stampListener = new StampListener();

stampListener.listen((stampDataPoints, reEnableStampScreen) => {
    // Send the stamp data points to the API... 
    httpClient.post('/v3/stamp', {
        data: stampDataPoints,
        // If you are passing the stamp data through your server first, 
        // this is a good place to add extra data.
    })
        .then(response => {
            console.log(`Successfully verified stamp: ${response.data.stamp.serial}`);
        })
        .catch((error) => {
            const httpStatusCode = error.response?.status;
            if (httpStatusCode === 401) {
                console.log('The API key is most likely incorrect...', error.message);
            } else if (httpStatusCode === 400) {
                console.log('The stamp is most likely not registered...', error.response.data.error.message);
            } else {
                console.log('Some unlikely issue (like a network connection failure) has occurred...', error.message);
            }
        })
        .finally(() => {
            // Don't forget to make the screen stampable again...
            reEnableStampScreen();
        });
});