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

@nju33/flux

v1.3.0

Published

A flux utility

Downloads

44

Readme

@nju33/flux

A Flux utility.

github npm:version minzipped size typescript ci:status dependencies Status devDependencies Status document:typedoc license browserslist

Usage

/**
 * To prepare of using the `Flux`
 * ```sh
 * yarn add @nju33/flux
 * ```
 */
import Flux from '@nju33/flux';

or

<script src="https://unpkg.com/@nju33/flux/flux.js"></script>
<script>
  // Can use the `Flux` here.
</script>

Example by TypeScript

interface State {
  str: string;
  num: number;
  bool: boolean;
}

/**
 * define  in the form of `{[actionName]: payload}`
 */
interface ActionPayload {
  foo: {
    str: State['str'];
  };
  bar: {
    num: State['num'];
  };
  baz: {
    bool: State['bool'];
  };
}

type NameSpace = 'something';

const flux = new Flux<State, ActionPayload, NameSpace>({
  str: '',
  num: -1,
  bool: false,
});

const reducer = flux
  .addAction('foo', (state, payload) => {
    // produce === `immer`
    return produce(state, draft => {
      draft.str = payload.str;
    });
  })
  .addAction('bar', (state, payload) => {
    return produce(state, draft => {
      draft.num = payload.num;
    });
  })
  .addAction(
    'baz',
    (state, payload) => {
      return produce(state, draft => {
        draft.bool = payload.bool;
      });
    },
    // belongs to the 'something' scope
    ['something'],
  )
  .createReducer();

// For example, when using with the Redux.
const store = createStore(reducer);

// By function
store.dispatch(flux.act(({foo}) => [foo({str: 'foo'})]));
console.log('1. ', store.getState());

// By curried
const multiAct = flux.act('foo', 'bar');
store.dispatch(multiAct({str: 'foo2'}, {num: 222}));
console.log('2. ', store.getState());

// It does not process actions belonging to the 'something' scope
// Thus, `bool` remaining `false`
flux.off('something');
store.dispatch(flux.act(({baz}) => [baz({bool: true})]));
console.log('3. ', store.getState());

flux.allOn();
store.dispatch(flux.act(({baz}) => [baz({bool: true})]));
console.log('4. ', store.getState());

Edit @nju33/flux

Tips / I want to define a action which have not payload nothing.

You should use void as type of payload. Here is an example.

interface ActionPayload {
  voidIncrement: void;
  undefinedIncrement: undefined;
}

// ...

flux.act(({voidIncrement}) => [
  increment(),

  // Expected 1 arguments, but got 0.
  // undefinedIncrement(),
  undefinedIncrement(undefined),
]);

Very useful functions

In addition, camelcase-keys and snakecase-keys packages are included in this, because it is used a lot.

// If they are necessary.
import {camelcaseKeys, snakecaseKeys} from '@nju33/flux';

// ...

store.dispatch(
  flux.act('...')(
    camelcaseKeys({
      /* ... */
    }),
  ),
);