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

Filtering out specific symbols #29

Open
lazarljubenovic opened this issue Feb 3, 2020 · 0 comments
Open

Filtering out specific symbols #29

lazarljubenovic opened this issue Feb 3, 2020 · 0 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@lazarljubenovic
Copy link
Owner

Symbols are great for special values where "null" and/or "undefined" already represent a valid value. Since they are unique, there is no fear of "what if the consumer wants exactly that value?"-type of questions. Of course, there are other possibilities such as wrapping the unknown-yet-highly-customizable value in an object such as { isReady: false } | { isReady: true, value: T}; however, another equally valid approach is T | typeof NOT_READY, where const NOT_READY = Symbol('NOT_READY').

When we want to filter out these "special" values, for one reason or another (ignoring them, skipping them, waiting only for them), we might encounter code like this:

filter(event => event != NOT_READY)

Obviously, this is not strict enough and would require a specific guard. This is precisely what this module was created for, and while tg.isNot(NOT_READY) seems like it should work, it doesn't. Not sure if bug, or ignorance of Symbols. Either way, would like to have this.

@lazarljubenovic lazarljubenovic added enhancement New feature or request help wanted Extra attention is needed labels Feb 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant