mirror of
https://github.com/toss/es-toolkit.git
synced 2024-12-01 10:45:08 +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);
|
|
});
|
|
});
|