
Security News
Feross on TBPN: How North Korea Hijacked Axios
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.
hyperdrive-index
Advanced tools
index changes to a hyperdrive feed
Use this package to generate indexes to quickly answer questions about files written to hyperdrive. For example, you could create an index that parses exif headers and generates thumbnails for a p2p photo album served over a hyperdrive.
This example indexes the number of lines in each file written to hyperdrive.
var level = require('level')
var hyperdrive = require('hyperdrive')
var through = require('through2')
var split = require('split2')
var hdex = require('hyperdrive-index')
var db = level('/tmp/drive.db')
var archive = hyperdrive('/tmp/drive.data')
var dex = hdex({
archive: archive,
db: level('/tmp/drive.dex.db'),
map: function (entry, cb) {
var ch = archive.checkout(entry.version)
var stream = ch.createReadStream(entry.name)
countLines(stream, function (err, lines) {
if (err) cb(err)
else db.put(entry.name, lines, cb)
})
}
})
var name = process.argv[3]
if (process.argv[2] === 'add') {
process.stdin.pipe(archive.createWriteStream(name))
} else if (process.argv[2] === 'get') {
dex.ready(function () {
db.get(name, function (err, lines) {
if (err) console.error(err)
else console.log(lines)
})
})
}
function countLines (stream, cb) {
var n = 0
stream.pipe(split()).pipe(through(write, end))
function write (buf, enc, next) { n++; next() }
function end (next) { cb(null, n) }
}
$ echo -ne 'one\ntwo\nthree' | node dex.js add /hello.txt
$ echo -ne 'wheee' | node dex.js add /what.txt
$ node dex.js get /what.txt
1
$ node dex.js get /hello.txt
3
$ echo -ne 'one\ntwo\nthree\nfour\nfive' | node dex.js add /hello.txt
$ node dex.js get /hello.txt
5
var hindex = require('hyperdrive-index')
Create a hyperdrive index dex from:
opts.archive - hyperdrive archive opened in live modeopts.db - leveldb instanceopts.map(entry, cb) - function to process each new entry objectIn your opts.map(entry, cb) function, write your indexes to some persistent
storage and call cb(err) when finished. The entry records are metadata
objects, like you get from archive.list().
fn() fires when the indexes are caught up with the latest known value in the
hyperdrive feed.
npm install hyperdrive-index
BSD
FAQs
index changes to a hyperdrive feed
The npm package hyperdrive-index receives a total of 2 weekly downloads. As such, hyperdrive-index popularity was classified as not popular.
We found that hyperdrive-index demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.

Security News
OpenSSF has issued a high-severity advisory warning open source developers of an active Slack-based campaign using impersonation to deliver malware.

Research
/Security News
Malicious packages published to npm, PyPI, Go Modules, crates.io, and Packagist impersonate developer tooling to fetch staged malware, steal credentials and wallets, and enable remote access.