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 🙏

© 2026 – Pkg Stats / Ryan Hefner

switch-pro

v1.0.1

Published

Events for Switch Pro controller

Readme

Switch Pro Controller

Support the Switch Pro controller in your JavaScript game!

This is a small package to wrap the gamepad api for the Switch Pro controller to provide an observable API.

Usage

There are two basic APIs, one to capture when buttons are pressed, and one to send vibration to the controller.

Button presses

import SwitchPro from 'switch-pro'

const switchPro = new SwitchPro(window)

switchPro.addListener((pressed) => {
  console.log(pressed)
})

The value passed to the callback is an object with values for the pressed buttons. The callback function will only be invoked if the state of button presses on the controller has changed.

Vibration

Make things Rumble

import SwitchPro from 'switch-pro'
const switchPro = new SwitchPro(window)

switchPro.vibrate()

Available Buttons

Most buttons have a value of either 0 (not-pressed) or 1 (pressed). The Joypad directions have a value ranging from 0-1.

The right side: B, A, Y, X

The center buttons: MINUS, PLUS, HOME, CAPTURE

The directional pad: UP, DOWN, LEFT, RIGHT

The top buttons: L, R, ZL, ZR

The left joystick: LS, LS-UP, LS-DOWN, LS-LEFT, LS-RIGHT

The right joystick: RS, RS-UP, RS-DOWN, RS-LEFT, RS-RIGHT

An example of the object passed to the callback might look like this, where the user is using the Left Stick about 1/2 way to the right and pressing Y:

{
  LS-RIGHT: 0.51,
  Y: 1
}

Run The Example

See it in action. Plug in your controller, and then fire up the example page with yarn start or npm start and visit localhost:8080/examples.