Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

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 - npm Package Compare versions

Comparing version 3.0.6 to 3.1.1

124

out/lib/safefs.js

@@ -1,4 +0,5 @@

// Generated by CoffeeScript 1.6.3
// Generated by CoffeeScript 1.7.1
(function() {
var TaskGroup, fsUtil, pathUtil, safefs, _base, _ref;
var fsUtil, key, pathUtil, safefs, value,
__hasProp = {}.hasOwnProperty;

@@ -9,22 +10,10 @@ fsUtil = require('graceful-fs');

TaskGroup = require('taskgroup').TaskGroup;
if (global.safefsGlobal == null) {
global.safefsGlobal = {};
}
if ((_base = global.safefsGlobal).pool == null) {
_base.pool = new TaskGroup().setConfig({
concurrency: (_ref = process.env.NODE_MAX_OPEN_FILES) != null ? _ref : 100,
pauseOnError: false
}).run();
}
safefs = {
openFile: function(fn) {
global.safefsGlobal.pool.addTask(fn);
console.log('safefs.openFile has been deprecated, we now do the opening and closing automatically through the graceful-fs module');
fn();
return safefs;
},
closeFile: function() {
console.log('safefs.closeFile has been deprecated, please use the safefs.openFile completion callback to close files');
console.log('safefs.closeFile has been deprecated, we now do the opening and closing automatically through the graceful-fs module');
return safefs;

@@ -71,15 +60,2 @@ },

},
readFile: function(path, options, next) {
if (next == null) {
next = options;
options = null;
}
safefs.openFile(function(closeFile) {
return fsUtil.readFile(path, options, function(err, data) {
closeFile();
return next(err, data);
});
});
return safefs;
},
writeFile: function(path, data, options, next) {

@@ -94,8 +70,3 @@ if (next == null) {

}
return safefs.openFile(function(closeFile) {
return fsUtil.writeFile(path, data, options, function(err) {
closeFile();
return next(err);
});
});
return fsUtil.writeFile(path, data, options, next);
});

@@ -113,8 +84,3 @@ return safefs;

}
return safefs.openFile(function(closeFile) {
return fsUtil.appendFile(path, data, options, function(err) {
closeFile();
return next(err);
});
});
return fsUtil.appendFile(path, data, options, next);
});

@@ -131,37 +97,5 @@ return safefs;

}
safefs.openFile(function(closeFile) {
return fsUtil.mkdir(path, mode, function(err) {
closeFile();
return next(err);
});
});
fsUtil.mkdir(path, mode, next);
return safefs;
},
lstat: function(path, next) {
safefs.openFile(function(closeFile) {
return fsUtil.lstat(path, function(err, stat) {
closeFile();
return next(err, stat);
});
});
return safefs;
},
stat: function(path, next) {
safefs.openFile(function(closeFile) {
return fsUtil.stat(path, function(err, stat) {
closeFile();
return next(err, stat);
});
});
return safefs;
},
readdir: function(path, next) {
safefs.openFile(function(closeFile) {
return fsUtil.readdir(path, function(err, files) {
closeFile();
return next(err, files);
});
});
return safefs;
},
unlink: function(path, next) {

@@ -172,41 +106,27 @@ safefs.exists(path, function(exists) {

}
return safefs.openFile(function(closeFile) {
return fsUtil.unlink(path, function(err) {
closeFile();
return next(err);
});
});
return fsUtil.unlink(path, next);
});
return safefs;
},
rmdir: function(path, next) {
safefs.openFile(function(closeFile) {
return fsUtil.rmdir(path, function(err) {
closeFile();
return next(err);
});
});
return safefs;
},
exists: function(path, next) {
var exists;
exists = fsUtil.exists || pathUtil.exists;
safefs.openFile(function(closeFile) {
return exists(path, function(exists) {
closeFile();
return next(exists);
});
});
(fsUtil.exists || pathUtil.exists)(path, next);
return safefs;
},
existsSync: function(path) {
var existsSync, result;
existsSync = fsUtil.existsSync || pathUtil.existsSync;
result = existsSync(path);
return result;
return (fsUtil.existsSync || pathUtil.existsSync)(path);
}
};
for (key in fsUtil) {
if (!__hasProp.call(fsUtil, key)) continue;
value = fsUtil[key];
if ((value != null ? value.bind : void 0) === Function.prototype.bind) {
if (safefs[key] == null) {
safefs[key] = value.bind(fsUtil);
}
}
}
module.exports = safefs;
}).call(this);

20

package.json
{
"title": "Safe FS",
"name": "safefs",
"version": "3.0.6",
"version": "3.1.1",
"description": "Stop getting EMFILE errors! Open only as many files as the operating system supports.",

@@ -13,5 +13,8 @@ "homepage": "https://github.com/bevry/safefs",

"npm": true,
"david": true,
"daviddev": true,
"gittip": "bevry",
"flattr": "344188/balupton-on-Flattr",
"paypal": "QB8GQPZAH84N6"
"paypal": "QB8GQPZAH84N6",
"bitcoin": "https://coinbase.com/checkouts/9ef59f5479eec1d97d63382c9ebcb93a"
},

@@ -32,3 +35,4 @@ "keywords": [

"jagill (https://github.com/jagill)",
"sfrdmn (https://github.com/sfrdmn)"
"sfrdmn (https://github.com/sfrdmn)",
"shama (https://github.com/shama)"
],

