mirror of
https://github.com/toss/es-toolkit.git
synced 2024-11-28 12:05:41 +03:00
25 lines
727 B
TypeScript
25 lines
727 B
TypeScript
import { bench, describe } from 'vitest';
|
|
import { findIndex as findIndexToolkit } from 'es-toolkit/compat';
|
|
import { findIndex as findIndexLodash } from 'lodash';
|
|
|
|
const items = [
|
|
{ id: 1, name: 'Alice' },
|
|
{ id: 2, name: 'Bob' },
|
|
];
|
|
|
|
describe('findIndex', () => {
|
|
bench('es-toolkit/compat/findIndex', () => {
|
|
findIndexToolkit(items, x => x.name === 'Bob');
|
|
findIndexToolkit(items, { name: 'Bob' });
|
|
findIndexToolkit(items, ['name', 'Bob']);
|
|
findIndexToolkit(items, 'name');
|
|
});
|
|
|
|
bench('lodash/findIndex', () => {
|
|
findIndexLodash(items, x => x.name === 'Bob');
|
|
findIndexLodash(items, { name: 'Bob' });
|
|
findIndexLodash(items, ['name', 'Bob']);
|
|
findIndexLodash(items, 'name');
|
|
});
|
|
});
|