Skip to content
This repository has been archived by the owner on Dec 29, 2021. It is now read-only.

Recursive directory walker for dat archives [ DEPRECATED - More info on active projects and modules at https://dat-ecosystem.org/ ]

License

Notifications You must be signed in to change notification settings

dat-ecosystem-archive/dat-walk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

deprecated

More info on active projects and modules at dat-ecosystem.org


dat-walk

Recursive directory walker for dat archives.

Supports both raw hyperdrive instances and Beaker Browser's DatArchive API. With scoped-fs you can use it on your local file system as well.

Installation

In Beaker or Webrun you can import the module directly in your code:

import walk from 'dat://brecht.pamphlets.me/lib/dat-walk/v2.1.js'

Note that it's advised to always use the dat protocol for this. HTTPS might be fine for testing, but I can't guarantee the required reliability and performance for production usage.

If you need dat-walk in Node.js, you can get it from NPM:

npm install dat-walk

Usage

This package exports two modules. The default require('dat-walk') works with async iteration, whereas require('dat-walk/stream') uses standard Node streams. Both these examples log all file paths of a given dat to the console.

// Async iteration
var walk = require('dat-walk')

async function main () {
  var dat = DatArchive.load(key)

  for await (var file of walk(dat)) {
    console.log(file)
  }
  console.log('done!')
}

main()

// Node stream
var hyperdrive = require('hyperdrive')
var walk = require('dat-walk/stream')

var dat = hyperdrive(key)
var stream = walk(dat, 'subdir')

stream.on('data', console.log)
stream.on('end', () => console.log('done!'))

API

walk(dat [, base])

dat

Type: object (required)

A DatArchive, hyperdrive, or scoped-fs instance.

base

Type: string

Subdirectory to start walking from.

walk(dat [, opts])

dat

See above.

opts.base

See above.

opts.dir

Type: boolean (default: false)

Determines if walk outputs directories as well as files.

License

Apache-2.0

About

Recursive directory walker for dat archives [ DEPRECATED - More info on active projects and modules at https://dat-ecosystem.org/ ]

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published