0.2.2 • Published 2 years ago

readdirp-async v0.2.2

Weekly downloads
7
License
-
Repository
github
Last release
2 years ago

readdirp-async

Yet another "readdirp" implementation that's an async generator.

Install

npm install readdirp-async

API

import r from 'readdirp-async'

r(path, opts)

  • path <string> Root path to start reading dir
  • [opts.depth] [number] Depth to scan down to

for await(const output of r(…))

  • output.path [string] Path of the descendant
  • output.dirent [dirent] instance
  • output.depth [number] Current depth
  • output.parent [string] Parent path

r(…).next(input)

  • input.skip [boolean] Skip current directory (and all its descendants)
  • You can also assign these to output

Example

const r = require('readdirp-async')

for await(const o of r(__dirname)) {
  if (o.path.includes('node_modules')) {
    // Skip commonly ignored directories and their contents
    o.skip = true
    continue;
  } else {
    // do any operations
    await fs.copy(o.item, …)
  }
}