intercept-hypercore-storage

1.0.0 • Public • Published

intercept-hypercore-storage

Intercept the data storage in a hypercore. Made for the datdot project

npm i --save intercept-hypercore-storage
const intercept = require('intercept-hypercore-storage')
 
// Get an instance of a hypercore
const feed = hypercore()
 
// Start intercepting
const unintercept = intercept(feed, {
  // This tells you to save the data somewhere
  // Only the data storage is intercepted
  // The storage of the signatures is being stored normally
  // The `index` is the index of the chunk in the hypercore
  putData: (index, data, cb) => cb(null),
  // Use this to retrieve the data you stored
  getData: (index, cb) => cb(null, thedata)
})
 
// Replicate the feed with a peer
feed.replicate({stream})
 
// If you're done intercepting and want to clean up the monkey patching, use this.
unintercept()

How it works

The module will monkey-patch your hypercore instance and intercept it's attempts to store and retrieve the data portion.

Package Sidebar

Install

npm i intercept-hypercore-storage

Weekly Downloads

1

Version

1.0.0

License

MIT

Unpacked Size

4.56 kB

Total Files

5

Last publish

Collaborators

  • rangermauve