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

duxen

v0.8.8

Published

High performance engine maintaining a complex immutable state for online applications

Downloads

47

Readme

duxen

DUXEN

npm version jest dependencies devDependencies Gitter License: MIT

High performance data engine maintaining complex immutable state for reactive applications. Fully integrated with Immutable.js, Redux, and Meteor.

See demo here: https://stackblitz.com/edit/duxen-demo

Huh?

Redux is an amazing concept that shows how to manage application data in a predictable state containers. It is actually a tiny library (2kB) with a simple container that receives actions and forwards them to reducers. The actions and reducers themselves have to be fully designed and developed from scratch. Although Redux applications are elegant, behave consistently, and are easy to test, their state management logic is usually scattered across many small files and developers may end up typing a lot of repetitive boilerplate code. Moreover, the reducers must be written as pure functions with no side effects and they have to modify the application state in an immutable way. This can become difficult and error prone especially if application logic is complex.

So here comes DUXEN, the Redux Engine.

Instead of writing individual reducers and action creators, the developer is focusing on the whole application state. The state is described with a schema that contains simple values, collections, and views which are seamlessly transforming the data in collections into their presentation form. The DUXEN compiles the schema, generates the reducers, and provides all the action creators. The resulting application state is built by DUXEN as one large immutable object using Immutable.js library.

Installation

npm install duxen

Development

Setup:

git clone https://github.com/applitopia/duxen.git
cd duxen
npm install

Lint:

npm run lint

Build:

npm run build

Test:

npm test

Lint, Build, & Test:

npm run all

Update Dependencies:

npm update --save

Example

Define your DUXEN schema:

const cmp=(a,b)=>(a>b?1:(a<b?-1:0))

const schema = {

  'todosFilter': {
    type: 'value',
    initValue: "",
  },

  'todosLimit': {
    type: 'value',
    initValue: 10,
  },

  'todos': {type: 'collection'},

  'todosView': {
    type:'view',
    sourceName: 'todos',
    props: ['todosFilter', 'todosLimit'],
    recipe: (seq, props)=>seq
      .filter(v=>v.get('text').indexOf(props.todosFilter) >= 0)
      .sort((a, b)=>cmp(a.get('text'), b.get('text')))
      .take(props.todosLimit),
  },

  'todosCnt': {
    type:'view',
    sourceName: 'todosView',
    props: [],
    recipe: (seq)=>Seq({cnt: seq.count()})
  },

  'todosCompletedCnt': {
    type:'view',
    sourceName: 'todosView',
    props: [],
    recipe: (seq, props)=>{
      const cnt = seq
      .filter(v=>v.get('completed'))
      .count();
      return Seq({cnt});
    }
  },

}

Create a DUXEN engine:

import { createEngine } from 'duxen'

const engine = createEngine(schema)

Get a reducer from the engine and attach it to a Redux store:

import { createStore } from 'redux'

const store = createStore(engine.reducer())

Create actions and dispatch them to the store:

// Create an action that changes the value of the filter
const action = engine.value('todosFilter', "Get milk");

// Dispatch the action to the Redux store
store.dispatch(action);

// Get the updated state from the store
const state = store.getState();

License

MIT