You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
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 isT | typeof NOT_READY
, whereconst 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:
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.The text was updated successfully, but these errors were encountered: