Extract Files Versions Save

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.

v13.0.0

1 year ago

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.js builtin module imports in tests.

Patch

  • Updated dependencies.
  • Simplified dev dependencies and config for ESLint.
  • Updated GitHub Actions CI config:
    • Run tests with Node.js v14, v16, v18.
    • Updated actions/checkout to v3.
    • Updated actions/setup-node to v3.
  • Updated jsconfig.json:
    • Set compilerOptions.maxNodeModuleJsDepth to 10.
    • Set compilerOptions.module to nodenext.
  • Removed the now redundant not IE > 0 from the Browserslist query.
  • Replaced TypeScript Record types with index signatures.
  • Tweaked formatting of a JSDoc comment.
  • Revamped the readme:
    • Removed the badges.
    • Removed the detailed API docs. The JSDoc comments and TypeScript types in the exported modules are now the primary documentation.
    • Added Browserslist links.
    • Added information about Deno, import maps, TypeScript config, and optimal JavaScript module design.

v12.0.0

2 years ago

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 previously supported.

  • Public modules are now individually listed in the package files and exports fields.

  • Removed ./package from the package exports field; the full package.json filename must be used in a require path.

  • Removed the package main index module; deep imports must be used.

  • Shortened public module deep import paths, removing the /public/.

  • The API is now ESM in .mjs files instead of CJS in .js files, accessible via import but not require.

  • Implemented TypeScript types via JSDoc and @deno-types comments, fixing #7.

  • Changed the function extractFiles parameters. The previously third isExtractableFile parameter has been renamed isExtractable, is now the second parameter, and no longer defaults to the function isExtractableFile to avoid a redundant import when a custom function is specified.

  • The function extractFiles now does basic runtime argument type validation.

  • The function extractFiles now also deep clones “plain” objects that aren’t Object instances (e.g. Object.create(null)).

  • Removed out of the box React Native support. The class ReactNativeFile is no longer exported, or matched by the function isExtractableFile.

    This class was bloating non React Native environments with an extra module, increasing bundle sizes when building and adding an extra step to ESM loading waterfalls in browsers.

    It’s the responsibility of Facebook to adhere to web standards and implement spec-complaint File, Glob, and FormData globals in the React Native environment.

    In the meantime, React Native projects can manually implement a class ReactNativeFile and match it with a custom function isReactNativeFile for use with the function extractFiles.

Patch

  • Also run GitHub Actions CI with Node.js v17.
  • Simplified package scripts.
  • Check TypeScript types via a new package types script.
  • Removed the jsdoc-md dev dependency and the related package scripts, replacing the readme “API” section with a manually written “Exports” section.
  • Reorganized the test file structure.
  • Test the bundle sizes for public modules individually.
  • Use a new assertBundleSize function to assert module bundle size in tests:
    • Failure message contains details about the bundle size and how much the limit was exceeded.
    • Errors when the surplus is greater than 25% of the limit, suggesting the limit should be reduced.
    • Resolves the minified bundle and its gzipped size for debugging in tests.
  • Fixed an extractFiles function test bug.
  • Added an extractFiles function test clarifying that object properties with Symbol keys don’t get cloned.
  • Configured Prettier option singleQuote to the default, false.
  • Updated the package description.
  • Documentation tweaks.
  • Added a license.md MIT License file, fixing #19 via #20.
  • Amended the changelog entry for v10.0.0.

v11.0.0

2 years ago

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 arrays. This change shouldn’t affect typical JSON.stringify use with cloned values.
  • The function extractFiles now uses for…of to iterate FileList instances.

Patch

  • Updated dev dependencies.
  • Reverted the more specific package main field path.
  • The function extractFiles now correctly handles circular references within the input value by recreating the circular references in the returned clone instead of infinitely recursing to the point of a Maximum call stack size exceeded error, fixing #14.
  • Renamed imports in the test index module.
  • Refactored extractFiles tests to use Object.freeze with input objects and arrays to ensure input isn’t mutated.
  • Updated a code example to use a deep import.
  • Amended the changelog entries for v8.0.0 and v9.0.0.

v10.0.0

3 years ago

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 the the package.json exports field public subpath folder mapping (deprecated by Node.js) with a subpath pattern, fixing #17. Deep require paths within extract-files/public/ must now include the .js file extension.
  • Removed Babel related dev dependencies, config, and scripts. Published modules now contain more modern ES syntax.
  • Published modules now contain JSDoc comments, which might affect TypeScript projects.
  • The tests are now ESM in .mjs files instead of CJS in .js files.

