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

recursive-readdir-filter

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

recursive-readdir-filter

Get an array of all files in a directory and subdirectories. Supports filters.

  • 0.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

#recursive-readdir-filter

This is a fork of https://github.com/jergason/recursive-readdir.

It adds support for filtering files and folders.


A simple Node module for recursively listing all files in a directory, or in any subdirectories.

It does not list directories themselves.

Installation

npm install recursive-readdir-filter

Usage

Just like recursive-readdir

var recursive-readdir = require('recursive-readdir-filter');

recursive-readdir('some/path', function (err, files) {
  // Files is an array of filename
  console.log(files);
});

But now with filters;

var options = {
    filterDir: function (stats) {
        return stats.name !== 'node_modules';
    },
    filterFile: function (stats) {
        return stats.name.match(/\.js$/);
    }
};

recursive-readdir('some/path', options, function (err, files) {
    console.log(files);
});

Options

Options are completly optional;

Both options must be a function. A Stats object is passed to them, but with some extra information added:

  • path: the full path to the file/folder. e.g. /Volumes/Home/foo.txt.
  • name: the name of file/folder. e.g foo.txt.
  • folder: the parent folder of the file/folder. e.g. /Volumes/Home.
{
  dev: 2114,
  ino: 48064969,
  mode: 33188,
  nlink: 1,
  uid: 85,
  gid: 100,
  rdev: 0,
  size: 527,
  blksize: 4096,
  blocks: 8,
  atime: Mon, 10 Oct 2011 23:24:11 GMT,
  mtime: Mon, 10 Oct 2011 23:24:11 GMT,
  ctime: Mon, 10 Oct 2011 23:24:11 GMT,
  name: 'a',
  path: '/Volumes/Home/Projects/recursive-readdir/test/testdir/a/a/'
  folder: '/Volumes/Home/Projects/recursive-readdir/test/testdir/a/'
}

filterDir

Is run whenever a folder is found.

filterFile

Is run whenever a file is found.

Keywords

FAQs

Package last updated on 08 Mar 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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