Socket
Socket
Sign inDemoInstall

vow-fs

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vow-fs - npm Package Compare versions

Comparing version 0.2.3 to 0.3.0

127

lib/fs.js
/**
* Vow-fs
*
* Copyright (c) 2013 Filatov Dmitry (dfilatov@yandex-team.ru)
* @module vow-fs
* @author Filatov Dmitry <dfilatov@yandex-team.ru>
* @version 0.3.0
* @license
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*
* @version 0.2.3
* * http://www.opensource.org/licenses/mit-license.php
* * http://www.gnu.org/licenses/gpl.html
*/
var Vow = require('vow'),
var vow = require('vow'),
Queue = require('vow-queue'),

@@ -22,9 +21,9 @@ openFilesQueue = new Queue(),

return function() {
var promise = Vow.promise(),
var defer = vow.defer(),
args = slice.call(arguments);
args.push(function(err) {
err? promise.reject(err) : promise.fulfill(arguments[1]);
err? defer.reject(err) : defer.resolve(arguments[1]);
});
nodeFn.apply(fs, args);
return promise;
return defer.promise();
};

@@ -49,3 +48,3 @@ },

emfileTimeout++;
return Vow.delay(null, emfileTimeout).then(function() {
return vow.delay(null, emfileTimeout).then(function() {
return wrapper.apply(vfs, callArgs);

@@ -66,6 +65,6 @@ });

/**
* Read file by given path
* Reads file by given path
* @param {String} path
* @param {String} [encoding=utf8]
* @returns {Vow.promise}
* @returns {vow:Promise}
*/

@@ -75,7 +74,7 @@ read : emfileFixWrapper(promisify(fs.readFile)),

/**
* Write data to file by given path
* Writes data to file by given path
* @param {String} path
* @param {String|Buffer} data
* @param {String} [encoding=utf8]
* @returns {Vow.promise}
* @returns {vow:Promise}
*/

@@ -85,7 +84,7 @@ write : emfileFixWrapper(promisify(fs.writeFile)),

/**
* Append data to file by given path
* Appends data to file by given path
* @param {String} path
* @param {String|Buffer} data
* @param {String} [encoding=utf8]
* @returns {Vow.promise}
* @returns {vow:Promise}
*/

@@ -95,5 +94,5 @@ append : emfileFixWrapper(promisify(fs.appendFile)),

/**
* Remove file at given path
* Removes file at given path
* @param {String} pathToRemove
* @returns {Vow.promise}
* @returns {vow:Promise}
*/

@@ -103,6 +102,6 @@ remove : promisify(fs.unlink),

/**
* Copy file from sourcePath to targetPath
* Copies file from sourcePath to targetPath
* @param {String} sourcePath
* @param {String} targetPath
* @returns {Vow.promise}
* @returns {vow:Promise}
*/

@@ -119,6 +118,6 @@ copy : emfileFixWrapper(function(sourcePath, targetPath) {

var promise = Vow.promise(),
var defer = vow.defer(),
sourceStream = fs.createReadStream(sourcePath),
errFn = function(err) {
promise.reject(err);
defer.reject(err);
};

@@ -134,7 +133,7 @@

.on('close', function() {
promise.fulfill();
defer.resolve();
}));
});
return promise;
return defer.promise();
});

@@ -144,6 +143,6 @@ }, 2),

/**
* Move from sourcePath to targetPath
* Moves from sourcePath to targetPath
* @param {String} sourcePath
* @param {String} targetPath
* @returns {Vow.promise}
* @returns {vow:Promise}
*/

@@ -153,5 +152,5 @@ move : promisify(fs.rename),

/**
* Extract fs.Stats about a given path
* Extracts fs.Stats about a given path
* @param {String} path
* @returns {Vow.promise}
* @returns {vow:Promise}
*/

@@ -161,27 +160,27 @@ stat : promisify(fs.stat),

/**
* Test whether or not the given path exists
* Tests whether or not the given path exists
* @param {String} path
* @returns {Vow.promise}
* @returns {vow:Promise}
*/
exists : fs.exists?
function(path) {
var promise = Vow.promise();
var defer = vow.defer();
fs.exists(path, function(exists) {
promise.fulfill(exists);
defer.resolve(exists);
});
return promise;
return defer.promise();
} :
function(path) {
var promise = Vow.promise();
var defer = vow.defer();
fs.stat(path, function(err) {
promise.fulfill(!err);
defer.resolve(!err);
});
return promise;
return defer.promise();
},
/**
* Create a hard link from the sourcePath to targetPath
* Creates a hard link from the sourcePath to targetPath
* @param {String} sourcePath
* @param {String} targetPath
* @returns {Vow.promise}
* @returns {vow:Promise}
*/

