An open API service indexing awesome lists of open source software.

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

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.

[![Travis](https://img.shields.io/travis/blahah/hyperdrive-binary-search.svg?style=flat-square)](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)
})
```