mirror of
https://github.com/toss/es-toolkit.git
synced 2024-11-28 20:26:33 +03:00
16fda3f24c
* feat(upperFirst): Add upperFirst function * Add upperFirst benchmark * Add upperFirst english docs * Update docs/reference/string/upperFirst.md --------- Co-authored-by: Sojin Park <raon0211@gmail.com> Co-authored-by: Sojin Park <raon0211@toss.im>
29 lines
724 B
TypeScript
29 lines
724 B
TypeScript
import { bench, describe } from 'vitest';
|
|
import { upperFirst as upperFirstToolkit } from 'es-toolkit';
|
|
import { upperFirst as upperFirstLodash } from 'lodash';
|
|
|
|
describe('upperFirst', () => {
|
|
describe('short string', () => {
|
|
bench('es-toolkit/upperFirst', () => {
|
|
const str = 'camelCase';
|
|
upperFirstToolkit(str);
|
|
});
|
|
|
|
bench('lodash/upperFirst', () => {
|
|
const str = 'camelCase';
|
|
upperFirstLodash(str);
|
|
});
|
|
});
|
|
|
|
describe('long string', () => {
|
|
const LONG_STR = 'camelCaseLongString'.repeat(1000);
|
|
bench('es-toolkit/upperFirst', () => {
|
|
upperFirstToolkit(LONG_STR);
|
|
});
|
|
|
|
bench('lodash/upperFirst', () => {
|
|
upperFirstLodash(LONG_STR);
|
|
});
|
|
});
|
|
});
|