mirror of
https://github.com/toss/es-toolkit.git
synced 2024-11-28 03:34:26 +03:00
260bae963f
* feat(maxBy): Add maxBy function * feat(maxBy): Add benchamark test * feat(maxBy): Add unit test of maxBy * docs(maxBy): Add reference of maxBy function * feat(maxBy): use for-each loop instead of index-increasing fashion * fix(maxBy): Change code by code review * fix(maxBy): Changed by code review, all tests are fine * fix(maxBy): remove explicit undefined return * fix(maxBy): Fix reference due to signature modification * Update src/math/maxBy.ts --------- Co-authored-by: Sojin Park <raon0211@gmail.com>
24 lines
598 B
TypeScript
Executable File
24 lines
598 B
TypeScript
Executable File
import { bench, describe } from 'vitest';
|
|
import { maxBy as maxByToolkit } from 'es-toolkit';
|
|
import { maxBy as maxByLodash } from 'lodash';
|
|
|
|
describe('maxBy', () => {
|
|
bench('es-toolkit', () => {
|
|
const people = [
|
|
{ name: 'Mark', age: 25 },
|
|
{ name: 'Nunu', age: 30 },
|
|
{ name: 'Overmars', age: 20 },
|
|
];
|
|
maxByToolkit(people, person => person.age);
|
|
});
|
|
|
|
bench('lodash', () => {
|
|
const people = [
|
|
{ name: 'Mark', age: 25 },
|
|
{ name: 'Nunu', age: 30 },
|
|
{ name: 'Overmars', age: 20 },
|
|
];
|
|
maxByLodash(people, person => person.age);
|
|
});
|
|
});
|