Closed n1ru4l closed 4 years ago
This is a nice idea :)
Consideration: If a consumer wants to just extend the default set with one more type of "file", they will have to copy and paste the defaults across into their own function, and both sets will appear in their bundle. Maybe if the default isFileValue()
was exported, they could use it inside their custom function 🤔
This enhancement has been published in v6.0.0 🚀
I know that this package is intended for browser/react-native environments.
By adding a new parameter for
extractFiles
, e.g.isFileValue: (value: unknown) => boolean
, other higher level implementations that are not browser-specific could also leverage the logic of this package.This is how I would imagine a Node.js implementation that uses
fs.ReadStream
.The isFileValue function would then (if defined) used instead of the code block here:
https://github.com/jaydenseric/extract-files/blob/30292c400a48e8685ca541621095dbf87502ef2d/src/extractFiles.mjs#L69-L73
The default value stays the same.
@jaydenseric What is your opinion on this? Are there any concerns? Would the impact on the bundle size be too huge? Could you imagine such a feature becoming part of this package and would you accept a pull request that implements this feature?