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

hyperapp-actionpack

v0.0.4

Published

This is a proof of concept of how to build actions in a service container that you can manage globally.

Readme

Hyperapp Action Pack

This is a proof of concept of how to build hyperapp actions in a container that you can manage globally.

See composable-state for documentation on state updates.

Install

npm install --save hyperapp-actionPack

Example

Simplest

How to wire your actions into your app.

import ActionPack from 'hyperapp-actionPack';
import { app, h, text } from 'hyperapp';
import { select, replace } from 'composable-state';

const actions = new ActionPack();

actions.declare('++', (props) => composable.select('counter', composable.replace(old => old + 1)));
actions.declare('--', (props) => composable.select('counter', composable.replace(old => old - 1)));

app({
  init: {
    counter: 0,
  },

  view: (state) => {
    return h('div', { style: { display: 'flex', justifyContent: 'center', alignItems: 'center' } }, [
      h('button', { type: 'button', onclick: actions.act('--') }, text('-1')),

      h('div', {}, text(`${state.counter}`)),

      h('button', { type: 'button', onclick: actions.act('++') }, text('+1')),
    ]);
  },
});

Conditional updates based on state

Get access to the global state to decide how to properly update the state.

import ActionPack from 'hyperapp-actionPack';
import { select, replace, collect } from 'composable-state';

const actions = new ActionPack();

actions.declare('play-sound', (props, state) => (
  state.enabled
    ? select('audioSrc', props.audioSrc)
    : collect([])
));

Composable exposed in stateMutators

As a convenience, all composable-state mutators are available as a third parameter to your state-mutator method.

import ActionPack from 'hyperapp-actionPack';

const actions = new ActionPack();

actions.declare('++', (props, _state, { select, replace }) => select('counter', replace(old => old + 1)));

With effects

And of course, your actions can schedule side-effects, too.

import ActionPack from 'hyperapp-actionPack';

const actions = new ActionPack();

const effectFx = (dispatch, props) => {
  console.log(`Hello ${props.name} from my side-effect`);
};
const effect = (props) => [effectFx, props];

actions.declare('runMyEffect', (props, _state, { collect }) => [
  collect([]),
  effect({ name: 'world' }),
]));

Chaining actions

Chaining actions together has never been easier

import ActionPack from 'hyperapp-actionPack';

const actions = new ActionPack();

actions.declare('step1', (props, _state, { collect }) => [
  collect([]),
  actions.andThen('step2', props),
]);

actions.declare('step2', (props, _state, { collect }) => collect([]));

Debugging

For now, debugging is strictly console/devtools based. To turn it on, just pass the global console object into the constructor. In the future, I may write proper debug/devtools adapter using the console api.

import ActionPack from 'hyperapp-actionPack';

const actions = new ActionPack(console);

actions.declare('++', (props, _state, { select, replace }) => (
  select('counter', replace(old => old + 1))
);

It sets up a singleton

If you want to split up your actions across multiple file, you can do-so easily with the handle singleton static method.

actions1.js

import ActionPack from 'hyperapp-actionPack'

const actions = ActionPack.singleton();

actions.declare('foo', (_props, _state, { select, replace }) => select('name', replace('foo')));

actions2.js

import ActionPack from 'hyperapp-actionPack'

const actions = ActionPack.singleton();

actions.declare('bar', (_props, _state, { select, replace }) => select('name', replace('bar')));

app.js

import ActionPack from 'hyperapp-actionPack';
import { app, h, text } from 'hyperapp';

const actions = ActionPack.singleton();

app({
  init: { name: null },

  view: (state) => h('div', {}, [
    h('div', {}, `Hello${state.name ? `, ${state.name}` : ''}`),
    h('button', { type: 'button', onclick: actions.act('action1.foo') }, text('Foo')),
    h('button', { type: 'button', onclick: actions.act('action2.bar') }, text('Bar')),
  ]),
});