@@ -191,7 +190,7 @@ link : promisify(fs.link),

/**
* Create a relative symbolic link from the sourcePath to targetPath
* Creates a relative symbolic link from the sourcePath to targetPath
* @param {String} sourcePath
* @param {String} targetPath
* @param {String} [type=file] can be either 'dir', 'file', or 'junction'
* @returns {Vow.promise}
* @returns {vow:Promise}
*/

@@ -201,7 +200,7 @@ symLink : promisify(fs.symlink),

/**
* Change the owner for a given path using Unix user-id and group-id numbers
* Changes the owner for a given path using Unix user-id and group-id numbers
* @param {String} path
* @param uid
* @param gid
* @returns {Vow.promise}
* @returns {vow:Promise}
*/

@@ -211,6 +210,6 @@ chown : promisify(fs.chown),

/**
* Change the Unix mode for a path. Returns a promise
* Changes the Unix mode for a path. Returns a promise
* @param {String} path
* @param mode
* @returns {Vow.promise}
* @returns {vow:Promise}
*/

@@ -222,3 +221,3 @@ chmod : promisify(fs.chmod),

* @param {String} path
* @returns {Vow.promise}
* @returns {vow:Promise}
*/

@@ -228,5 +227,5 @@ absolute : promisify(fs.realpath),

/**
* Check whether the given path is a file
* Checks whether the given path is a file
* @param {String} path
* @returns {Vow.promise}
* @returns {vow:Promise}
*/

@@ -240,5 +239,5 @@ isFile : function(path) {

/**
* Check whether the given path is a directory
* Checks whether the given path is a directory
* @param {String} path
* @returns {Vow.promise}
* @returns {vow:Promise}
*/

@@ -252,5 +251,5 @@ isDir : function(path) {

/**
* Check whether the given path is a socket
* Checks whether the given path is a socket
* @param {String} path
* @returns {Vow.promise}
* @returns {vow:Promise}
*/

@@ -264,5 +263,5 @@ isSocket : function(path) {

/**
* Check whether the given path is a symbolic link
* Checks whether the given path is a symbolic link
* @param {String} path
* @returns {Vow.promise}
* @returns {vow:Promise}
*/

@@ -276,3 +275,3 @@ isSymLink : function(path) {

/**
* Make a temporary file
* Makes a temporary file
* @param {Object} options

@@ -282,3 +281,3 @@ * @param {String} [options.prefix]

* @param {String} [options.ext=tmp]
* @returns {Vow.promise}
* @returns {vow:Promise}
*/

@@ -298,5 +297,5 @@ makeTmpFile : function(options) {

/**
* Read the contents of a directory by given path
* Reads the contents of a directory by given path
* @param {String} path
* @returns {Vow.promise}
* @returns {vow:Promise}
*/

@@ -306,7 +305,7 @@ listDir : emfileFixWrapper(promisify(fs.readdir)),

/**
* Make a directory at a given path, recursively creating any branches that doesn't exist
* Makes a directory at a given path, recursively creating any branches that doesn't exist
* @param {String} dirPath
* @param [mode=0777]
* @param [failIfExist=false]
* @returns {Vow.promise}
* @returns {vow:Promise}
*/

@@ -346,5 +345,5 @@ makeDir : function(dirPath, mode, failIfExist) {

/**
* Remove directory
* Removes directory
* @param {String} dirPath
* @returns {Vow.promise}
* @returns {vow:Promise}
*/

@@ -354,3 +353,3 @@ removeDir : function(dirPath) {

.then(function(list) {
return list.length && Vow.all(
return list.length && vow.all(
list.map(function(file) {

@@ -357,0 +356,0 @@ var fullPath = path.join(dirPath, file);

{
"name" : "vow-fs",
"version" : "0.2.3",
"version" : "0.3.0",
"description" : "File I/O by Vow",

@@ -18,9 +18,9 @@ "homepage" : "https://github.com/dfilatov/vow-fs",

"node-uuid" : "1.4.0",
"vow-queue" : "0.0.2"
"vow-queue" : "0.1.0"
},
"peerDependencies": {
"vow" : ">= 0.3.9"
"vow" : ">= 0.4.0"
},
"devDependencies": {
"vow" : ">= 0.3.9",
"vow" : ">= 0.4.0",
"nodeunit" : "",

@@ -27,0 +27,0 @@ "istanbul" : ""

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