2024-04-25 14:56:13 +03:00
|
|
|
import { bench, describe } from 'vitest';
|
|
|
|
import { unionWith as unionWithToolkit } from 'es-toolkit';
|
|
|
|
import { unionWith as unionWithLodash } from 'lodash';
|
|
|
|
|
|
|
|
describe('unionWith', () => {
|
2024-06-18 04:40:07 +03:00
|
|
|
bench('es-toolkit/unionWith', () => {
|
2024-04-25 14:56:13 +03:00
|
|
|
const array1 = [{ id: 1 }, { id: 2 }];
|
|
|
|
const array2 = [{ id: 2 }, { id: 3 }];
|
|
|
|
const areItemsEqual = (a, b) => a.id === b.id;
|
|
|
|
unionWithToolkit(array1, array2, areItemsEqual);
|
2024-06-04 11:19:26 +03:00
|
|
|
});
|
2024-04-25 14:56:13 +03:00
|
|
|
|
2024-06-18 04:40:07 +03:00
|
|
|
bench('lodash/unionWith', () => {
|
2024-04-25 14:56:13 +03:00
|
|
|
const array1 = [{ id: 1 }, { id: 2 }];
|
|
|
|
const array2 = [{ id: 2 }, { id: 3 }];
|
|
|
|
const areItemsEqual = (a, b) => a.id === b.id;
|
|
|
|
unionWithLodash(array1, array2, areItemsEqual);
|
2024-06-04 11:19:26 +03:00
|
|
|
});
|
|
|
|
});
|