Closed ankitjha420 closed 6 days ago
The latest updates on your projects. Learn more about Vercel for Git ↗︎
Name | Status | Preview | Comments | Updated (UTC) |
---|---|---|---|---|
es-toolkit | ✅ Ready (Inspect) | Visit Preview | 💬 Add feedback | Sep 13, 2024 6:33am |
Let me review this during the weekend :)
trim
function you wrote is bit odd.
Normally, trim
is a function that removes leading and trailing occurrences (ltrim(rtrim(target, toTrim), toTrim)
),
but the function you wrote removes all occurrences (target.replaceAll(toTrim, '')
)
Lodash: https://lodash.com/docs/#trim PHP: https://www.php.net/manual/en/function.trim.php C#: https://learn.microsoft.com/en-us/dotnet/api/system.string.trim?view=net-8.0
Thank you @nemorize for the feedback, I corrected it. Please have a look again and sorry I misunderstood the issue.
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 99.54%. Comparing base (
c5d0254
) to head (2c797f6
).
This addresses issue #384 by implementing and testing three string manipulation utility functions: trim, ltrim, and rtrim. These functions provide essential trimming capabilities, allowing for precise removal of specified characters from the start, end, or both ends of strings.
Implemented Functions:
trim(str: string, toTrim: string | string[]): string: Removes all specified characters from the string. ltrim(str: string, toTrim: string): string: Trims specified characters from the start of the string. rtrim(str: string, toTrim: string): string: Trims specified characters from the end of the string.
Tests & Benchmarks:
Added comprehensive unit tests for each function, covering various scenarios, including edge cases and handling of empty strings. (trim.spec.ts, ltrim.spec.ts, rtrim.spec.ts). Benchmark test file has been created
PS: This is my first contribution so I may have missed something obvious even though I read the contribution doc, please let me know.