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 🙏

© 2025 – Pkg Stats / Ryan Hefner

jeux

v0.8.0

Published

Javascript state container

Readme

API

  • createStore(reducerObject, middleware1...middlewarenN);

2nd-level API

  • dispatch(action)
  • subscribe(callback(newState))
  • getState()

State

A plain js object that describes the state of your application

Store

The store is nothing but a js object that gives you access to methods that mutate your app state

Reducers

Reducers are functions that accept the current slice of the state that the reducer responds to and the current action being dispatched.

Middleware

Middleware are functions that are called before an action gets to any reducers.

ReducerObject

A plain js object that is used to map keys to reducer functions. See examples below.

Normal flow --- dispatch action --- reducers --- update state

Flow with middleware --- dispatch action --- passes action through middleware(s) --- reducers --- update state

createStore

CreateStore accepts the reducer object as a first arg. And middleware functions as 2...n args

See Examples below for more details.

dispatch

This method is used to dispatch actions to the reducers which take the action and updates the state accordingly.

most actions look like this

{
    
    type : "FETCH_USER",
    extraField : "someData"
}

subscribe

This method is to be used if you would like to know when changes to the store have occurred. Ths method accepts a callback function that is invoked when the store changes.

getState

The methods returns the current state of your application

Examples

function counter(state = 0, action){
    if(action.type === 'INC'){
        return state + 1;
    } else if(action.type === 'DEC'){
        return state - 1;
    }
    return state;
}

function middlewareExample(dispatch){
    return function(getState){
        return function(action){
            console.log(action.type);
        }
    }
}
const reducerObject = { count: counter };
// normal path   dispath --- run through proper reducer
const store = createStore(reducerObject, middlewareExample);
store.dispatch({type: 'INC'});
// count is 1
function subCallack(newState){
  console.log(newState);   
}
store.subscribe(subCallback);
// everytime the store is dispatched, the newState will be given to the callback and logged

store.getState();
// {count : 1}