es-toolkit/benchmarks/minBy.bench.ts
HyunWoo Lee (Nunu Lee) 860fb0c0e2
feat(minBy): Add minBy function that select element that have min value by given condition in array (#71)
* feat(minBy): Add minBy function that return minimum of arrary

* feat(minBy): Add minBy bench test & export it

* feat(minBy): Add documents of minBy

* feat(minBy): Add unit test of minBy

* Update src/math/minBy.ts

---------

Co-authored-by: Sojin Park <raon0211@gmail.com>
Co-authored-by: Sojin Park <raon0211@toss.im>
2024-06-17 18:40:13 +09:00

24 lines
598 B
TypeScript

import { bench, describe } from 'vitest';
import { minBy as minByToolkit } from 'es-toolkit';
import { minBy as minByLodash } from 'lodash';
describe('minBy', () => {
bench('es-toolkit', () => {
const people = [
{ name: 'Mark', age: 30 },
{ name: 'Nunu', age: 20 },
{ name: 'Overmars', age: 35 },
];
minByToolkit(people, person => person.age);
});
bench('lodash', () => {
const people = [
{ name: 'Mark', age: 30 },
{ name: 'Nunu', age: 20 },
{ name: 'Overmars', age: 35 },
];
minByLodash(people, person => person.age);
});
});