https://github.com/little-core-labs/hypercore-indexed-file
Address a local file or HTTP resource as an indexed Hypercore feed.
https://github.com/little-core-labs/hypercore-indexed-file
file hypercore index
Last synced: 9 months ago
JSON representation
Address a local file or HTTP resource as an indexed Hypercore feed.
- Host: GitHub
- URL: https://github.com/little-core-labs/hypercore-indexed-file
- Owner: little-core-labs
- License: mit
- Created: 2019-10-21T21:20:44.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-01-10T00:50:46.000Z (over 6 years ago)
- Last Synced: 2023-12-27T19:01:36.584Z (over 2 years ago)
- Topics: file, hypercore, index
- Language: JavaScript
- Size: 10.7 KB
- Stars: 6
- Watchers: 5
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
hypercore-indexed-file
======================
> Address a local file or HTTP resource as an indexed
> [Hypercore][hypercore] feed.
## Installation
```sh
$ npm install hypercore-indexed-file
```
## Usage
```js
const feed = file(pathspec, (err) => {
// file at `pathspec` has been indexed
// bitfield, tree, and signatures generated
})
```
## API
### `feed = file(pathspec[, opts[, callback]])`
Creates a [Hypercore][hypercore] feed with `indexing` set to `true` that uses
[random-access-storage-from][random-access-storage-from] to derive the
**data** storage for the created feed from the given `pathspec` string.
When the feed is ready, it will index the file specified at `pathspec`
by streaming the chunks through the feed, generating the **bitfield**,
**merkle tree**, and **signatures**.
```js
const feed = file('https://example.com/example.txt', (err) => {
feed.createReadStream().pipe(process.stdout)
feed.audit(console.log) // should show `0` invalid nodes
})
```
## License
MIT
[hypercore]: https://github.com/mafintosh/hypercore
[random-access-storage-from]: https://github.com/little-core-labs/random-access-storage-from