Description
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
.
"use strict";
const fs = require("fs");
const extractFiles = require("extract-files");
function isFileValue(value) {
return value instanceof fs.ReadStream;
}
const { clone, files } = extractFiles(input, "", isFileValue);
The isFileValue function would then (if defined) used instead of the code block here:
extract-files/src/extractFiles.mjs
Lines 69 to 73 in 30292c4
The default value stays the same.
function defaultIsFileValue(value) {
return (
(typeof File !== 'undefined' && value instanceof File) ||
(typeof Blob !== 'undefined' && value instanceof Blob) ||
value instanceof ReactNativeFile
)
}
@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?