mirror of
https://github.com/toss/es-toolkit.git
synced 2024-11-28 20:26:33 +03:00
bcc3e924fd
* Remove duplicated zipObjectDeep bench * set: Move and import from compat * cloneDeep: Move to benchmarks folder * startCase: Move to benchmarks folder
34 lines
767 B
TypeScript
34 lines
767 B
TypeScript
import { bench, describe } from 'vitest';
|
|
import { cloneDeep } from 'es-toolkit';
|
|
import { cloneDeep as lodashCloneDeep } from 'lodash';
|
|
|
|
const obj = {
|
|
number: 29,
|
|
string: 'es-toolkit',
|
|
boolean: true,
|
|
array: [1, 2, 3],
|
|
object: { a: 1, b: 'es-toolkit' },
|
|
date: new Date(),
|
|
regex: /abc/g,
|
|
nested: { a: [1, 2, 3], b: { c: 'es-toolkit' }, d: new Date() },
|
|
nested2: { a: { b: { c: { d: { e: { f: { g: 'es-toolkit' } } } } } } },
|
|
};
|
|
|
|
describe('cloneDeep', () => {
|
|
bench('es-toolkit/cloneDeep', () => {
|
|
cloneDeep(obj);
|
|
});
|
|
|
|
bench('lodash/cloneDeep', () => {
|
|
lodashCloneDeep(obj);
|
|
});
|
|
|
|
bench('node/JSON.parse', () => {
|
|
JSON.parse(JSON.stringify(obj));
|
|
});
|
|
|
|
bench('node/structuredClone', () => {
|
|
structuredClone(obj);
|
|
});
|
|
});
|