https://github.com/blahah/hyperdrive-binary-search
Binary search for entries in a hyperdrive archive by name
https://github.com/blahah/hyperdrive-binary-search
Last synced: 4 months ago
JSON representation
Binary search for entries in a hyperdrive archive by name
- Host: GitHub
- URL: https://github.com/blahah/hyperdrive-binary-search
- Owner: blahah
- Created: 2016-04-04T14:41:15.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2016-04-04T15:09:49.000Z (about 9 years ago)
- Last Synced: 2024-12-27T19:13:30.891Z (5 months ago)
- Language: JavaScript
- Size: 2.93 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## hyperdrive binary search
Find files by name in a [hyperdrive](https://github.com/mafintosh/hyperdrive), using binary search.
This implementation has no dependencies, and is a tiny port of the [binary-search](https://www.npmjs.com/package/binary-search) package to work with hyperdrive archives.
[](https://travis-ci.org/blahah/hyperdrive-binary-search)
### Usage
```js
var hypersearch = require('hyperdrive-binary-search')hypersearch(archive, 'myfile.txt', (err, entry) => {
if (err) raise err
console.log(entry)
})
```The second argument to the callback (here called `entry`) is a hyperdrive metadata entry, e.g.:
```json
{
"type": "file",
"name": "myfile.txt",
"mode": 33188,
"size": 5028864,
"uid": 0,
"gid": 0,
"mtime": 0,
"ctime": 0
}
```you can download the corresponding file from the archive, e.g:
```js
hypersearch(archive, 'myfile.txt', (err, entry) => {
if (err) raise err
var progress = archive.download(entry)
})
```