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 __.valued wildcard #60

Closed
mordv opened this issue Nov 1, 2021 · 1 comment · Fixed by #229 · May be fixed by lkeff/extensions#7
Closed

Add __.valued wildcard #60

mordv opened this issue Nov 1, 2021 · 1 comment · Fixed by #229 · May be fixed by lkeff/extensions#7
Labels
enhancement New feature or request

Comments

@mordv
Copy link

mordv commented Nov 1, 2021

Hi! Thanks for this amazing library!

I often use {x: not(__.nullish)} pattern so I wonder can we add __.valued wildcard?

Which would look like this

const isValued = <T>(val?: T | null | undefined): val is T => val !== undefined && val !== null;

Happy to create PR, if you approve.

@mordv mordv added the enhancement New feature or request label Nov 1, 2021
@gvergnaud
Copy link
Owner

gvergnaud commented Nov 8, 2021

Thanks for the suggestion, I'll consider it. In the meantime, since this can be implemented in user land with const valued = not(__.nullish), you can store this in your own codebase if you want to use this.

Update for TS-Pattern v4+:

const valued = P.not(P.nullish);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
2 participants