Closed azimgd closed 2 years ago
Hey @jaydenseric what makes Buffer unsuitable for inclusion by default? It makes extract-files
that much more compatible with node which is a positive in my mind! Is there some key downside that merits making users customize the isExtractable
function when in node all the time?
@airhorns
It's good to align as much as possible to a universal JavaScript philosophy and stick to standard globals like Blob
, File
, etc.
Buffer
instance doesn't always represent a "file"; arbitrary things people may or may not want to consider a "file" are better off as opt-in instead of opt-out.Buffer
is not universal JavaScript; it's a Node.js-ism. This extract-files
package is also used in Deno projects.extract-files
is used primarily (but not exclusively) on the client, where the byte size of the module is very important. (typeof Buffer !== 'undefined' && value instanceof Buffer) ||
is an extra 61 bytes that offers no value in a browser environment.Right, I understand! Node doesn't have a File
global but it does have a Blob
global as of v16, though I think the vast majority of the code that works with files in node will work with them using Buffer
s. I see the minimalism argument you're making, and yeah by coupling to the browser env you get automatic Deno compatability, but, there sure are a lot of node users out there already. It seems annoying to make those server side users spend their time running into this issue, discover how to customize, and succeed at the customization to save a few bytes and to call node out on its decidedly not-browser-esque API. I think if you wanted, I could probably code golf the change into fewer bytes than are used on master
right now, but I get the sense that's not the biggest issue, I am just a maximalist I guess!
Thanks for your interest in contributing to this project :)
Adding
Buffer
to the list of extractables is not something we'll do out of the box, for now at least. People are able to make their own functionisExtractable
for use with the functionextractFiles
to matchBuffer
instances, or any other custom things.