hyperdrive
Advanced tools
Comparing version 2.0.0 to 2.1.0
28
index.js
@@ -87,2 +87,30 @@ var constants = require('constants') | ||
Archive.prototype.download = function (i, cb) { | ||
if (!cb) cb = noop | ||
var ptr = 0 | ||
var self = this | ||
if (typeof i === 'number') this.entry(i, onentry) | ||
else onentry(null, i) | ||
function onentry (err, entry) { | ||
if (err) return cb(err) | ||
var feed = self._getFeed(entry) | ||
feed.on('put', kick) | ||
kick() | ||
function kick () { | ||
if (!feed.blocks) return | ||
for (; ptr < feed.blocks; ptr++) { | ||
if (!feed.has(ptr)) return | ||
} | ||
feed.removeListener('put', kick) | ||
cb(null) | ||
} | ||
} | ||
} | ||
Archive.prototype.select = function (i, cb) { | ||
@@ -89,0 +117,0 @@ if (!cb) cb = noop |
{ | ||
"name": "hyperdrive", | ||
"version": "2.0.0", | ||
"version": "2.1.0", | ||
"description": "A file sharing network based on rabin file chunking and append only feeds of data verified by merkle trees.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -136,10 +136,7 @@ # hyperdrive | ||
#### `archive.select(index)` | ||
#### `archive.download(index, [callback])` | ||
Select a file to be downloaded | ||
Downloads the file specified by index and calls the callback when done. | ||
You have to call this or create a file stream to download a file. | ||
#### `archive.delect(index)` | ||
Deselects a file. | ||
#### `var rs = archive.createFileStream(index)` | ||
@@ -146,0 +143,0 @@ |
@@ -22,3 +22,3 @@ var tape = require('tape') | ||
clone.once('file-downloaded', function () { | ||
clone.download(0, function () { | ||
var buf = [] | ||
@@ -36,4 +36,2 @@ clone.createFileStream(0) | ||
clone.select(0) | ||
var p1 = drive.createPeerStream() | ||
@@ -40,0 +38,0 @@ var p2 = driveClone.createPeerStream() |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
53232
616
0
152