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

docs(ary): Update docs for `ary` #452

Closed mass2527 closed 2 weeks ago

mass2527 commented 2 weeks ago

Previous docs of ary had this following problems.

import { ary } from 'es-toolkit/function';

function fn(a, b, c) {
  console.log(arguments);
}

ary(fn, 2)(1, 2, 3); // [Arguments] { '0': 1, '1': 2 }
ary(fn); // [Arguments] { '0': 1, '1': 2, '2': 3 }
ary(fn, -1); // [Arguments] {}
ary(fn, 1.5); // [Arguments] { '0': 1 }
ary(fn, 2, {}); // [Arguments] { '0': 1, '1': 2, '2': 3 }

Not only did I fix this issue, but I also simplified the example for clarity.

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 Aug 31, 2024 5:33am
codecov-commenter commented 2 weeks ago

Codecov Report

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

Project coverage is 99.77%. Comparing base (367fc87) to head (023b0e7). Report is 5 commits behind head on main.

Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/toss/es-toolkit/pull/452/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/452?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=toss) ```diff @@ Coverage Diff @@ ## main #452 +/- ## ======================================= Coverage 99.77% 99.77% ======================================= Files 165 168 +3 Lines 1321 1343 +22 Branches 357 359 +2 ======================================= + Hits 1318 1340 +22 Misses 2 2 Partials 1 1 ```
mass2527 commented 2 weeks ago

@raon0211

Thanks for fixing it. I copied and pasted the code after testing by mistake.

I have one more thing to discuss: how about throwing an error if a non-integer or negative integer is passed, similar to how it was handled with before?

raon0211 commented 2 weeks ago

Technically, we should, but it would bring a breaking change to our users, where code might suddenly break after updating our library. I'm a little concerned about that.. (Actually, removing the default parameters too)

raon0211 commented 2 weeks ago

We might discuss it in a separate issue or pull request.

mass2527 commented 2 weeks ago

Then we might include these kinds of changes in the next major update