mirror of
https://github.com/toss/es-toolkit.git
synced 2024-11-28 12:05:41 +03:00
30 lines
740 B
TypeScript
30 lines
740 B
TypeScript
import { bench, describe } from 'vitest';
|
|
import { keyBy as keyByToolkit } from 'es-toolkit';
|
|
import { keyBy as keyByLodash } from 'lodash';
|
|
|
|
describe('keyBy', () => {
|
|
bench('es-toolkit/keyBy', () => {
|
|
const people = [
|
|
{ name: 'mike', age: 20 },
|
|
{ name: 'jake', age: 30 },
|
|
{ name: 'john', age: 25 },
|
|
{ name: 'sarah', age: 25 },
|
|
{ name: 'emma', age: 25 },
|
|
];
|
|
|
|
keyByToolkit(people, person => person.name);
|
|
});
|
|
|
|
bench('lodash/keyBy', () => {
|
|
const people = [
|
|
{ name: 'mike', age: 20 },
|
|
{ name: 'jake', age: 30 },
|
|
{ name: 'john', age: 25 },
|
|
{ name: 'sarah', age: 25 },
|
|
{ name: 'emma', age: 25 },
|
|
];
|
|
|
|
keyByLodash(people, person => person.name);
|
|
});
|
|
});
|