es-toolkit/benchmarks/unionWith.bench.ts
Minsoo Kim cf65b2c601
style(*): Setup prettier and apply formatting (#24)
* chore: add prettierrc

* chore: apply format with prettier config

* chore: eslint error fix
2024-06-04 17:19:26 +09:00

20 lines
640 B
TypeScript

import { bench, describe } from 'vitest';
import { unionWith as unionWithToolkit } from 'es-toolkit';
import { unionWith as unionWithLodash } from 'lodash';
describe('unionWith', () => {
bench('es-toolkit', () => {
const array1 = [{ id: 1 }, { id: 2 }];
const array2 = [{ id: 2 }, { id: 3 }];
const areItemsEqual = (a, b) => a.id === b.id;
unionWithToolkit(array1, array2, areItemsEqual);
});
bench('lodash', () => {
const array1 = [{ id: 1 }, { id: 2 }];
const array2 = [{ id: 2 }, { id: 3 }];
const areItemsEqual = (a, b) => a.id === b.id;
unionWithLodash(array1, array2, areItemsEqual);
});
});