JSPM

safefs

3.0.5
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 127532
  • Score
    100M100P100Q155925F
  • License

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

Package Exports

  • safefs

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (safefs) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Safe FS

Build Status NPM version Gittip donate button Flattr donate button PayPayl donate button

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

Install

Node, Browserify

  • Use: require('safefs')
  • Install: npm install --save safefs

Ender

  • Use: require('safefs')
  • Install: ender add safefs

Usage

var safefs = require('safefs');

The following file system methods are available (but wrapped in safe way to prevent EMFILE errors):

  • readFile(path, options?, next)
  • writeFile(path, data, options?, next) - will also attempt to ensure the path exists
  • appendFile(path, data, options?, next) - will also attempt to ensure the path exists
  • mkdir(path, mode?, next) - mode defaults to 0o777 & (~process.umask())
  • stat(path, next)
  • readdir(path, next)
  • unlink(path, next)
  • rmdir(path, next)
  • exists(path, next)

For other file system interaction, you can do the following:

// get a slot in the file system queue
require('safefs').openFile(function(closeFile){
    // do our file system interaction
    require('fs').someOtherMethod(a,b,c,function(err,a,b,c){
        // close the slot we are using in the file system queue
        closeFile();
    });
});

To make this possible we define a global variable called safefsGlobal that manages the available slots for interacting with the file system.

History

Discover the change history by heading on over to the History.md file.

Contribute

Discover how you can contribute by heading on over to the Contributing.md file.

Backers

Maintainers

These amazing people are maintaining this project:

Sponsors

No sponsors yet! Will you be the first?

Gittip donate button Flattr donate button PayPayl donate button

Contributors

These amazing people have contributed code to this project:

Become a contributor!

License

Licensed under the incredibly permissive MIT license

Copyright © 2013+ Bevry Pty Ltd us@bevry.me (http://bevry.me)
Copyright © 2011-2012 Benjamin Lupton b@lupton.cc (http://balupton.com)