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

recombine

v0.1.1

Published

Utilities for combining Redux reducers

Downloads

5

Readme

We've moving!

We are going to move on under new domain soon. Current one gonna be shifted to service new package.

Please note: all available versions will stay published permanently, so that you have not to worry about existed build processes to be failed.

Recombine npm version Build Status

Utilities for combining Redux reducers

Installation

npm install --save recombine

API

combineReducers(reducers: ReducerMapObjectWithExtraArgs): ReducerWithExtraArgs

Same as original combineReducers from Redux but returned reducer accepts extra arguments and passes them to each child reducer.

Example

Construct reducer that manages state where one branch depends on another:

import {combineReducers} from "recombine";

// for regular reducers `combineReducers` behaves exactly the same as original
const firstBranchReducer = combineReducers({
  something(state = ..., action) {/*...*/},
  somethingElse(state = ..., action) {/*...*/},
});

// created reducer forwards any extra args to child reducers
const secondBranchReducer = combineReducers({
  someKey(state = ..., action, firstBranch) {/*...*/},
  anotherKey(state = ..., action, firstBranch) {/*...*/},
});

const reducer = (state = {}, action) => {
  // compute first branch and pass results to the second branch
  const {firstBranch, secondBranch} = state;
  
  const nextFirstBranch = firstBranchReducer(firstBranch, action);
  const nextSecondBranch = secondBranchReducer(secondBranch, action, nextFirstBranch);
  
  if (nextFirstBranch !== firstBranch || nextSecondBranch !== secondBranch)
    return {firstBranch: nextFirstBranch, secondBranch: nextSecondBranch};
  
  return state;
};

dictionaryReducer(childReducer: Reducer, addKey?: Function, removeKey?: Function, initialState?: Object): Reducer

Create reducer that manages key-value dictionary state with values of same shape. Child reducer is called on every action for each dictionary value, and dictionary key is supplied to the child reducer as third argument.

Any extra arguments for resulting reducer are passed to the child reducer following dictionary key.

Parameters

  • childReducer: Reducer for dictionary values. Receives dictionary key as third argument.
  • addKey?: Function that will be called on every action to determine whether that action should result in adding a new key to the dictionary, in which case it should return the key.
  • removeKey?: Function that will be called on every action to determine whether that action should result in removing a key from the dictionary, in which case it should return the key.
  • initialState = {}: Initial state for resulting reducer.

Roadmap

  • More documentation covering rationale and use cases.
  • More tests