toss / es-toolkit

A modern JavaScript utility library that's 2-3 times faster and up to 97% smaller—a major upgrade to lodash.
https://es-toolkit.slash.page
Other
6.25k stars 263 forks source link

feat(pad): add `pad` function #469

Closed pkovzz closed 1 week ago

pkovzz commented 2 weeks ago

Solution

This pull request introduces a pad function that pads a string on both the left and right sides if it is shorter than the specified length. The padding characters are truncated if they cannot be evenly divided by the length.

Benchmark

Screenshot 2024-09-01 at 21 21 44

Resolves #386

vercel[bot] commented 2 weeks 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 1, 2024 7:39pm
codecov-commenter commented 2 weeks ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 99.78%. Comparing base (3a6cb36) to head (daeb4e6).

Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/toss/es-toolkit/pull/469/graphs/tree.svg?width=650&height=150&src=pr&token=8N5S3AR3C7&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=toss)](https://app.codecov.io/gh/toss/es-toolkit/pull/469?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=toss) ```diff @@ Coverage Diff @@ ## main #469 +/- ## ======================================= Coverage 99.78% 99.78% ======================================= Files 171 172 +1 Lines 1366 1368 +2 Branches 364 365 +1 ======================================= + Hits 1363 1365 +2 Misses 2 2 Partials 1 1 ```