mirror of
https://github.com/toss/es-toolkit.git
synced 2024-11-28 20:26:33 +03:00
0c6f7c95f1
* feat(before): Add before function * feat(before): Add before test code * feat(before): Add before docs * feat(before): Add before benchmarks --------- Co-authored-by: Sojin Park <raon0211@toss.im>
26 lines
609 B
TypeScript
26 lines
609 B
TypeScript
import { bench, describe } from 'vitest';
|
|
import { before as beforeToolkit } from 'es-toolkit';
|
|
import { before as beforeLodash } from 'lodash';
|
|
|
|
describe('before', () => {
|
|
bench('es-toolkit/before', () => {
|
|
const add = (a: number, b: number) => a + b;
|
|
const n = 10;
|
|
const beforeFn = beforeToolkit(10, add);
|
|
|
|
for (let i = 0; i < n; i++) {
|
|
beforeFn(1, 2);
|
|
}
|
|
});
|
|
|
|
bench('lodash/before', () => {
|
|
const add = (a: number, b: number) => a + b;
|
|
const n = 10;
|
|
const beforeFn = beforeLodash(10, add);
|
|
|
|
for (let i = 0; i < n; i++) {
|
|
beforeFn(1, 2);
|
|
}
|
|
});
|
|
});
|