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

stackmat

v1.1.1

Published

Subscribe to events received from a Stackmat timer connected to the browser via the HTML5 Audio API.

Downloads

22

Readme

Stackmat

Subscribe to events received from a Stackmat timer connected to the browser via the HTML5 Audio API.

Both a Typescript-based library and a UMD build are available.

Typescript Usage

Install the library:

npm install stackmat

Subscribe to events and start listening for packets:

import { Stackmat, Packet } from 'stackmat'

const stackmat = new Stackmat()

stackmat.on('started', (packet: Packet) => {
    console.log('Timer started')
})

stackmat.on('stopped', (packet: Packet) => {
    console.log('Timer stopped at: ' + packet.timeAsString)
})

stackmat.start()

Browser Usage

Import the UMD build:

<script type="text/javascript" src="https://unpkg.com/stackmat"></script>

Subscribe to events and start listening for packets:

<script type="text/javascript">
const stackmat = new Stackmat();

stackmat.on('started', packet => {
    console.log('Timer started')
})

stackmat.on('stopped', packet => {
    console.log('Timer stopped at: ' + packet.timeAsString)
})

stackmat.start()
</script>

Disconnecting

stackmat.stop() may be called to stop listening for packets, without unsubscribing from any events.

stackmat.off(TimerEvent?) may be called to unsubscribe from a specified event, or all events if no specific event is provided.

Events

| TimerEvent | When Fired | --- | --- | packetRecieved | Every time a valid packet is recieved | timerConnected | Valid packets start being received | timerDisconnected | Valid packets stop being received | started | A solve is started, and the timer starts counting up from zero | stopped | A solve is completed, and the timer is stopped | reset | The timer is reset to zero | ready | Both hands are placed on the timer while the timer is in a reset state | unready | One or both hands are removed before the green light turns on and the timer is in a ready state | starting | The green light turns on while in a ready state, indicating the solve can be started | leftHandDown | The left hand is placed on the timer while the timer is in any state | leftHandUp | The left hand is removed from the timer while the timer is in any state | rightHandDown | The right hand is placed on the timer while the timer is in any state | rightHandUp | The right hand is removed from the timer while the timer is in any state

Packet Interface

Each event callback (with the exception of timerConnected and timerDisconnected) sends a Packet with the following properties:

interface Packet {
    isValid: boolean
    status: PacketStatus
    timeInMilliseconds: number
    timeAsString: string
    isLeftHandDown: boolean
    isRightHandDown: boolean
    areBothHandsDown: boolean
}

PacketStatus is an enum representing the internal code sent with each Stackmat packet:

enum PacketStatus {
    IDLE = 'I',
    STARTING = 'A',
    RUNNING = ' ',
    STOPPED = 'S',
    LEFT_HAND = 'L',
    RIGHT_HAND = 'R',
    BOTH_HANDS = 'C',
    INVALID = 'X',
}