Socket
Socket
Sign inDemoInstall

read-dir-files

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

read-dir-files

Recursively read files from a directory


Version published
Maintainers
1
Created
Source

read-dir-files Build Status

Module for recursively (and non-recursively) reading all files in a directory.

Installation

npm install read-dir-files

Usage

  var readDirFiles = require('read-dir-files');

  readDirFiles.list('directory', function (err, filenames) {
    if (err) return console.dir(err);
    console.dir(filenames);
  });

  readDirFiles.read('directory', function (err, files) {
    if (err) return console.dir(err);
    console.dir(files);
  });

readDirFiles.read(dir, encoding, recursive, callback)

Parameters:

  • dir Directory to read files from
  • encoding Files encoding. Optional.
  • recursive Recurse into subdirectories? Optional, default true.
  • callback Callback. Optional.

Asynchronously reads all files from dir and returns them to the callback in form:

{
   dir: {
     file0: <Buffer ...>,
     file1: <Buffer ...>,
     sub: {
      file0: <Buffer ...>
    }
  }
}

If you pass it the encoding, instead of buffers you'll get strings.

readDirFiles.list(dir, options, callback)

Parameters:

  • dir Directory to read filenames from
  • options Files encoding. Optional.
    • options.recursive Recurses subdirectories.
    • options.normalize Normalizes filenames.
  • recursive Recurse into subdirectories? Optional, default true.
  • callback Callback. Optional.

Asynchronously reads all filenames from dir and returns them to the callback in form:

[
  'dir',
  'file0',
  'file1'
]

Keywords

FAQs

Package last updated on 12 May 2012

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