Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use w3c decoder #90

Closed
wants to merge 1 commit into from

Conversation

ThaUnknown
Copy link
Contributor

uses W3C text decoder which is built in to most JS environments such as node.js, web, bun etc

reduces dependency size by some 20-ish KB

@ThaUnknown
Copy link
Contributor Author

@mafintosh

@ThaUnknown
Copy link
Contributor Author

b4a seems like a Buffer polyfill, I made uint8-util which roughly does the same, just with a different API so it's a lot smaller, webtorrent has been using it for quite a while now globally, pretty much since v2 it dropped buffer support :)

@mafintosh
Copy link
Owner

Thanks taking a look tmw. We use b4a everywhere so pretty happy with that

@ThaUnknown
Copy link
Contributor Author

;-;

@mafintosh
Copy link
Owner

Where are you getting 20 kb from? text-decoder is <4kb

@mafintosh
Copy link
Owner

This needs a fallback to envs where TextDecoder doesnt exist, but honestly saving 4kb but adding the code that also supports the fallback doesn't seem worth the complexity to me

@mafintosh
Copy link
Owner

Ah let me re-review, i got confused by the comment, b4a is pulled in by textdecoder

@mafintosh
Copy link
Owner

Moved here holepunchto/text-decoder#2

@mafintosh mafintosh closed this Jul 8, 2024
@ThaUnknown
Copy link
Contributor Author

Moved here holepunchto/text-decoder#2

that is a private org

@ThaUnknown
Copy link
Contributor Author

This needs a fallback to envs where TextDecoder doesnt exist

I personally struggled to find such envs, I think some very niche stuff like goja doesn't support it, and some smart TV's from 2010's, that's about it tho? I used streamx because of how tiny it was compared to stream, this change kinda nullifies that

@mafintosh
Copy link
Owner

Open now, was private by mistake

@mafintosh
Copy link
Owner

We use it on phones where its not there. Dont think 1kb matters personally.

@ThaUnknown
Copy link
Contributor Author

We use it on phones where its not there. Dont think 1kb matters personally.

ah that makes sense.

yeah, I still don't like the fact that I'm importing packages and functionality which I won't be using, would be nice if this was in a separate class that extended readable/writable, rather than the main one so at least its tree-shakeable, or so I'd like to say, but I'm not sure if CJS would allow that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants