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

redux-simplifier

v1.0.0

Published

A tool to make redux reducer more simple!

Readme

redux-simplifier

Build Status npmnpm

Using redux needs lot's of boilerplate codes,it's very inefficient.Most of reducers and actions are used to replace a value in state. This tool provide a replace action, which will change the value after being dispatched without a reduc er. So, this tool can greatly simplify you code without affect the redux's predictable. Besides, this tool is very easy to use, you just need to know two simply function.

中文

Installation

$ npm install --save redux-simplifier

or

$ yarn add redux-simplifier

Usage

There have two methods to use this tool, one is to enhance the function of redux,the other one is to replace redux;

METHOD ONE:

import { createStore } from 'redux';
import { combineReducers, replaceAction, enhanceReducer } from "redux-simplifier";

const onAddOne = (state = 0, action) => {
  switch (action.type) {
    case "add":
      return state + action.playLoad;
    default:
      return state;
  }
};

const reducer = combineReducers({
  number: onAddOne,
  infor: { text: "text" }
});

const store = createStore(enhanceReducer(reducer));

store.dispatch(replaceAction("infor.text", "new text"));
store.dispatch(replaceAction("number", 1));

//get new state:
// {
//   number: 1,
//   infor: { text: 'new text'}
// }

METHOD TWO:

import { createStore, combineReducers, replaceAction } from "redux-simplifier";

const onAddOne = (state = 0, action) => {
  switch (action.type) {
    case "add":
      return state + action.playLoad;
    default:
      return state;
  }
};

const reducer = combineReducers({
  number: onAddOne,
  infor: { text: "text" }
});

const store = createStore(reducer);

store.dispatch(replaceAction("infor.text", "new text"));
store.dispatch(replaceAction("number", 1));

//get new state:
// {
//   number: 1,
//   infor: { text: 'new text'}
// }

APIs

function replaceAction(tag, value)


A action creator, return a ation like this: { type:actionType.TYPE, tag:tag, playload:value } @param {String} tag is a symbol, to mark the state you want to be replace. "a.b" mean state.a.b will be replaced。 @param {any} value mean the new value you want to replace。

  store.dispacth(replaceAction('infor.text', 'new value'));

function combineReducers(reducers)


Enhance redux combineReducers funtion. When one of reducers's value isn't a function, make the value to be init value of the state. @param {Object} reducers: An object like redux reducers object, but when it's values are not function, the value will be part of the init state; So that we can replace the values when use replace action.

  const reducer = combineReducers({
    number: onAddOne,
    infor: { text: 'text' }
  });

function enhanceReducer(reducer)


Enhance the root reducer, return a new reducer, make sure redux can handle the State replace actions.

  const finalReducer = enhanceReducer(reducer)

not important API

object actionType


This is an Object to manage replace-action type. Can be used to reset replace-action's type:

  import { actionType } from 'redux-simplifier';
  actionType.resetActionType('MY_REPLACE_TYPE')

Sometimes you don't like to use replaceAction:

  import { actionType } from 'redux-simplifier';
  import store from './store';

  store.dispatch({
    type:actionType.TYPE,
    playload: value,
    tag:tag
  });

other API


Below apis are the same with redux:

  • createStore
  • bindActionCreators
  • applyMiddleware
  • compose
  • __DO_NOT_USE__ActionTypes

run example

$ cd example
$ npm install
$ npm run start

license

MIT