Skip to content

Instantly share code, notes, and snippets.

@micahnz
Created September 8, 2016 14:41
Show Gist options
  • Save micahnz/6296eb1a4cd96f09dd30dc0858eec280 to your computer and use it in GitHub Desktop.
Save micahnz/6296eb1a4cd96f09dd30dc0858eec280 to your computer and use it in GitHub Desktop.
// benchmark test
import { curry } from 'ramda';
import { chainMethod, chainReducer, method, privateMethod, reducer, privateReducer, sideEffect } from "../lib/as-stated";
const initialState = {
result: 0
};
function MyClass(initialState = {}) {
this.state = initialState;
}
// example reducer, adds x to the current result in state
MyClass.prototype.add = chainReducer << curry << function (state, x) {
const newState = Object.assign({}, state, {
result: state.result + a
});
return newState;
};
MyClass.prototype.addStuff = chainReducer << curry << function (state) {
return state
>> this.add(1)
>> this.add(2)
>> this.add(3)
}
const inst = new MyClass()
.add(1)
.addStuff();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment