-
Notifications
You must be signed in to change notification settings - Fork 89
Expose TextEncoder for use in workers #31
Expose TextEncoder for use in workers #31
Conversation
Thanks for this! With the holidays, things are a little more hectic than usual. I’ll try to review when I have a moment but it may take a little longer than normal. |
Hola, No problem at all, totally understand about the holidays. It's the busy season. cheers |
I've updated the pull, as a noticed As a result I took the polyfil for the decode from golang/go#27295 (it only supports utf-8, maybe it's worth removing text-encoding module and also using the TextEncoder from the same go lang polyfil? - one less external dependency) |
Thanks for the contribution! I'm not opposed to using Go's implementation for both TextEncoder and TextDecoder even if it only supports |
Hi there, I can now see why the TextDecoder from text-encoding isn't working (after some hacking locally) I'll see if I can work out a work around; as I see what you mean about the licensing from the go issue. If my lack of is knowledge fails to get me a work around in the next couple of days I'll post here what I'm seeing. Cheers |
The result being the decode method ended up in creating an empty bytes view : https://github.com/inexorabletash/text-encoding/blob/master/lib/encoding.js#L1086. The CustomTextDecoder here ensures the Uint8Array's buffer is an ArrayBuffer, resulting in TextDecoders method setting up bytes view correctly
Hola, I've updated to monkey patch around the TextDecoder's decode method. The type checking at the beginning of the The monkey patch, creates a new Uint8Array, with ArrayBuffer, setting contents from the original buffer. This results in TextDecoder's type checking working. I'm not sure what the Root Cause of the missing type info is, maybe the Let me know your thoughts, cheers |
Hola, I've pushed the changes mentioned, and merged in current master. Let me know your thoughts. Cheers |
Also, please resolve conflicts |
Let me know if that latest change matches what we were talking about. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking great thus far. Some minor changes but we're in the home stretch. Thanks for all the hard work!
updated. |
I noticed that when trying to use
new TextEncoder()
inside a worker, that it would resulting an a not defined error.I've attempted to expose the text-encoding polyfil, in this pull request, which allows the use of
TextEncoder
within a worker.