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
Pretty frequently I come across the problem of needing to check if an optional variable is true or false. The problem is that the server can send it as true, false, undefined, "true", or "false". I added this mixin (based on this SO answer):
I'm in favor! Although I would like to slap a !! in front to ensure it always returns a boolean, and call it isTrueish or something like that to clarify that is does not only detect the value true but also string equivalents.
If you submit a pull request that also includes tests and documentation, I will merge it.
I wasn't sure where to put it, but since it's primarily dealing with strings that can sometimes be booleans I put it in the string module. Let me know if I messed anything up! :p
Pretty frequently I come across the problem of needing to check if an optional variable is true or false. The problem is that the server can send it as
true
,false
,undefined
,"true"
, or"false"
. I added this mixin (based on this SO answer):Thoughts on adding this?
The text was updated successfully, but these errors were encountered: