2024-08-11 15:09:39 +03:00
|
|
|
import { bench, describe } from 'vitest';
|
2024-08-22 17:16:01 +03:00
|
|
|
import { indexOf as indexOfToolkitCompat } from 'es-toolkit/compat';
|
2024-08-11 15:09:39 +03:00
|
|
|
import { indexOf as indexOfLodash } from 'lodash';
|
|
|
|
|
|
|
|
describe('indexOf', () => {
|
|
|
|
const array = [1, 2, 3, 4, NaN, '1', '2', '3', '4', 'NaN'];
|
|
|
|
|
|
|
|
bench('es-toolkit/compat/indexOf', () => {
|
2024-08-22 17:16:01 +03:00
|
|
|
indexOfToolkitCompat(array, 3);
|
|
|
|
indexOfToolkitCompat(array, NaN);
|
|
|
|
indexOfToolkitCompat(array, '1');
|
|
|
|
indexOfToolkitCompat(array, 'NaN', -5);
|
|
|
|
indexOfToolkitCompat(array, 'NaN', -100);
|
2024-08-11 15:09:39 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
bench('lodash/indexOf', () => {
|
|
|
|
indexOfLodash(array, 3);
|
|
|
|
indexOfLodash(array, NaN);
|
|
|
|
indexOfLodash(array, '1');
|
|
|
|
indexOfLodash(array, 'NaN', -5);
|
|
|
|
indexOfLodash(array, 'NaN', -100);
|
|
|
|
});
|
|
|
|
});
|