Dependency Breakdown of an Example

Here is a minimalistic example showing how to download a file from a Dat archive:

const hyperdrive = require('hyperdrive')
const hyperdiscovery = require('hyperdiscovery')
const ram = require('random-access-memory')

const key = '9900f9aad4d6e79e0beb1c46333852b99829e4dfcdfa9b690eeeab3c367c1b9a'
const archive = hyperdrive(ram, key, {sparse: true})

archive.ready(() => {
  hyperdiscovery(archive)
  archive.readFile('dat.json', (err, data) => {
    if (err) throw err
    console.log(data.toString())
    process.exit(0)
  })
})

It depends on some npm modules, so you'll need to install those:

npm install hyperdrive hyperdiscovery random-access-memory

At the time this was written, in node_modules, there are 97 npm modules!

Let's break it down a bit...

Explicit module dependencies

Three modules were explicitly 'required':

  • hyperdrive: mafintosh/hyperdrive

    This exposes a virtual filesystem interface. Hyperdrive is the primary module used to implement a Dat archive. We'll describe some hyperdrive-specific dependencies below.

  • hyperdiscovery: karissa/hyperdiscovery

    Hyperdrive doesn't know anything about the network, but it does expose a replication interface. Hyperdiscovery is a convenience wrapper around some other modules that can be used to connect to the peer-to-peer network and sync data. We'll describe some hyperdiscovery-specific dependencies below.

  • random-access-memory: random-access-storage/random-access-memory

    By default, Hyperdrive stores archives on disk. But you can tell it to use alternative "random-access storage" modules. In this case, we just use in-memory storage implemented by random-access-storage.

Hyperdrive-specific Dependencies

Hyperdrive (github), provides a filesystem abstraction. It is built on top of a pair of "append-only logs", implemented with Hypercore (below).

Hypercore

Additionally, the following parts of hypercore are split into their own modules so they can be re-used elsewhere:

Hyperdiscovery-specific Dependencies

Secondary dependencies:

DNS Discovery Modules

DHT Discovery Modules

UTP

Random-Access Storage Modules

Encryption Modules

Related videos:

Useful Data Structures

Numerical Support

Protocol Buffers Support

Node.js Stream Utilities

Javascript Control Flow Utilities

Node.js and Browser Compatibility Modules

Some of these modules are to support older versions of Node.js, and some are for browser support.

Windows support:

Node.js Native Module Support

Convenience utilities

UI Formatting

results matching ""

    No results matching ""