Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
find by id and replace in array [lodash vs js vs ramda]
find by id and replace in array [lodash vs js vs ramda]
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36
Browser:
Chrome 118
Operating system:
Linux
Device Platform:
Desktop
Date tested:
2 years ago
Test name
Executions per second
lodash map
473237.5 Ops/sec
es6 map
14164300.0 Ops/sec
lodash findIndex and splice
2253643.0 Ops/sec
ramda findIndex and splice
1185042.2 Ops/sec
ramda map
3385446.8 Ops/sec
HTML Preparation code:
<script src="//cdnjs.cloudflare.com/ajax/libs/ramda/0.25.0/ramda.min.js"></script> <script src="//cdnjs.cloudflare.com/ajax/libs/lodash-fp/0.10.4/lodash-fp.min.js"></script>
Script Preparation code:
var arr = [{id: 1, name: "Person 1"}, {id: 2, name: "Person 2"}];
Tests:
lodash map
var newArr = _.map(arr, function(a) { return a.id === 1 ? {id: 1, name: "Person New Name"} : a; });
es6 map
// ES6 var newArr = arr.map(function(a) { return a.id === 1 ? {id: 1, name: "Person New Name"} : a; });
lodash findIndex and splice
var index = _.findIndex(arr, {id: 1}); // Replace item at index using native splice arr.splice(index, 1, {id: 100, name: 'Person New Name'});
ramda findIndex and splice
const index = R.findIndex(R.propEq('id', 1))(arr) arr.splice(index, 1, {id: 100, name: 'Person New Name'});
ramda map
var newArr = R.map(function(a) { return a.id === 1 ? {id: 1, name: "Person New Name"} : a; })(arr);