Socket
Socket
Sign inDemoInstall

safefs

Package Overview
Dependencies
Maintainers
1
Versions
112
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

safefs

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


Version published
Weekly downloads
144K
increased by0.43%
Maintainers
1
Weekly downloads
 
Created
Source

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

  1. Install Node.js
  2. npm install --save 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

You can discover the history inside the History.md file

License

Licensed under the incredibly permissive MIT License
Copyright © 2013+ Bevry Pty Ltd
Copyright © 2011-2012 Benjamin Arthur Lupton

Keywords

FAQs

Package last updated on 29 Aug 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc