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 🙏

© 2024 – Pkg Stats / Ryan Hefner

reduman

v0.0.3

Published

Reducer manager, it can be used in Redux

Downloads

18

Readme

ReduMan

Reducer manager, it can be used as a replace for switch in Redux reducers

Installation

Via npm on Node:

npm install reduman

In your browser: TBD

Usage

Reference in your program

var reduman = require('reduman');

Reference in your browser

TBD

Creating a reducer using fluent API:

var reducer = reduman()
    .when({ type: INCREMENT }, function (state, action) ... )
    .when({ type: INCREMENT}, function (state, action) ... )
    .otherwise(function (state, action) .. );
    
// using with a Redux store
var store = createStore(reducer);

The default action (if no otherwise is specified) is to return the original state.

When you use an object as first argument to when the incoming data is matches (property by property usign ===) with that object.

When you use a simple value as first argument to when the incoming data is compared using === with that value. Example, you can use strings or numbers as action values:

var reducer = reduman()
    .when("INCREMENT", function (state, action) ... )
    .when("DECREMENT", function (state, action) ... )
    .otherwise(function (state, action) .. );

New (version 0.0.2): if you use a simple value as first argument to when, the action is accepted if it is a simple value equals to the argument value, or if the action is an object with a type property equals to that argument.

You can use a predicate function with signature (action) => boolean:

reduman().when(function (action) ...,  function (state, action) ...)

Compose reducers:

var reducer0 = redman()
    .when(...)
var reducer = reduman()
    .use(reducer0)    // add reducer0 to the chain at this point
    .when(...)

reducer0 will be invoked during the process of an action. You can mix use with when. In this way, a reducer can be build isolated of other reducers.

See tests for use examples.

Samples

TBD

Versions

  • 0.0.1 Published
  • 0.0.2 Published, filter by implicit type property
  • 0.0.3 Published, using use to compose reducers

Contribution

Feel free to file issues and submit pull requests � contributions are welcome.

If you submit a pull request, please be sure to add or update corresponding test cases, and ensure that npm test continues to pass.