Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dat-ecosystem-archive/dat-walk
Recursive directory walker for dat archives [ DEPRECATED - More info on active projects and modules at https://dat-ecosystem.org/ ]
https://github.com/dat-ecosystem-archive/dat-walk
Last synced: 3 months ago
JSON representation
Recursive directory walker for dat archives [ DEPRECATED - More info on active projects and modules at https://dat-ecosystem.org/ ]
- Host: GitHub
- URL: https://github.com/dat-ecosystem-archive/dat-walk
- Owner: dat-ecosystem-archive
- License: apache-2.0
- Archived: true
- Created: 2018-11-20T18:58:55.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2021-12-28T20:56:01.000Z (about 3 years ago)
- Last Synced: 2024-05-16T13:15:35.318Z (9 months ago)
- Language: JavaScript
- Homepage:
- Size: 10.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-dat - dat-walk - Recursive directory walker for dat archives (Using Dat / Dat Utilities)
README
[![deprecated](http://badges.github.io/stability-badges/dist/deprecated.svg)](https://dat-ecosystem.org/)
More info on active projects and modules at [dat-ecosystem.org](https://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`](https://github.com/pfrazee/scoped-fs) you can use it on your local file system as well.
## Installation
In [Beaker](https://beakerbrowser.com) or [Webrun](https://github.com/RangerMauve/webrun) you can import the module directly in your code:
```js
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:
```sh
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.
```js
// 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