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-pirate-actions

v1.0.2

Published

The simplest way to create actions in redux

Readme

import { simpleActions } from 'redux-pirate-actions';

export const createDependencies = (actions, store) => {
  const actionsCallbacks = bindActionCreators(simpleActions(actions), store.dispatch)
  return [store, actionsCallbacks]
}

Now you doesn't need any type constants for redux. The type field will auto generate with redux-pirate-actions using the function name for that.

Actions can be any simple functions

// simple promise
const foo = () => new Promise();

// an object
const boo = () => ({ data: { field: 1, field2: 2 }});

// or almost nothing, but this way you will see the warn in the console with message: 'The action goo should return Object or Promise';
const goo = () => {};

Instalation

npm install redux-pirate-actions -s

Motivation

We trap to constants hell quite often using pure redux functions. And often the constant have same name with action.

const CHANGE_SOMETHING = 'CHANGE_SOMETHING';

const changeSomething = ()=> ({
    type: CHANGE_SOMETHING
});

The code become a rubbish, and it can be better. So we drop the constatns and create redux-pirate-actions to automate this process.

How to use

There few way to use the redux-pirate-actions. We provide two defined methods.

  • simpleActions - the actions wrapper that define the type filed when it doesn't exists
  • setActionTypes - the way to setup types object to be able use it in the reducers
  • getTypes - the way to get the types object at the reducers

NOTE: to simplify the usage we set the copy of the types object to the window.types object. But it's mostly lifehack here.

First of all we needs some actions.

export const foo = () => ({ data: 'foo'});
export const boo = () => ({ data: 'foo'});

Then we have to wrap actions before use bindActionCreators funcion from redux.

import { bindActionCreators } from 'redux'
import { simpleActions } from 'redux-pirate-actions';

export default (actions, store) => {
  const actionsCallbacks = bindActionCreators(simpleActions(actions), store.dispatch)
  return [store, actionsCallbacks]

And now at reducers we use actions by name

import { getTypes } from 'redux-pirate-actions';
const types = getTypes();
// or types can come from window object

export function someData(state = '', action) {
    switch (action.type) {
        case types.foo:
            return action.data;

        case types.boo:
            return action.data;

        default:
            return state
    }
}

Limitations

The types object should be received before redux init the store with default state. Other vise types would be empty.

We provide possibility to generate types list before simpleActions will call via the setActionTypes.

import { setActionTypes } from 'redux-pirate-actions';
...
setActionTypes(actions);
...
export const store = createStore({}, reducers);

Copyright (c) 2017 Pirate Minds. Licensed with The MIT License (MIT).