2024-04-25 14:56:13 +03:00
|
|
|
import { omitBy as omitByToolkit } from 'es-toolkit';
|
|
|
|
import { omitBy as omitByLodash } from 'lodash';
|
2024-06-04 11:19:26 +03:00
|
|
|
import { bench, describe } from 'vitest';
|
2024-04-25 14:56:13 +03:00
|
|
|
|
|
|
|
describe('omitBy', () => {
|
|
|
|
bench('es-toolkit', () => {
|
|
|
|
const obj = { a: 1, b: 'omit', c: 3 };
|
2024-06-04 11:19:26 +03:00
|
|
|
const shouldOmit = (value: number | string) => typeof value === 'string';
|
2024-04-25 14:56:13 +03:00
|
|
|
omitByToolkit(obj, shouldOmit);
|
2024-06-04 11:19:26 +03:00
|
|
|
});
|
2024-04-25 14:56:13 +03:00
|
|
|
|
|
|
|
bench('lodash', () => {
|
|
|
|
const obj = { a: 1, b: 'omit', c: 3 };
|
2024-06-04 11:19:26 +03:00
|
|
|
const shouldOmit = (value: number | string) => typeof value === 'string';
|
2024-04-25 14:56:13 +03:00
|
|
|
omitByLodash(obj, shouldOmit);
|
2024-06-04 11:19:26 +03:00
|
|
|
});
|
|
|
|
});
|