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 🙏

© 2025 – Pkg Stats / Ryan Hefner

redux-iterator

v1.0.1

Published

middleware that iterates over and dispatches actions

Readme

redux-iterator

About

Redux Iterator middleware is capable of receiving Sets, Maps, Arrays, Objects and Generators. Once the middleware is reached, they’re iterated over and the nested actions are dispatched to the Redux store.

Redux Iterator works seamlessly along side other middleware for Thunks and Promises. It makes the process of dispatching to the store cleaner by allowing you to group actions into one item/ location.

Why use Redux Iterator?

It makes updating the state easier and cleaner than before. No longer do there need to be multiple dispatches for various action creators. It can all be done within one.

Below is a simple example of what can be done. Obviously you can come up with many ways to take advantage of Sets, Maps, Arrays, Objects and Generators. Which all now are capable of being sent to the Redux store.

const NAME = 'NAME';
const AGE = 'AGE';

const updateName = (name) => {
  return {
    type: NAME
    name,
  };
}

const updateAge = (age) => {
  return {
    type: AGE
    age,
  };
}

dispatch([updateName('Bob'), updateAge(33)]);

Installation

npm install --save redux-iterator

Then, to enable Redux Iterator, use applyMiddleware():

As seen below, iterator MUST go before thunk middleware in order to avoid issues with thunk invoking the dispatched generator (meant for iterator)

import { createStore, applyMiddleware } from 'redux';
import iterator from 'redux-iterator';
import thunk from 'redux-thunk';
import rootReducer from './reducers/index';

// Note: this API requires redux@>=3.1.0
// With thunk middleware, iterator must go first!
const store = createStore(
  rootReducer,
  applyMiddleware(iterator, thunk)
);

Examples

With Arrays

const arr = [updateName('Bob'), updateAge(33), updateCounter()]
dispatch(arr);

With Objects

const obj = { name: updateName('Bob'), age: updateAge(33), counter: updateCounter() }
dispatch(obj);

With Sets

const set = new Set();
      set.add(updateName('Bob'))
        .add(updateAge(33))
        .add(updateCounter());
dispatch(set);

With Maps

const map = new Map([['key1', updateName('Bob')], ['key2', updateAge(33)], ['key3', updateCounter()]]);
dispatch(map);

With Generators

function* generator() {
        yield updateName('Bob');
        yield updateAge(33);
        yield updateCounter();
      }

dispatch(generator);

License

ISC