mirror of
https://github.com/toss/es-toolkit.git
synced 2024-12-01 10:45:08 +03:00
fcc166a8fa
* feat(size, compat): implement size function Signed-off-by: sunrabbit123 <qudwls185@naver.com> * fix: typo Signed-off-by: sunrabbit123 <qudwls185@naver.com> * bench(size): add benchamrk code Signed-off-by: sunrabbit123 <qudwls185@naver.com> * enhance(size): refactor size implementation Signed-off-by: sunrabbit123 <qudwls185@naver.com> * remove: unused code Signed-off-by: sunrabbit123 <qudwls185@naver.com> * fix: type check Signed-off-by: sunrabbit123 <qudwls185@naver.com> * fix: typo Signed-off-by: sunrabbit123 <qudwls185@naver.com> --------- Signed-off-by: sunrabbit123 <qudwls185@naver.com>
40 lines
836 B
TypeScript
40 lines
836 B
TypeScript
import { bench, describe } from 'vitest';
|
|
import { size as sizeToolkit } from 'es-toolkit';
|
|
import { size as sizeLodash } from 'lodash';
|
|
|
|
describe('size', () => {
|
|
bench('es-toolkit/size', () => {
|
|
sizeToolkit([1, 2, 3, 4]);
|
|
sizeToolkit('hello');
|
|
sizeToolkit({ a: 1, b: 2, c: 3 });
|
|
sizeToolkit([]);
|
|
sizeToolkit('');
|
|
sizeToolkit({});
|
|
sizeToolkit(new Set([1, 2, 3]));
|
|
sizeToolkit(
|
|
new Map([
|
|
['a', 1],
|
|
['b', 2],
|
|
['c', 3],
|
|
])
|
|
);
|
|
});
|
|
|
|
bench('lodash/size', () => {
|
|
sizeLodash([1, 2, 3, 4]);
|
|
sizeLodash('hello');
|
|
sizeLodash({ a: 1, b: 2, c: 3 });
|
|
sizeLodash([]);
|
|
sizeLodash('');
|
|
sizeLodash({});
|
|
sizeLodash(new Set([1, 2, 3]));
|
|
sizeLodash(
|
|
new Map([
|
|
['a', 1],
|
|
['b', 2],
|
|
['c', 3],
|
|
])
|
|
);
|
|
});
|
|
});
|