Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

intercept-hypercore-storage

RangerMauve12MIT1.0.0

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

dat, hypercore, proxy, intercept

readme

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.