パッケージの詳細

safefs

bevry592.3kArtistic-2.08.10.0

Stop getting EMFILE errors! Open only as many files as the operating system supports.

closeFile, emfile, esnext, fs

readme

Safe FS

Status of the GitHub Workflow: bevry NPM version NPM downloads
GitHub Sponsors donate button ThanksDev donate button Patreon donate button Liberapay donate button Buy Me A Coffee donate button Open Collective donate button crypto donate button PayPal donate button
Discord server badge Twitch community badge

Stop getting EMFILE errors! Open only as many files as the operating system supports.

Usage

Complete API Documentation.

var safefs = require('safefs')

SafeFS uses graceful-fs to wrap all of the standard file system methods to avoid EMFILE errors among other problems.

On-top of graceful-fs, SafeFS also adds additional wrapping on the following methods:

  • writeFile(path, data, options?, next) - ensure the full path exists before writing to it
  • appendFile(path, data, options?, next) - ensure the full path exists before writing to it
  • mkdir(path, mode?, next) - mode defaults to 0o777 & (~process.umask())
  • unlink(path, next) - checks if the file exists before removing it

SafeFS also define these additional methods:

  • ensurePath(path, options, next) - ensure the full path exists, equivalent to unix's mdir -p path
  • getParentPathSync(path) - returns the parent directory of the path

Alternatives

You should use these instead, which use and provide modern APIs while providing brilliant ecosystem support:

Install

npm

  • Install: npm install --save safefs
  • Import: import * as pkg from ('safefs')
  • Require: const pkg = require('safefs')

Editions

This package is published with the following editions:

  • safefs aliases safefs/source/index.js
  • safefs/source/index.js is ESNext source code for Node.js 4 || 6 || 8 || 10 || 12 || 14 || 16 || 18 || 20 || 21 with Require for modules

TypeScript

This project provides its type information via inline JSDoc Comments. To make use of this in TypeScript, set your maxNodeModuleJsDepth compiler option to 5 or thereabouts. You can accomplish this via your tsconfig.json file like so:

{
  "compilerOptions": {
    "maxNodeModuleJsDepth": 5
  }
}

History

Discover the release history by heading on over to the HISTORY.md file.

Backers

Code

Discover how to contribute via the CONTRIBUTING.md file.

Authors

Maintainers

Contributors

Finances

GitHub Sponsors donate button ThanksDev donate button Patreon donate button Liberapay donate button Buy Me A Coffee donate button Open Collective donate button crypto donate button PayPal donate button

Sponsors

  • Andrew Nesbitt — Software engineer and researcher
  • Balsa — We're Balsa, and we're building tools for builders.
  • Codecov — Empower developers with tools to improve code quality and testing.
  • Poonacha Medappa
  • Rob Morris
  • Sentry — Real-time crash reporting for your web apps, mobile apps, and games.
  • Syntax — Syntax Podcast

Donors

License

Unless stated otherwise all works are:

and licensed under:

更新履歴

History

v8.10.0 2024 January 2

v8.9.0 2023 December 29

v8.8.0 2023 December 29

v8.7.0 2023 December 27

v8.6.0 2023 December 6

v8.5.0 2023 November 25

v8.4.0 2023 November 21

v8.3.0 2023 November 15

v8.2.0 2023 November 13

v8.1.0 2023 November 13

  • Rename rmdir to rimraf to not conflict

v8.0.0 2023 November 13

  • Updated dependencies, base files, and editions using boundation
  • Minimum required Node.js version changed from node: >=14 to node: >=4 adapting to ecosystem changes
  • Added JSDoc comments
  • Added rmdir with fallbacks for old Node.js versions

v7.1.0 2023 November 13

v7.0.0 2023 November 2

  • Updated dependencies, base files, and editions using boundation
  • Updated license from MIT to Artistic-2.0
  • Minimum required node version changed from node: >=10 to node: >=14 to keep up with mandatory ecosystem changes

v6.16.0 2021 July 31

v6.15.0 2021 July 28

v6.14.0 2020 October 29

v6.13.0 2020 September 5

v6.12.0 2020 August 18

v6.11.0 2020 August 4

v6.10.0 2020 July 23

v6.9.0 2020 June 25

v6.8.0 2020 June 22

v6.7.0 2020 June 21

v6.6.0 2020 June 20

v6.5.0 2020 June 11

v6.4.0 2020 June 10

v6.3.0 2020 May 22

v6.2.0 2020 May 21

v6.1.0 2020 May 21

v6.0.0 2020 May 11

  • Updated dependencies, base files, and editions using boundation
  • Minimum required node version changed from node: >=8 to node: >=10 to keep up with mandatory ecosystem changes

v5.5.0 2019 December 10

v5.4.0 2019 December 1

v5.3.0 2019 December 1

v5.2.0 2019 November 18

v5.1.0 2019 November 13

v5.0.0 2019 November 13

  • Updated dependencies, base files, and editions using boundation
  • Minimum required node version changed from node: >=0.12 to node: >=8 to keep up with mandatory ecosystem changes

v4.2.0 2019 November 13

v4.1.0 2016 May 28

v4.0.1 2015 December 10

  • Updated internal conventions

v4.0.0 2015 September 5

  • Dropped node <0.12 support

v3.2.2 2015 September 5

  • Use any version of graceful-fs to fix possible compat issues with node <0.10 support

v3.2.1 2015 September 5

  • Fixed node <0.10 support (regression since v3.2.0) - Unfortunately our dev dependencies don't support this early, so no travis ci tests, manual tests pass

v3.2.0 2015 September 5

  • Moved from CoffeeScript to ES6+
  • Removed cyclic.js as it should no longer be needed
  • Added tests... finally...

v3.1.3 2015 March 18

  • Updated dependencies

v3.1.2 2014 December 12

  • Updated dependencies

v3.1.1 2014 February 5

v3.1.0 2013 December 9

  • We no longer use our internal queue and now just rely on the graceful-fs queue
  • We now alias all the other standard file system methods onto our own object

v3.0.6 2013 November 25

  • Only unlink if the file exists

v3.0.5 2013 November 17

  • Use graceful-fs under the hood, along with our limiting abilities to help avoid even more problems
  • Updated dependencies

v3.0.4 2013 November 6

  • Repackaged
  • Updated dependencies

v3.0.3 2013 August 29

v3.0.2 2013 August 29

  • Updated dependencies

v3.0.1 2013 April 5

  • Updated dependencies

v3.0.0 2013 April 5

  • Rewrote to use TaskGroup instead of the manual queue + setTimeout approach we were using before

v2.0.3 2013 April 1

  • Added missing ensurePath and getParentPathSync

v2.0.2 2013 April 1

  • Added missing ensurePath and getParentPathSync

v2.0.1 2013 March 29

  • Fixed readme code block

v2.0.0 2013 March 29