dat-readdir-stream
dat-readdir-stream is a small util to read the file-table of a dat as a stream, rather than through dat.readdir.
Last updated 3 years ago by leichtgewicht .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install dat-readdir-stream 
SYNC missed versions from official npm registry.

dat-readdir-stream

Build Status JavaScript Style Guide Maintainability Test Coverage

dat-readdir-stream is a small util to read the file-table of a dat as a stream, rather than through dat.readdir.

npm i dat-readdir-stream --save

Usage

new ReaddirStream(archive[, opts])
  • archive Hyperdrive archive (object).
  • opts.glob Do a glob match over a folder (string).
  • opts.globOpts Options passed to Minimatch (object).
  • opts.cwd Target directory path (string), defaults to /.
  • opts.recursive Read all subfolders and their files as well?
  • opts.maxDepth Limit the depth until which to look into folders.
  • opts.depthFirst Using a depth-first search instead of the default breadth-first search.
  • Returns a readable stream in Object Mode. The payload per entry is an object:
    • entry.location The path of the entry
    • entry.stats A Stats object for that path
const ReaddirStream = require('dat-readdir-stream')

var stream = new ReaddirStream(archive, { cwd: '/assets' })
stream.on('data', ({location, stat}) => {
  console.log(location) // => '/assets/profile.png', '/assets/styles.css'
  console.log(stat.isDirectory()) // => false, false
})

var stream = new ReaddirStream(archive, { recursive: true })
stream.on('data', ({location, stat}) => {
  console.log(location) // => '/assets', '/index.html', '/assets/profile.png', '/assets/styles.css'
})

var stream = new ReaddirStream(archive, { recursive: true, depthFirst: true })
stream.on('data', ({location, stat}) => {
  console.log(location) // => '/assets', '/assets/profile.png', '/assets/styles.css', '/index.html'
})

License

MIT

Current Tags

  • 1.1.0                                ...           latest (3 years ago)

2 Versions

  • 1.1.0                                ...           3 years ago
  • 1.0.0                                ...           3 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (2)
Dev Dependencies (8)
Dependents (2)

Copyright 2014 - 2016 © taobao.org |