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

mori-redux

v3.1.1

Published

Fine collection of Redux functionality for Mori

Downloads

15

Readme

mori-redux

Install instructions

  1. cd into your project directory
  2. run npm install --save mori-redux

Usage

createReduce

// import the goodies we like to use from mori
import { hashMap, list, map, inc, dec } from 'mori'
// import the goodies we like to use from mori-redux
import { createReducer } from 'mori-redux'

// setup some state to begin with
const initialState = list(1, 2, 3)

// along with the initialState we provide a hashMap with actionHandlers keyed by action-types
const reducer = createReducer(initialState, hashMap(
  'increase', (state, action) => map(inc, state),
  'decrease', (state, action) => map(dec, state)
))

// for simplicity I wont hassle with setting up a store
// lets give our reducer an action which is a plain javascript object 
const changedState = reducer(initialState, {type: 'increase'})

changedState.toString() // (2, 3, 4)

// we can also use a hashMap as action like this
const changedAgain = reducer(changedState, hashMap('type', 'decrease')

changedAgain.toString() // (1, 2, 3)

combineReducers

// import mori stuff
import { hashMap, inc, dec } from 'mori'
// import the combineReducer function
// and for convience the createReducer function
import { combineReducers, createReducer } from 'mori-redux'

// let's quickly setup 2 reducers

const lightSwitch = createReducer(false, hashMap(
  'turn_off', (state, action) => false,
  'turn_on', (state, action) => true
))

const counter = createReducer(0, hashMap(
  'increase', (state, action) => inc(state),
  'decrease', (state, action) => dec(state)
))

// Now we combine the reducers
const reducer = combineReducers(hashMap(
  'light', lightSwitch,
  'counter', counter
))

// Lets make use of them
const changedState = reducer(undefined, hashMap('type', 'turn_on'))

changedState.toString() // {'light' true, 'counter' 0}

const changedAgain = reducer(changedState, hashMap('type', 'increase'))

changedAgain.toString() // {'light' true, 'counter' 1}

logMiddleware

// Import our middleware
import { logMiddleware  } from 'mori-redux'
// Import the Redux stuff we need
import { createStore, applyMiddleware } from 'redux'

// Lets mockup a reducer
const reducer = () => 'state'

// Apply the middleware when creating the store
const store = createStore(reducer, applyMiddleware(logMiddeware))

// It's done, whenever the state change, it will log the state (in a human readable way)

Todos

There will be more goodies in the future, keep track of you favorite functionality by subscribing to the related issue.

Contributors

Uses