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

readdirp

Package Overview
Dependencies
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

readdirp - npm Package Compare versions

Comparing version 2.0.1 to 2.1.0

14

package.json

@@ -5,3 +5,3 @@ {

"description": "Recursive version of fs.readdir with streaming api.",
"version": "2.0.1",
"version": "2.1.0",
"homepage": "https://github.com/thlorenz/readdirp",

@@ -28,7 +28,7 @@ "repository": {

"test-main": "(cd test && set -e; for t in ./*.js; do node $t; done)",
"test-0.8": "nave use 0.8 npm run test-main",
"test-0.10": "nave use 0.10 npm run test-main",
"test-0.12": "nave use 0.12 npm run test-main",
"test-2.4": "nave use 2.4 npm run test-main",
"test-all": "npm run test-main && npm run test-0.8 && npm run test-0.10 && npm run test-0.12 && npm run test-2.4",
"test-4": "nave use 4.4 npm run test-main",
"test-6": "nave use 6.2 npm run test-main",
"test-all": "npm run test-main && npm run test-0.10 && npm run test-0.12 && npm run test-4 && npm run test-6",
"test": "if [ -e $TRAVIS ]; then npm run test-all; else npm run test-main; fi"

@@ -39,7 +39,9 @@ },

"minimatch": "^3.0.2",
"readable-stream": "^2.0.2"
"readable-stream": "^2.0.2",
"set-immediate-shim": "^1.0.1"
},
"devDependencies": {
"nave": "^0.5.1",
"tap": "^1.3.2",
"proxyquire": "^1.7.9",
"tap": "1.3.2",
"through2": "^2.0.0"

@@ -46,0 +48,0 @@ },

@@ -7,4 +7,6 @@ 'use strict';

, toString = Object.prototype.toString
, si = require('set-immediate-shim')
;
// Standard helpers

@@ -49,2 +51,3 @@ function isFunction (obj) {

, aborted = false
, paused = false
;

@@ -62,2 +65,4 @@

stream.on('close', function () { aborted = true; });
stream.on('pause', function () { paused = true; });
stream.on('resume', function () { paused = false; });
} else {

@@ -205,3 +210,10 @@ handleError = function (err) { errors.push(err); };

function readdirRec(currentDir, depth, callCurrentDirProcessed) {
var args = arguments;
if (aborted) return;
if (paused) {
si(function () {
readdirRec.apply(null, args);
})
return;
}

@@ -208,0 +220,0 @@ fs.readdir(currentDir, function (err, entries) {

'use strict';
var si = typeof setImmediate !== 'undefined' ? setImmediate : function (fn) { setTimeout(fn, 0) };
var si = require('set-immediate-shim');
var stream = require('readable-stream');

@@ -18,3 +17,3 @@ var util = require('util');

opts = opts || {};
opts.objectMode = true;

@@ -75,3 +74,3 @@ Readable.call(this, opts);

var self = this;
si(function () {
si(function () {
if (self._paused) return self._warnings.push(err);

@@ -84,3 +83,3 @@ if (!self._destroyed) self.emit('warn', err);

var self = this;
si(function () {
si(function () {
if (self._paused) return self._errors.push(err);

@@ -94,3 +93,3 @@ if (!self._destroyed) self.emit('error', err);

return {
return {
stream : stream

@@ -97,0 +96,0 @@ , processEntry : stream._processEntry.bind(stream)

@@ -11,2 +11,3 @@ /*jshint asi:true */

, through = require('through2')
, proxyquire = require('proxyquire')
, streamapi = require('../stream-api')

@@ -220,3 +221,2 @@ , readdirp = require('..')

t.test('\n# handleError', function (t) {

@@ -269,3 +269,31 @@ t.plan(1);

t.test('\n# when a stream is paused it stops walking the fs', function (t) {
var resumed = false,
mockedAPI = streamapi();
mockedAPI.processEntry = function (entry) {
if (!resumed) t.notOk(true, 'should not emit while paused')
t.ok(entry, 'emitted while resumed')
}.bind(mockedAPI.stream)
function wrapper () {
return mockedAPI
}
var readdirp = proxyquire('../readdirp', {'./stream-api': wrapper})
, stream = readdirp(opts())
.on('error', function (err) {
t.fail('should not throw error', err);
})
.on('end', function () {
t.end()
})
.pause();
setTimeout(function () {
resumed = true;
stream.resume();
}, 5)
})
t.test('\n# when a stream is destroyed, it emits "closed", but no longer emits "data", "warn" and "error"', function (t) {

@@ -272,0 +300,0 @@ var api = streamapi()

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