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

bal-util

Package Overview
Dependencies
Maintainers
1
Versions
118
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bal-util - npm Package Compare versions

Comparing version 2.4.3 to 2.5.0

4

HISTORY.md
# History
## v2.5.0 December 17, 2014
- Abstracted out `balUtilPaths.scandir` to [scandirectory](https://github.com/bevry/scandirectory)
- Removed `balUtilPaths.rmdirDeep` in favour of [rimraf](https://github.com/isaacs/rimraf)
## v2.4.3 December 12, 2014

@@ -4,0 +8,0 @@ - Fixed flow (regression since v2.4.2)

232

out/lib/paths.js
// Generated by CoffeeScript 1.8.0
(function() {
var TaskGroup, balUtilFlow, balUtilPaths, eachr, extendr, extractOptsAndCallback, ignorefs, pathUtil, safefs, typeChecker,
__slice = [].slice,
__hasProp = {}.hasOwnProperty;
var TaskGroup, balUtilFlow, balUtilPaths, eachr, extendr, extractOptsAndCallback, ignorefs, pathUtil, safefs, scandir, typeChecker,
__slice = [].slice;

@@ -25,2 +24,4 @@ pathUtil = require('path');

scandir = require('scandirectory');
balUtilPaths = {

@@ -89,3 +90,3 @@ resolveCaseSensitivePath: function(path, next) {

scanlist: function(path, next) {
balUtilPaths.scandir({
scandir({
path: path,

@@ -101,3 +102,3 @@ readFiles: true,

scantree: function(path, next) {
balUtilPaths.scandir({
scandir({
path: path,

@@ -112,193 +113,2 @@ readFiles: true,

},
scandir: function() {
var args, err, list, next, opts, tree;
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
list = {};
tree = {};
if (args.length === 1) {
opts = args[0];
} else if (args.length >= 4) {
opts = {
path: args[0],
fileAction: args[1] || null,
dirAction: args[2] || null,
next: args[3] || null
};
} else {
err = new Error('balUtilPaths.scandir: unsupported arguments');
throw err;
}
if (opts.recurse == null) {
opts.recurse = true;
}
if (opts.readFiles == null) {
opts.readFiles = false;
}
if (opts.ignorePaths == null) {
opts.ignorePaths = false;
}
if (opts.ignoreHiddenFiles == null) {
opts.ignoreHiddenFiles = false;
}
if (opts.ignoreCommonPatterns == null) {
opts.ignoreCommonPatterns = false;
}
if (opts.next == null) {
opts.next = function(err) {
if (err) {
throw err;
}
};
}
next = opts.next;
if (opts.action != null) {
if (opts.fileAction == null) {
opts.fileAction = opts.action;
}
if (opts.dirAction == null) {
opts.dirAction = opts.action;
}
}
if (opts.parentPath && !opts.path) {
opts.path = opts.parentPath;
}
if (!opts.path) {
err = new Error('balUtilPaths.scandir: path is needed');
return next(err);
}
safefs.readdir(opts.path, function(err, files) {
var tasks;
if (err) {
return next(err);
}
if (files.length === 0) {
return next(null, list, tree);
}
tasks = new TaskGroup({
concurrency: 0
}).done(function(err) {
return opts.next(err, list, tree);
});
files.forEach(function(file) {
return tasks.addTask(function(complete) {
var fileFullPath, fileRelativePath, isIgnoredFile;
fileFullPath = pathUtil.join(opts.path, file);
fileRelativePath = opts.relativePath ? pathUtil.join(opts.relativePath, file) : file;
isIgnoredFile = ignorefs.isIgnoredPath(fileFullPath, {
ignorePaths: opts.ignorePaths,
ignoreHiddenFiles: opts.ignoreHiddenFiles,
ignoreCommonPatterns: opts.ignoreCommonPatterns,
ignoreCustomPatterns: opts.ignoreCustomPatterns
});
if (isIgnoredFile) {
return complete();
}
return balUtilPaths.isDirectory(fileFullPath, function(err, isDirectory, fileStat) {
var handle;
if (err) {
return complete(err);
}
if (tasks.paused) {
return complete();
}
if (isDirectory) {
handle = function(err, skip, subtreeCallback) {
if (err) {
return complete(err);
}
if (tasks.paused) {
return complete();
}
if (skip) {
return complete();
}
list[fileRelativePath] = 'dir';
tree[file] = {};
if (!opts.recurse) {
return complete();
}
return balUtilPaths.scandir({
path: fileFullPath,
relativePath: fileRelativePath,
fileAction: opts.fileAction,
dirAction: opts.dirAction,
readFiles: opts.readFiles,
ignorePaths: opts.ignorePaths,
ignoreHiddenFiles: opts.ignoreHiddenFiles,
ignoreCommonPatterns: opts.ignoreCommonPatterns,
ignoreCustomPatterns: opts.ignoreCustomPatterns,
recurse: opts.recurse,
stat: opts.fileStat,
next: function(err, _list, _tree) {
var filePath, fileType;
tree[file] = _tree;
for (filePath in _list) {
if (!__hasProp.call(_list, filePath)) continue;
fileType = _list[filePath];
list[filePath] = fileType;
}
if (err) {
return complete(err);
}
if (tasks.paused) {
return complete();
}
if (subtreeCallback) {
return subtreeCallback(complete);
}
return complete();
}
});
};
if (opts.dirAction) {
return opts.dirAction(fileFullPath, fileRelativePath, handle, fileStat);
} else if (opts.dirAction === false) {
return handle(err, true);
} else {
return handle(err, false);
}
} else {
handle = function(err, skip) {
if (err) {
return complete(err);
}
if (tasks.paused) {
return complete();
}
if (skip) {
return complete();
}
if (opts.readFiles) {
return safefs.readFile(fileFullPath, function(err, data) {
if (err) {
return complete(err);
}
if (opts.readFiles !== 'binary') {
data = data.toString();
}
list[fileRelativePath] = data;
tree[file] = data;
return complete();
});
} else {
list[fileRelativePath] = 'file';
tree[file] = true;
return complete();
}
};
if (opts.fileAction) {
return opts.fileAction(fileFullPath, fileRelativePath, handle, fileStat);
} else if (opts.fileAction === false) {
return handle(err, true);
} else {
return handle(err, false);
}
}
});
});
});
return tasks.run();
});
return this;
},
cpdir: function() {

@@ -346,3 +156,3 @@ var args, err, next, opt, opts, outPath, scandirOpts, srcPath, _i, _len, _ref;

}
balUtilPaths.scandir(scandirOpts);
scandir(scandirOpts);
return this;

@@ -398,31 +208,5 @@ },

}
balUtilPaths.scandir(scandirOpts);
scandir(scandirOpts);
return this;
},
rmdirDeep: function(parentPath, next) {
safefs.exists(parentPath, function(exists) {
if (!exists) {
return next();
}
return balUtilPaths.scandir(parentPath, function(fileFullPath, fileRelativePath, next) {
return safefs.unlink(fileFullPath, function(err) {
return next(err);
});
}, function(fileFullPath, fileRelativePath, next) {
return next(null, false, function(next) {
return balUtilPaths.rmdirDeep(fileFullPath, function(err) {
return next(err);
});
});
}, function(err, list, tree) {
if (err) {
return next(err, list, tree);
}
return safefs.rmdir(parentPath, function(err) {
return next(err, list, tree);
});
});
});
return this;
},
writetree: function(dstPath, tree, next) {

@@ -429,0 +213,0 @@ safefs.ensurePath(dstPath, function(err) {

{
"title": "[Benjamin Lupton's](http://balupton.com) Utility Functions",
"name": "bal-util",
"version": "2.4.3",
"version": "2.5.0",
"description": "Common utility functions for Node.js used and maintained by Benjamin Lupton",

@@ -70,10 +70,12 @@ "homepage": "https://github.com/balupton/bal-util",

"extract-opts": "^2.2.0",
"ignorefs": "^1.0.0"
"ignorefs": "^1.0.0",
"scandirectory": "~2.5.0"
},
"devDependencies": {
"chai": "~1.10.0",
"coffee-script": "~1.8.0",
"joe": "~1.5.0",
"joe-reporter-console": "~1.2.1",
"chai": "~1.10.0",
"projectz": "~0.3.17"
"projectz": "~0.3.17",
"rimraf": "^2.2.8"
},

@@ -80,0 +82,0 @@ "directories": {

@@ -43,3 +43,3 @@

- Install: `npm install --save bal-util`
- CDN URL: `//wzrd.in/bundle/bal-util@2.4.3`
- CDN URL: `//wzrd.in/bundle/bal-util@2.5.0`

@@ -58,4 +58,4 @@ ### [Ender](http://ender.jit.su/)

## Future
We're in the process of abstracting the pieces of bal-util out into their own modules. So far, we've done the following:
## Abstraction
We're working to breaking out every part of bal-util into their own modules, or to use existing modules where there is now a more abstract version. Below are the list of the following abstractions that have been made:

@@ -72,5 +72,7 @@ - [ambi](https://github.com/bevry/ambi) < `balUtilFlow.fireWithOptionalCallback`

- [istextorbinary](https://github.com/bevry/istextorbinary) < `balUtilPaths.(isTextSync|isText|getEncodingSync|getEncoding)`
- [rimraf](https://github.com/isaacs/rimraf) < `balUtilPaths.rmdirDeep`
- [safecallback](https://github.com/bevry/safecallback) < `balUtilFlow.safeCallback`
- [safefs](https://github.com/bevry/safefs) < `balUtilPaths.(openFile|closeFile|etc)`
- [safeps](https://github.com/bevry/safeps) < `balUtilModules`
- [scandirectory](https://github.com/bevry/scandirectory) < `balUtilPaths.scandir`
- [taskgroup](https://github.com/bevry/taskgroup) < `balUtilFlow.Group`

@@ -77,0 +79,0 @@ - [textextensions](https://github.com/bevry/textextensions) < `balUtilPaths.textExtensions`

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