Created
September 8, 2016 14:41
-
-
Save micahnz/6296eb1a4cd96f09dd30dc0858eec280 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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