extract-files
v13.0.0
Published
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 instance
Downloads
19,854,173
Maintainers
Readme
extract-files
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
.
Installation
For Node.js, to install extract-files
with npm, run:
npm install extract-files
For Deno and browsers, an example import map:
{
"imports": {
"extract-files/": "https://unpkg.com/[email protected]/",
"is-plain-obj": "https://unpkg.com/[email protected]/index.js",
"is-plain-obj/": "https://unpkg.com/[email protected]/"
}
}
See the function extractFiles
to get started.
Requirements
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.allowJs
should betrue
.compilerOptions.maxNodeModuleJsDepth
should be reasonably large, e.g.10
.compilerOptions.module
should be"node16"
or"nodenext"
.
Exports
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
: