Skip to content

feat: collect and collectFirst (Scala style map+filter) - #497

Open
hazrid93 wants to merge 1 commit into
sodiray:masterfrom
hazrid93:hazrid93/54_269
Open

feat: collect and collectFirst (Scala style map+filter)#497
hazrid93 wants to merge 1 commit into
sodiray:masterfrom
hazrid93:hazrid93/54_269

Conversation

@hazrid93

Copy link
Copy Markdown

Closes #269.

Add collect(array, fn): a map+filter combo that maps array through fn and keeps only results that are not undefined (the issue's example: collect([{a:1},{b:2},{a:3}], el => el.a) to [1,3]). And collectFirst(array, fn): returns the first defined result (or undefined if none), short circuiting (collectFirst([{a:1},{b:2},{a:3}], el => el.a) to 1).

@vercel

vercel Bot commented Jul 20, 2026

Copy link
Copy Markdown

@hazrid93 is attempting to deploy a commit to the rayunishinedev's projects Team on Vercel.

A member of the Team first needs to authorize it.

Closes sodiray#269.

Add collect(array, fn): a map+filter combo that maps array through fn and keeps only results that are not undefined (the issue's example: collect([{a:1},{b:2},{a:3}], el => el.a) to [1,3]). And collectFirst(array, fn): returns the first defined result (or undefined if none), short circuiting (collectFirst([{a:1},{b:2},{a:3}], el => el.a) to 1).
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.

Any interest in collect/collectFirst?

1 participant