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

fs-walk-breadth-first

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fs-walk-breadth-first - npm Package Compare versions

Comparing version 0.0.1 to 1.0.0

4

CHANGELOG.md

@@ -5,2 +5,6 @@ # Change Log

## [1.0.0] - 2015-07-15
### Changed
- Change iterator argument to be async, expecting its own callback
## [0.0.1] - 2015-07-07

@@ -7,0 +11,0 @@ ### Fixed

17

lib/walk.js

@@ -10,3 +10,7 @@ "use strict";

var isDirectory = R.pipe(R.lensIndex(1), R.invoker(0, "isDirectory"));
function walk(directory, iterator, finished) {
var walker = R.curry(walk)(R.__, iterator, R.__); // eslint-disable-line no-underscore-dangle
fs.readdir(directory, function(err, files) {

@@ -25,8 +29,9 @@ if (err) {

var pairs = R.zip(files, stats);
R.forEach(R.apply(iterator), pairs);
var isDirectory = R.pipe(R.lensIndex(1), R.invoker(0, "isDirectory"));
var dirs = R.map(R.lensIndex(0), R.filter(isDirectory, pairs));
async.each(dirs, function(dir, callback) {
walk(dir, iterator, callback);
}, finished);
async.each(pairs, function(pair, callback) {
pair.push(callback);
R.apply(iterator, pair);
}, function() {
var dirs = R.map(R.lensIndex(0), R.filter(isDirectory, pairs));
async.each(dirs, walker, finished);
});
});

@@ -33,0 +38,0 @@ });

{
"name": "fs-walk-breadth-first",
"version": "0.0.1",
"version": "1.0.0",
"description": "Call a function on each file in a filesystem tree",

@@ -37,3 +37,4 @@ "keywords": [

"tap-spec": "^4.0.2",
"tape": "^4.0.0"
"tape": "^4.0.0",
"tape-catch": "^1.0.4"
},

@@ -40,0 +41,0 @@ "dependencies": {

@@ -32,3 +32,3 @@ # node-fs-walk-breadth-first

* `directory` - The directory to traverse.
* `iterator(filename, stats)` - A function to apply to each file or directory found. `stats` is an instance of [fs.Stats](https://nodejs.org/api/fs.html#fs_class_fs_stats).
* `iterator(filename, stats, callback)` - A function to apply to each file or directory found. `stats` is an instance of [fs.Stats](https://nodejs.org/api/fs.html#fs_class_fs_stats). `callback(err)` should be called when the iterator is finished
* `callback(err)` - A function that is called when all the files and directories have been visited, or when an error occurs.

@@ -35,0 +35,0 @@

@@ -5,3 +5,3 @@ "use strict";

var mockFs = require("mock-fs");
var test = require("tape");
var test = require("tape-catch");

@@ -36,4 +36,5 @@ function setup(t, fakeFs) {

t.plan(2);
walk("folder", function(filename) {
walk("folder", function(filename, _, callback) {
t.equal(filename, "folder/file", "should return the file's path");
callback();
}, function(err) {

@@ -47,4 +48,5 @@ t.notOk(err, "should have no errors");

t.plan(3);
walk("folder", function(filename, stat) {
walk("folder", function(filename, stat, callback) {
t.equal(stat.isFile(), true, "should return a fs.Stats");
callback();
}, function(err) {

@@ -58,6 +60,7 @@ t.notOk(err, "should have no errors");

t.plan(2);
walk("folder1", function(filename, stat) {
walk("folder1", function(filename, stat, callback) {
if (filename === "folder1/folder2/file") {
t.ok(stat.isFile(), "should return a fs.Stats");
}
callback();
}, function(err) {

@@ -64,0 +67,0 @@ t.notOk(err, "should have no errors");

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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