Patch

  • Stop using hard-rejection to detect unhandled Promise rejections in tests, as Node.js v15+ does this natively.
  • Used revertable-globals to define globals per-test.
  • Test the bundle size manually using esbuild and gzip-size, removing size-limit related dev dependencies, config, and scripts.
  • Removed npm-debug.log from the .gitignore file as npm v4.2.0+ doesn’t create it in the current working directory.
  • Fixed a test of extractFiles with an undefined value.
  • Updated GitHub Actions CI config:
    • Run tests with Node.js v12, v14, v16.
    • Updated actions/checkout to v2.
    • Updated actions/setup-node to v2.
    • Don’t specify the CI environment variable as it’s set by default.
  • More specific package main field path.
  • Simplified JSDoc related package scripts now that jsdoc-md v10 automatically generates a Prettier formatted readme.
  • Added a package test:jsdoc script that checks the readme API docs are up to date with the source JSDoc.
  • Use the .js file extension in internal require paths.
  • Improved documentation.
  • The file changelog.md is no longer published.
  • Updated URLs in the changelog entries for v3.1.0 and v5.0.1.

v9.0.0

3 years ago

Major

  • Updated Node.js support to ^10.17.0 || ^12.0.0 || >= 13.7.0.
  • Updated dev dependencies, some of which require newer Node.js versions than previously supported.
  • Renamed the lib directory to public; existing deep import or require paths must be updated.
  • Removed the package module field.

Patch

  • Removed Node.js v13 and added v14 to the versions tested in GitHub Actions.
  • Simplified the GitHub Actions CI config with the npm install-test command.
  • Improved JSDoc code examples.
  • Updated EditorConfig.
  • No longer transpile tests with Babel, or test ESM.
  • Simplified the Babel config and scripts, ensuring .js files are parsed as scripts.
  • Removed unnecessary .js file extensions from require paths.
  • Documented all the ways to import and require the public API.
  • Tweaked the readme setup instructions.

v8.1.0

4 years ago

Minor

  • Updated the package exports field:

    • Deep imports to specific files are now allowed, e.g.

      import extractFiles from 'extract-files/lib/extractFiles.js';
      
      const extractFiles = require('extract-files/lib/extractFiles');
      
    • The package.json can now be required, e.g.

      const pkg = require('extract-files/package.json');
      
      // With Node.js --experimental-json-modules flag.
      import pkg from 'extract-files/package.json';
      

Patch

  • Updated dev dependencies.
  • Updated the package engines.node field to 10 - 12 || >= 13.7 to reflect the package exports related breaking changes in [email protected].
  • Improved the package prepare:prettier and test:prettier scripts.
  • Reordered the package test:eslint script args for consistency with test:prettier.
  • Configured Prettier option semi to the default, true.
  • Restructured the src directory so lib and test files are separate with their own .babelrc.js files.

v8.0.0

4 years ago

Major

Patch

  • Updated dependencies.
  • Removed @babel/plugin-proposal-class-properties from dev dependencies and the Babel config.
  • Lint fixes for prettier v2.
  • Ensure GitHub Actions run on pull request.
  • Improved the ExtractableFileMatcher JSDoc typedef.
  • Size limit test the published CJS files as well as the ESM.

v7.0.0

4 years ago

Major

  • Updated Node.js support from v8.10+ to v10+.
  • Replaced tap and nyc with test-director, coverage-node and hard-rejection to improve the dev experience, test ESM natively with Node.js, and reduce the dev install size by ~78.8 MB. These new dev dependencies require Node.js v10+.

Patch

v6.0.0

4 years ago

Major

  • Updated Node.js support from v6+ to v8.10+.

Minor

  • Added the ability to customize what are extractable files, fixing #10 via #11:
    • Added a new third parameter to the extractFiles function, for specifying a custom extractable file matcher.
    • Export a new isExtractableFile function that is used as the default extractable file matcher for the extractFiles function. This can be used in a custom extractable file matcher implementation to match the default extractable files, along with additional custom files.
  • Setup GitHub Sponsors funding:
    • Added .github/funding.yml to display a sponsor button in GitHub.
    • Added a package.json funding field to enable npm CLI funding features.

Patch

  • Updated dev dependencies.
  • Replaced the size-limit dev dependency with @size-limit/preset-small-lib.
  • Added a new babel-plugin-transform-require-extensions dev dependency and ensured ESM import specifiers in both source and published .mjs files contain file names with extensions, which are mandatory in the final Node.js ESM implementation. Published CJS .js files now also have file extensions in require paths.
  • Added a package module field.
  • Removed now redundant ESLint disable require-jsdoc comments.
  • Use GitHub Actions instead of Travis for CI.
  • Redid the test scripts and enforced 100% code coverage.
  • Run size limit tests last in the package test script as they are the slowest.
  • Only size limit test the ESM build.
  • Updated the package test:tap script to workaround a tap bug.
  • Simplified the prepublishOnly script.
  • Ordered plugins before presets in Babel config as they run first.
  • Reduced the size of the published package.json by moving dev tool config to files.
  • Only target the root lib directory in .gitignore and .eslintignore.
  • Removed package-lock.json from .gitignore and .prettierignore as it’s disabled in .npmrc anyway.
  • Prevented ESLint from ignoring dotfiles.
  • Clarified that Opera Mini isn’t supported in the Browserslist queries and readme “Support” section.

v5.0.1

5 years ago

Patch