Skip to content

docs: point alias docs to canonical function#1871

Open
Antoliny0919 wants to merge 1 commit into
toss:mainfrom
Antoliny0919:integration-alias-doc
Open

docs: point alias docs to canonical function#1871
Antoliny0919 wants to merge 1 commit into
toss:mainfrom
Antoliny0919:integration-alias-doc

Conversation

@Antoliny0919

@Antoliny0919 Antoliny0919 commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Summary

The documentation for aliased functions is currently quite inconsistent. It would be better if both documents used the same description rather than providing different explanations.

@vercel

vercel Bot commented Jul 10, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
es-toolkit Ready Ready Preview, Comment Jul 10, 2026 6:57am

Request Review

@Antoliny0919 Antoliny0919 force-pushed the integration-alias-doc branch from 0b6a641 to 3d0efca Compare July 10, 2026 06:51
@Antoliny0919 Antoliny0919 changed the title Integration alias doc docs: point alias docs to canonical function Jul 10, 2026

@Antoliny0919 Antoliny0919 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm planning to consolidate the documentation for functions that have aliases.

You can find the reasoning behind this in the comment below.

I've put together one example of what the consolidated documentation would look like. Would you be willing to help with the remaining alias functions once we agree on the approach?

Functions that require documentation consolidation

  • each, forEach
  • eachRight, forEachRight
  • first, head
  • extend, assignIn
  • extendWith, assignInWith
  • entries, toPairs
  • entriesIn, toPairsIn

(Just as a side note, it looks like entries and entriesIn aren't implemented yet 🥲)

Comment on lines -58 to +3
(`ArrayLike<T> | Record<any, any> | string | null | undefined`): Returns the original collection.
`each` is an alias of [`forEach`](./forEach.md). See the [`forEach`](./forEach.md) documentation for details.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed the detailed documentation from the aliased function.

Using each and forEach as an example, they provide the same functionality, so I think their documentation should remain consistent as well. If both documents contain detailed explanations, any future changes will need to be made in both places.

If one of them is updated without the other being reviewed, we could easily end up in a situation where two aliases provide different documentation for the same behavior.

For that reason, I removed the detailed description from each and had it refer to the forEach documentation instead.

Previously, both functions had detailed documentation. Was there a particular reason for that?

Comment on lines +85 to +86
- `collection` (`ArrayLike<T> | Record<any, any> | string | null | undefined`): The array or object to iterate over.
- `callback` (`(item: any, index: any, collection: any) => unknown`, optional): The function to execute for each element. Default is the `identity` function.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

noticed that the types documented in each were written correctly, so I applied that to forEach. Going forward, when consolidating docs for other aliases beyond each <-> forEach, what do you think about just taking whichever version is more accurate between the two and consolidating them into one, rather than keeping both?

Comment on lines +79 to +82
#### Alias

`each`

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also added an Alias section to the forEach documentation to make it clear that each is an alias of forEach.
(Lodash includes a similar section, which I think helps with discoverability as well.)

I'm not sure whether this is the best place for the section. If you think there's a more appropriate location, please let me know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant