Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add includes feature #29

Merged
merged 8 commits into from
Apr 20, 2023
Merged

Add includes feature #29

merged 8 commits into from
Apr 20, 2023

Conversation

RobinMalfait
Copy link
Owner

@RobinMalfait RobinMalfait commented Apr 20, 2023

This PR adds a new includes feature as a continuation of the existing PR #24.

This allows you to check if a certain value is seen in the data. Once it is, it will return early and result in a boolean.

import { pipe, includes } from 'lazy-collections'

let program = pipe(includes(1))

program([1, 2, 3, 4])

// true

Each value is compared using Object.is. This will guarantee that edge cases with NaN also work the same as Array.prototype.includes.

Optionally, you can start searching from a positive index:

import { pipe, includes } from 'lazy-collections'

let program = pipe(includes(1, 1))

program([1, 2, 3, 4])

// false

Closes: #24
Thanks, @AlexVipond!

@RobinMalfait RobinMalfait merged commit eb30562 into main Apr 20, 2023
4 checks passed
@RobinMalfait RobinMalfait deleted the includes branch April 20, 2023 22:28
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.

None yet

2 participants