@finwo/scandir

0.0.3 • Public • Published

scandir

Simple scandir for my own purposes, as I've used versions of this throughout multiple projects.

Usage

const scandir = require('@finwo/scandir');

// No way to await in async yet
scandir("path/to/directory", filename => {
  console.log(`Got a filename: ${filename}`);
}, ['json', 'js']);

// You can also load files directly (caution, may be dangerous)
// This loads the file through 'require'
scandir("path/to/directory", contents => {
  console.log(`Got file contents: ${contents}`);
}, ['json','js'], true);

// There's also a sync version, if that's what you need
// This accepts the same arguments
scandir.sync("path/to/directory", filename => {
  console.log(`Got a filename: ${filename}`);
}, ['json', 'js'], false);

Methods

scandir( dir, handler, extensions = ['json','js'], load = false)

scandir.sync( dir, handler, extensions = ['json','js'], load = false)

Readme

Keywords

none

Package Sidebar

Install

npm i @finwo/scandir

Weekly Downloads

0

Version

0.0.3

License

MIT

Unpacked Size

3.26 kB

Total Files

4

Last publish

Collaborators

  • finwo