Test name | Executions per second |
---|---|
Object spread | 425476.4 Ops/sec |
Patchinko | 28401.5 Ops/sec |
Ramda Lens | 81507.7 Ops/sec |
<script src="//cdnjs.cloudflare.com/ajax/libs/ramda/0.25.0/ramda.min.js"></script>
<script src=//unpkg.com/patchinko@4.1.0/immutable.js></script>
// Initial state
var state = {
visible: false,
lazy: { test: true, number: 44 },
count: 1
}
// Define reducers ahead of time
var spread = state => ({
state,
lazy: {
state.lazy,
test: !state.lazy.test
}
})
var patchinko = state =>
O(state, {
lazy: O({
test: O(test => !test),
}),
})
var lens = R.lensPath(["lazy", "test"])
var ramda = state => {
return R.over(lens, test => !test, state)
}
var data = spread(state)
var data = patchinko(state)
var data = ramda(state)