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
@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.

@sindresorhus
Copy link
Owner

should the name of ObjectFilter type be FilterObject instead.

FilterObject

@benzaria
Copy link
Contributor Author

should the name of ObjectFilter type be FilterObject instead.

FilterObject

Just pointing out that we also could merge them in one Filter type.

@sindresorhus
Copy link
Owner

sindresorhus commented Oct 18, 2025

A single type is tempting. Any downsides?

@benzaria
Copy link
Contributor Author

A single type is tempting. Any downsides?

should not be any, I guess.

@benzaria
Copy link
Contributor Author

@sindresorhus the merge of both types was flawless with no problems.

type Fail2 = IsEmptyArray<[0?]>;
//=> false
type Fail3 = IsEmptyArray<...string[]>;
Copy link
Owner

Choose a reason for hiding this comment

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

I don't think this is valid TS. Ensure all examples are correct.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right, I fixed it.

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