@@ -46,11 +50,7 @@ "bugs": {

"dependencies": {
"taskgroup": "~3.3.1",
"graceful-fs": "~2.0.1"
},
"devDependencies": {
"coffee-script": "~1.6.2",
"joe": "~1.3.2",
"joe-reporter-console": "~1.2.1",
"chai": "~1.8.1",
"projectz": "~0.2.6"
"coffee-script": "~1.7.1",
"projectz": "~0.3.9"
},

@@ -62,5 +62,5 @@ "directories": {

"preinstall": "node ./cyclic.js",
"test": "node ./out/test/safefs-test.js"
"test": "echo 'no tests yet'"
},
"main": "./out/lib/safefs.js"
}

@@ -13,5 +13,8 @@

[![NPM version](http://badge.fury.io/js/safefs.png)](https://npmjs.org/package/safefs "View this project on NPM")
[![Dependency Status](https://david-dm.org/bevry/safefs.png?theme=shields.io)](https://david-dm.org/bevry/safefs)
[![Development Dependency Status](https://david-dm.org/bevry/safefs/dev-status.png?theme=shields.io)](https://david-dm.org/bevry/safefs#info=devDependencies)<br/>
[![Gittip donate button](http://img.shields.io/gittip/bevry.png)](https://www.gittip.com/bevry/ "Donate weekly to this project using Gittip")
[![Flattr donate button](http://img.shields.io/flattr/donate.png?color=yellow)](http://flattr.com/thing/344188/balupton-on-Flattr "Donate monthly to this project using Flattr")
[![PayPayl donate button](http://img.shields.io/paypal/donate.png?color=yellow)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=QB8GQPZAH84N6 "Donate once-off to this project using Paypal")
[![BitCoin donate button](http://img.shields.io/bitcoin/donate.png?color=yellow)](https://coinbase.com/checkouts/9ef59f5479eec1d97d63382c9ebcb93a "Donate once-off to this project using BitCoin")

@@ -32,10 +35,6 @@ <!-- /BADGES -->

### [Node](http://nodejs.org/), [Browserify](http://browserify.org/)
### [Node](http://nodejs.org/)
- Use: `require('safefs')`
- Install: `npm install --save safefs`
### [Ender](http://ender.jit.su/)
- Use: `require('safefs')`
- Install: `ender add safefs`
<!-- /INSTALL -->

@@ -50,34 +49,22 @@

The following [file system](http://nodejs.org/docs/latest/api/all.html#all_file_system) methods are available (but wrapped in safe way to prevent EMFILE errors):
SafeFS uses [graceful-fs](https://npmjs.org/package/graceful-fs) to wrap all of the standard [file system](http://nodejs.org/docs/latest/api/all.html#all_file_system) methods to avoid EMFILE errors among other problems.
- `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
Ontop 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())`
- `stat(path, next)`
- `readdir(path, next)`
- `unlink(path, next)`
- `rmdir(path, next)`
- `exists(path, next)`
- `unlink(path, next)` - checks if the file exists before removing it
- `exists(path, next)` - node <v0.6 and >=v0.6 compatibility
- `existsSync(path)` - node <v0.6 and >=v0.6 compatibility
For other file system interaction, you can do the following:
SafeFS also define these additional methods:
``` javascript
// 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();
});
});
```
- `ensurePath(path, options, next)` - ensure the full path exists, equivalant to unix's `mdir -p path`
To make this possible we define a global variable called `safefsGlobal` that manages the available slots for interacting with the file system.
<!-- HISTORY/ -->
## History
[Discover the change history by heading on over to the `History.md` file.](https://github.com/bevry/safefs/blob/master/History.md#files)
[Discover the change history by heading on over to the `HISTORY.md` file.](https://github.com/bevry/safefs/blob/master/HISTORY.md#files)

@@ -91,3 +78,3 @@ <!-- /HISTORY -->

[Discover how you can contribute by heading on over to the `Contributing.md` file.](https://github.com/bevry/safefs/blob/master/Contributing.md#files)
[Discover how you can contribute by heading on over to the `CONTRIBUTING.md` file.](https://github.com/bevry/safefs/blob/master/CONTRIBUTING.md#files)

@@ -114,2 +101,3 @@ <!-- /CONTRIBUTE -->

[![PayPayl donate button](http://img.shields.io/paypal/donate.png?color=yellow)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=QB8GQPZAH84N6 "Donate once-off to this project using Paypal")
[![BitCoin donate button](http://img.shields.io/bitcoin/donate.png?color=yellow)](https://coinbase.com/checkouts/9ef59f5479eec1d97d63382c9ebcb93a "Donate once-off to this project using BitCoin")

@@ -120,7 +108,8 @@ ### Contributors

- Benjamin Lupton <b@lupton.cc> (https://github.com/balupton) - [view contributions](https://github.com/bevry/safefs/commits?author=balupton)
- jagill (https://github.com/jagill) - [view contributions](https://github.com/bevry/safefs/commits?author=jagill)
- sfrdmn (https://github.com/sfrdmn) - [view contributions](https://github.com/bevry/safefs/commits?author=sfrdmn)
- [Benjamin Lupton](https://github.com/balupton) <b@lupton.cc> — [view contributions](https://github.com/bevry/safefs/commits?author=balupton)
- [jagill](https://github.com/jagill) — [view contributions](https://github.com/bevry/safefs/commits?author=jagill)
- [sfrdmn](https://github.com/sfrdmn) — [view contributions](https://github.com/bevry/safefs/commits?author=sfrdmn)
- [shama](https://github.com/shama) — [view contributions](https://github.com/bevry/safefs/commits?author=shama)
[Become a contributor!](https://github.com/bevry/safefs/blob/master/Contributing.md#files)
[Become a contributor!](https://github.com/bevry/safefs/blob/master/CONTRIBUTING.md#files)

@@ -127,0 +116,0 @@ <!-- /BACKERS -->

Sorry, the diff of this file is not supported yet

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