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

kreighter

v1.1.4

Published

A utility for generating Redux action creators.

Downloads

15

Readme

kreighter

Build Status Coverage Status

A utility for generating Redux action creators.

Install

$ npm install --save kreighter

Usage

import { fromType, } from 'kreighter';

const toggleFoo = fromType('TOGGLE_FOO');

toggleFoo();
// -> { type: 'TOGGLE_FOO', }
import { fromType, } from 'kreighter';

const fetchBarSuccess = fromType('FETCH_BAR_SUCCESS', [ 'id', 'response', ]);

fetchFooSuccess(1, { ... });
// -> { type: 'FETCH_BAR_SUCCESS', id: 1, response: { ... }, }
import { fromType, } from 'kreighter';
import { toTitleCase, } from './util';

const formatTitle = (id, title) => ({
  id,
  title: toTitleCase(title),
});

const updateBazTitle = fromType('UPDATE_BAZ_TITLE', formatTitle);

updateBazTitle(1, 'foo bar baz');
// -> { type: 'UPDATE_BAZ_TITLE', id: 1, title: 'Foo Bar Baz', }
import { fromMap, } from 'kreighter';

const destroy = fromMap(
  {
    foo: 'DESTROY_FOO',
    bar: 'DESTROY_BAR',
    baz: 'DESTROY_BAZ',
  },
  [ 'id', ]);

destroy.foo(1); // -> { type: 'DESTROY_FOO', id: 1, }
destroy.bar(2); // -> { type: 'DESTROY_BAR', id: 2, }
destroy.baz(3); // -> { type: 'DESTROY_BAZ', id: 3, }

API

fromType(type, withFields)

Takes an action type and an optional action fields definition. Returns an action creator for the given action type.

type

Type: String

The value set as the action's type property. The type of type is not enforced but there are good reasons to use a string constant.

withFields

Type: [String] | (*...) -> Object

Arbitrary fields can be set on the action through the withFields option. withFields supports one of two types:

  • An array of field names.
  • A function that returns an arbitrary object.

If withFields is an array, each action creator argument is paired with the field name in the same position, and this set of key/value pairs is merged into the created action.

If withFields is a function, it should map action creator arguments to an arbitrary object that is merged with the created action.

fromMap(typeMap, withFields)

Takes an object map of action types and an optional map function. Returns an object map of action creators, one for each action type.

typeMap

Type: { k: String }

An object map of arbitrary keys and action type values. The key for each action type is used as the key for the corresponding action creator on the returned object map.

withFields

Type: [String] | (*...) -> Object

Arbitrary fields can be set on the action through the withFields option. withFields supports one of two types:

  • An array of field names.
  • A function that returns an arbitrary object.

If withFields is an array, each action creator argument is paired with the field name in the same position, and this set of key/value pairs is merged into the created action.

If withFields is a function, it should map action creator arguments to an arbitrary object that is merged with the created action.

License

MIT © Max Hallinan