dat-glob

1.3.0 • Public • Published

dat-glob

Glob implementation for dat archives.

Supports both raw hyperdrive instances and Beaker Browser's DatArchive API.

Usage

This package exports two modules. The default require('dat-glob') works with async iteration, whereas require('dat-glob/stream') uses standard Node streams. Both modules include a collect method which returns a list of all matching files.

// Async iteration
var glob = require('dat-glob')
 
async function main () {
  var dat = await DatArchive.create()
 
  for await (var file of glob(dat, '**/*.json')) {
    console.log(file) // 'dat.json'
  }
 
  var files = await glob(dat, '**/*.json').collect()
  console.log(files) // ['dat.json']
}
 
main()
 
// Node stream
var hyperdrive = require('hyperdrive')
var glob = require('dat-glob/stream')
 
var dat = hyperdrive(key)
var stream = glob(dat, ['*.json', 'subdir/*.json'])
 
stream.pipe(process.stdout)
 
stream.collect((err, files) => {
  console.log(files)
})

License

Apache-2.0

/dat-glob/

    Package Sidebar

    Install

    npm i dat-glob

    Weekly Downloads

    1

    Version

    1.3.0

    License

    Apache-2.0

    Unpacked Size

    17.1 kB

    Total Files

    7

    Last publish

    Collaborators

    • savelbr