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
The coercion functions when sent are passed the raw option value as parameter one and if set, then the default parameter is sent as the second argument. Therefore if you try using the example option with parseInt but add a default, the result will sometimes succeed and sometimes fail because the second parameter to parseInt is the number base (default base 10).
I imagine changing this now is going to break backwards compatibility - can I suggest that in the prototype.option command you might test to see if fn === parseInt (or parseFloat) and pass arguments appropritely.
Alternatively is probably worth not using parseInt as your example and instead pass function(sRaw) { return parseInt(sRaw, 10); }
If you are happy to risk breaking backward compatibility then I would recommend not passing the default value as a second parameter. The function is really meant for coercing type I assume and the caller is going to know the default anyway.
The text was updated successfully, but these errors were encountered:
The coercion functions when sent are passed the raw option value as parameter one and if set, then the default parameter is sent as the second argument. Therefore if you try using the example option with parseInt but add a default, the result will sometimes succeed and sometimes fail because the second parameter to parseInt is the number base (default base 10).
I imagine changing this now is going to break backwards compatibility - can I suggest that in the prototype.option command you might test to see if fn === parseInt (or parseFloat) and pass arguments appropritely.
Alternatively is probably worth not using parseInt as your example and instead pass function(sRaw) { return parseInt(sRaw, 10); }
If you are happy to risk breaking backward compatibility then I would recommend not passing the default value as a second parameter. The function is really meant for coercing type I assume and the caller is going to know the default anyway.
The text was updated successfully, but these errors were encountered: