es-toolkit/benchmarks/performance/endsWith.bench.ts
Bert Verhelst b9b409db32
feat(startsWith): add startsWith and endsWith string functions (#224)
* feat(startsWith): add startsWith and endsWith string functions

similar to
* https://lodash.com/docs/4.17.15#startsWith
* https://lodash.com/docs/4.17.15#endsWith

* fix(startsWith): use native startsWith inside the startsWith function

---------

Co-authored-by: Sojin Park <raon0211@toss.im>
2024-07-18 21:21:10 +09:00

18 lines
462 B
TypeScript

import { bench, describe } from 'vitest';
import { endsWith as endsWithToolkit } from 'es-toolkit';
import { endsWith as endsWithLodash } from 'lodash';
describe('endsWith', () => {
bench('es-toolkit/endsWith', () => {
const str = 'fooBar';
endsWithToolkit(str, 'Bar');
endsWithToolkit(str, 'foo', 3);
});
bench('lodash/endsWith', () => {
const str = 'fooBar';
endsWithLodash(str, 'Bar');
endsWithLodash(str, 'foo', 3);
});
});