Closed wraithgar closed 6 years ago
@wraithgar I suppose the intention was to support anything that supported indexing. Array-like...
It doesn't help that 2[0] === undefined
... ha.
Yeah I figured there was some broader set of things that were intended to work otherwise I'd have made a PR. The fact remains that there are inputs that will silently produce bad output. Perhaps just a "not a string" test would be enough.
@wraithgar I'm OK with restricting it to Array
and Buffer
, but I think I have seen usage with string
:confused: , but a major bump wouldn't be out of the question if that is the case.
The encode function assumes you are passing in a Buffer, but will happily accept a string with no errors. It will also return a valid looking result that does not decode back into the original string.
It would be helpful if this library threw some sort of exception back to the user if they passed an invalid input to the encode function.