readdir-filter
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

like fs.readdir but with a filter function:

example usage:

typescript usage:

 
import { readdirFilter } from 'readdir-filter'
// only retrieve directories that start with an alpha
readdirFilter(some_path, ()
  (file_name: string, stats: fs.Stats) =>
    stats.isDirectory() // is a directory
    && fie_name.match(/^[a-z]/i)) // starts with an alpha
    ).then(alpha_dirsstring[]) => {
    // do stuff w/ alpha_dirs here
}, (ex) { throw ex })
 

javascript usage:

 
const readdirFilter = require('readdir-filter').default
readdirFilter('tests/', (
  (fso_name, stats) =>
    fso_name.match(/^[a-z]i/) // starts with an alpha
    && stats.isDirectory()()) // is a directory
  ).then((alpha_dirs_arr) => {
    // do stuff w/ alpha_dirs here
  }, (ex) => { throw ex })

Package Sidebar

Install

npm i readdir-filter

Weekly Downloads

0

Version

1.0.2

License

MIT

Last publish

Collaborators

  • gforceg