
Product
Rust Support in Socket Is Now Generally Available
Socket’s Rust and Cargo support is now generally available, providing dependency analysis and supply chain visibility for Rust projects.
read-directory
Advanced tools
Read a directory of files.
npm install --save read-directory
var read = require('read-directory')
read('./files', function (err, contents) {
console.log(contents)
})
var read = require('read-directory')
var contents = read.sync('./files')
Use the included browserify transform module to convert calls to read.sync to the contents of the directory.
Note that to use the browserify transform you must use read.sync, and the path to the file directory can not be a variable.
var path = require('path')
var read = require('read-directory')
var contents = read.sync(path.join(__dirname, 'files'))
browserify index.js -t read-directory -o bundle.js
budo index.js:bundle.js -- -t read-directory
Read the contents of a directory asynchronously
Parameters
dir String – The directory to readoptions Object
options.fs Object – alternate fs implementation, optionaloptions.dirnames Boolean – include or exclude subdirectory names in keys of returned objectoptions.encoding String – encoding of files, default: utf8options.filter String – glob pattern for filtering files, examples: *.md, *.cssoptions.ignore String – glob pattern for ignoring filesoptions.ignore Array – array of glob patterns for ignoring filesoptions.transform Function – A function you can use to transform the contents of files after they are readExamples
var read = require('read-directory')
read('./files', function (err, contents) {
console.log(contents)
})
Read the contents of a directory asynchronously
Parameters
dir String – The directory to readoptions Object
options.fs Object – alternate fs implementation, optionaloptions.dirnames Boolean – include or exclude subdirectory names in keys of returned objectoptions.encoding String – encoding of files, default: utf8options.filter String – glob pattern for filtering files, examples: *.md, *.cssoptions.ignore String – glob pattern for ignoring filesoptions.ignore Array – array of glob patterns for ignoring filesoptions.transform Function – A function you can use to transform the contents of files after they are readExamples
var read = require('read-directory')
var contents = read.sync('./files')
FAQs
Read a directory of files
The npm package read-directory receives a total of 1,846 weekly downloads. As such, read-directory popularity was classified as popular.
We found that read-directory demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?

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.

Product
Socket’s Rust and Cargo support is now generally available, providing dependency analysis and supply chain visibility for Rust projects.

Security News
Chrome 144 introduces the Temporal API, a modern approach to date and time handling designed to fix long-standing issues with JavaScript’s Date object.

Research
Five coordinated Chrome extensions enable session hijacking and block security controls across enterprise HR and ERP platforms.