A function to recursively extract files and their object paths within a value, replacing them with null in a deep clone without mutating the original value. FileList instances are treated as File instance arrays. Files are typically File and Blob instances.
Used by GraphQL multipart request spec client implementations such as graphql-react and apollo-upload-client.
For Node.js, to install extract-files with npm, run:
npm install extract-filesFor Deno and browsers, an example import map:
{
"imports": {
"extract-files/": "https://unpkg.com/extract-files@13.0.0/",
"is-plain-obj": "https://unpkg.com/is-plain-obj@4.1.0/index.js",
"is-plain-obj/": "https://unpkg.com/is-plain-obj@4.1.0/"
}
}See the function extractFiles to get started.
Supported runtime environments:
- Node.js versions
^14.17.0 || ^16.0.0 || >= 18.0.0. - Deno, importing from a CDN that might require an import map for dependencies.
- Browsers matching the Browserslist query
> 0.5%, not OperaMini all, not dead.
Non Deno projects must configure TypeScript to use types from the ECMAScript modules that have a // @ts-check comment:
compilerOptions.allowJsshould betrue.compilerOptions.maxNodeModuleJsDepthshould be reasonably large, e.g.10.compilerOptions.moduleshould be"node16"or"nodenext".
The npm package extract-files features optimal JavaScript module design. It doesn’t have a main index module, so use deep imports from the ECMAScript modules that are exported via the package.json field exports: