Skip to content

Conversation

benzaria
Copy link
Contributor

@benzaria benzaria commented Jun 10, 2025

Closes #1181
Filters elements from an Array/Object based on whether there members match the given Type.
If Type is Boolean, it filters out falsy values like Boolean(T) does.

Strict controls whether strict or loose type comparison is used (defaults to loose). I will add this as on option eventually!

@benzaria benzaria marked this pull request as draft June 10, 2025 21:24
@benzaria benzaria marked this pull request as ready for review June 20, 2025 16:33
? _Filter<Rest, Type, Strict, [
...HeadAcc,
...IfFilter<FilterType<First, Type, Strict>,
'0' extends OptionalKeysOf<Array_> // TODO: replace with `IsOptionalKeyOf`.
Copy link
Owner

Choose a reason for hiding this comment

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

This can be done now.

If `Type` is `Boolean`, it filters out `falsy` values like {@link Boolean `Boolean(T)`} does.

Strict controls whether strict or loose type comparison is used (defaults to loose).

Copy link
Owner

Choose a reason for hiding this comment

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

Need proper usage examples.

@sindresorhus
Copy link
Owner

Needs to be added to readme and index.d.ts

@sindresorhus
Copy link
Owner

Make sure to go through the pull request yourself and the diff and find mistakes. Etc. AI can be helpful for this.

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.

ArrayFilter & ObjectFilter types
2 participants