Back to directory
jaydenseric avatar

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.. Read more below about its uses, features, and usage.

Clone repository

git clone https://github.com/jaydenseric/extract-files.git

57

Stars

23

Forks

3

Watchers

MIT

License

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:

Non Deno projects must configure TypeScript to use types from the ECMAScript modules that have a // @ts-check comment:

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:

Releases

Jul 24, 2026

Version 14.0.0

Download .zip

Major

Updated Node.js support to ^22.13.0 || ^24.0.0 || >=26.0.0. Use the JSDoc tag @import for type imports (requires TypeScript v5.5+). The type isExtractableFile is no longer exported from extract...

Aug 29, 2022

Version 13.0.0

Download .zip

Major

Updated Node.js support to ^14.17.0 || ^16.0.0 || >= 18.0.0. Updated dev dependencies, some of which require newer Node.js versions than previously supported. Use the node: URL scheme for Node....

Jan 14, 2022

Version 12.0.0

Download .zip

Major

Updated Node.js support to ^12.22.0 || ^14.17.0 || >= 16.0.0.

Added a new is-plain-obj dependency that is ESM.

Updated dev dependencies, some of which require newer Node.js versions than p...

Jun 11, 2021

Version 11.0.0

Download .zip

Major

The function extractFiles now deeply clones an input value containing multiple references of an object or array with a mirrored reference structure instead of creating multiple objects or array...

May 10, 2021

Version 10.0.0

Download .zip

Major

Updated Node.js support to ^12.20 || >= 14.13. Stopped supporting Internet Explorer. Updated dev dependencies, some of which require newer Node.js versions than previously supported. Replaced t...