ashtuchkin / iconv-lite

Convert character encodings in pure javascript.
MIT License
3.08k stars 281 forks source link

Version w/Uint8Array option? #293

Open benrr101 opened 2 years ago

benrr101 commented 2 years ago

I see in the master branch, the typings file allows for Buffer|Uint8Array. I'm currently working on refactoring some of the text decoding code in my project and would love to be able to use a Uint8Array with iconv-lite. Any chance we can get that change published? 😄

ashtuchkin commented 2 years ago

Hey Ben, do you need that for encoding or decoding? Current published version will happily decode Uint8Array even though the typings are not there. Publishing current master is tricky as it's not done yet.

benrr101 commented 2 years ago

Thanks for the response! I need it for decoding, so it's good to know that it will take Uint8Array even if the typings aren't there yet. I wanted to avoid the additional allocation of doing Buffer.from(myUint8Array). I'll give it a shot with an unsafe 'cast' in typescript and put a note in my code to remove the unsafe action once the new version is out.