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

@casualcoders/responder

v1.0.0

Published

A dependencyless page responsiveness package in js built using typescript

Readme

Responder.js 🚀

This package allows you to run as many js functions as you like at breakpoints you specify without the hassle of matchMedia re-running functions for each breakpoint you want the function to be active on. We ensure a function is only run when entering viewport (or page load) or exiting a viewport. This has all been built using typescript, tested and then compiled for compatibility.

WARNING: This requires the browser to function, do not use if your code is running server side as we will not have access to the matchMedia API.

Setup

npm install @casualcoders/responder

Creation

You can use this two ways, by creating responders through our factory, or by creating them yourself.

Factory Creation

import ResponderFactory from "@casualcoders/responder";

ResponderFactory = new ResponderFactory(breakpointConfig)

Example breakpointConfig:

[
  { label: 'small', min: 0, max: 575 },
  { label: 'mobile', min: 576, max: 767 },
  { label: 'tablet', min: 768, max: 991 },
  { label: 'desktop', min: 992, max: 1199 },
  { label: 'big', min: 1200, max: 9999 }
]

If you only require one Responder you can call:

const responder =  ResponderFactory.createResponder(
  breakpointArray,                    //Required
  callbackToRunOnEntry,               //Optional
  callbackToRunOnExit,                //Optional
  shouldRunExitOnSetupIfMatchFails    //Optional default = true
)

If you require multiple Responders you can define them by calling:

const responders = ResponderFactory.createResponders(responderConfigs)

Example functions to run

const firstExampleCallbackToRunOnEntry = () => {
  console.log("firstExampleCallbackToRunOnEntry", "small", "medium");
};

const firstExampleCallbackToRunOnExit = () => {
  console.log("firstExampleCallbackToRunOnExit", "small", "medium");
};

const secondExampleCallbackToRunOnEntry = () => {
  console.log("secondExampleCallbackToRunOnEntry", "desktop");
};

const secondExampleCallbackToRunOnExit = () => {
  console.log("secondExampleCallbackToRunOnExit", "big");
};

const thirdExampleCallbackToRunOnEntry = () => {
  console.log("thirdExampleCallbackToRunOnEntry", "big");
};

const thirdExampleCallbackToRunOnExit = () => {
  console.log("thirdExampleCallbackToRunOnExit", "desktop");
};
  

Example responder Configs:

[
  {
    viewports: ["small", "medium"],             //Required
    enterFn: firstExampleCallbackToRunOnEntry,  //Optional
    exitFn: firstExampleCallbackToRunOnExit,    //Optional
    shouldRunExitOnSetupIfMatchFails: false     //Optional default = true
  },
  {
    viewports: ["desktop"],
    enterFn: secondExampleCallbackToRunOnEntry,
    exitFn: secondexampleCallbackToRunOnExit,
  },
  {
    viewports: ["big"],
    enterFn: thirdExampleCallbackToRunOnEntry,
    exitFn: thirdExampleCallbackToRunOnExit,
  }
]

Direct Creation

import { Responder } from "@casualcoders/responder";

responder = new Responder(
  viewportConfig,                   //Required
  viewportsToRespondTo,             //Required
  callbackToRunOnEntry,             //Optional
  callbackToRunOnExit,              //Optional
  shouldRunExitOnSetupIfMatchFails  //Optional default = true
)

Example viewportConfig array:

[
  { label: 'small', min: 0, max: 575 },
  { label: 'mobile', min: 576, max: 767 },
  { label: 'tablet', min: 768, max: 991 },
  { label: 'desktop', min: 992, max: 1199 },
  { label: 'big', min: 1200, max: 9999 }
]

Example viewportsToRespondTo array:

[
  'small',
  'medium'
]

Initialisation

After being created, you need to run .setup() for each of the responders inside the browser when you wish for the responsive js to begin. This method aggregates the viewports and sets up the matchMedia listeners. This can be done directly if you only created one:

responder.setup()

Or by looping through them:

for (let i = 0; i < responders.length; i++) {
  responders[i].setup();
}

How to contribute

If you wish to contribute there are several ways to do so. You can raise a feature request or a bug report as an issue on Github, or if you would like to contribute to the repository you can find our guidelines in the wiki.

Running tests

npm run test

or a watch task is also available:

npm run watch