hyper-upload-progress
v1.0.0
Published
Track upload progress of hypercore/hyperdrive
Maintainers
Readme
hyper-upload-progress
Know when a Hypercore or Hyperdrive is fully uploaded to peers.
Only currently connected peers are counted towards the progress.
An empty Hypercore is not resolved, it will continue waiting until some data exists and resolves only when a peer syncs with that data.
A Hyperdrive is not resolved while metadata or blobs are empty.
Forks are not supported.
Instalation
npm i hyper-upload-progressUsage
const uploadProgress = require('hyper-upload-progress')
const progress = uploadProgress(hypercore, { minPeers: 5, pollInterval: 500 })
// Use destroy() to handle when you want to stop waiting
setTimeout(() => progress.destroy(), 5000)
// Will resolve when at least 5 peers are actively connected and report they downloaded the Hypercore
await progress.done()API
const progress = uploadProgress(core, opts)
Creates a new progress object. core is instance of Hypercore or Hyperdrive.
opts include:
minPeers: how many peers need to fully synchronize for progess to resolve (default: 1).pollInterval: how often (in milliseconds) progress is checked (default: 100).
await progress.done()
Waits until required amount of peers fully download the Hypercore or Hyperdrive.
progress.destroy()
Stops checking the progress and rejects the promise from progress.done.
