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

@innu/state

v0.0.1

Published

`@innu/state` is a library designed to streamline state management using async functions that resemble the behavior of reducers in Redux. Unlike Redux, this library does not include a built-in state manager, allowing you to integrate it seamlessly with yo

Readme

@innu/state

@innu/state is a library designed to streamline state management using async functions that resemble the behavior of reducers in Redux. Unlike Redux, this library does not include a built-in state manager, allowing you to integrate it seamlessly with your preferred state management solution such as zustand or jotai.

Note: More details about the motivation behind creating this library and its underlying philosophy can be found in the Appendix section.

Usage

For demonstration purposes, we'll illustrate how to use @innu/state with zustand as the state management library. However, it can be adapted to work with any library that offers similar getState and setState APIs.

Terminology:

To clarify the terminology used in @innu/state compared to Redux, here are the equivalent terms:

| Name | Meaning | Equivalent Redux Function | | ------- | -------------------------------------------------------- | ------------------------- | | toss | A function used to toss actions | dispatch | | taker | A function that takes tossed actions and returns a state | reducer |

Consider the following code:

// state.ts
import { create } from 'zustand';
import { make } from '@innu/state';
import type { MainActions, MainState } from './types.ts'; // Assume these are defined.

export const [attach] = make(
  create({
    //... define initial state here.
  })
);

export const [mainToss] = attach<MainState, MainActions>(async (getState, action, tossLocal) => {
  // ... async logic here to handle actions
});

Now, you can toss actions of type MainActions using the toss function exported. Additionally, you can use the attach function again to add additional takers, enabling multiple reducers to operate on the same state object. For example:

import { attach, mainToss } from 'state.ts';
import { PopupActions, PopupState } from './page2.types.ts';

export const [tossPopup] = attach<PopupState, PopupActions>(async (getState, action, tossLocal) => {
  // ... page 2 logic here.
  await mainToss({
    // Example: logging a user out
  });
  // ... additional logic
});

This approach addresses several challenges encountered with traditional reducers:

  1. Async logic is seamlessly integrated without the need for extra libraries.
  2. Actions can be tossed from within a reducer, simplifying action orchestration.
  3. Lazy-loaded modules can dynamically add their own slice after loading, with the potential for cleanup functionality.
  4. Orchestration between state slices is simplified, similar to tracking file dependencies in a codebase.

Appendix

Why Was This Library Created?

Background

Previously, at my workplace, we explored the concept of "async reducers" similar to Redux but with asynchronous capabilities. Although we encountered challenges and complexities, we found the approach intuitive and effective, albeit with certain pitfalls. While the initial experiment was discontinued, the idea continued to intrigue me, leading to the development of @innu/state.

Async Reducers

If Redux's synchronous reducers are like pure mathematical functions, the async takers in @innu/state resemble filters used in audio processing, introducing delays and echoes. This concept allows actions to interact with an already "playing" state, offering unique possibilities for state management.

TODO: Expand on philosophy, history, and rationale behind @innu/state.