Allow integers as input
MethodGrab opened this issue · 3 comments
MethodGrab commented
At the moment if you pass an integer to the polyfill it will error because doing charAt()
on an integer isn't valid.
I know the docs for the native version of btoa
state that the input should be a string but both Chrome & Firefox allow integers to be used without erroring so I think not erroring on integers would be in-line with how someone would expect the polyfill to work.
davidchambers commented
This sounds reasonable to me. It should be as simple as applying String to the argument:
> btoa(42) === btoa('42')
true
> btoa(null) === btoa('null')
true
> btoa({x: 1}) === btoa('[object Object]')
true
MethodGrab commented
Great, thanks David!
davidchambers commented
No problem. Thanks for the suggestion.