Touffy / client-zip

A client-side streaming ZIP generator

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Performance] use TextEncoderStream where it is supported

Touffy opened this issue · comments

When the input for a ZIP entry is a string, it is currently transformed into a Uint8Array, even for large strings. When the browser supports TextEncoderStream , we should use that and set the entry's internal bytes to the resulting stream instead of a Uint8Array.

Uint8Array streams (the readable half of a TextEncoderStream) are already a valid internal type, so only input normalization is impacted by this change.

Sadly, that feature is not yet implemented in Safari, so it needs to be an optional code path with feature detection.

I don't expect this change to be massively useful in the long term (since using large strings as input is a bad idea anyway) but it should be simple.