Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

README.md

2 - Hypercore: one log to rule them all

Hypercore is a fundamental module in Dat's ecosystem.

It works as an append-only log providing all the mechanisms necessary to work with and share big volumes of data in a distributed and secure manner.

First, let's take a look at what hypercore looks like. It's just a function we can call and will return a feed.

const hypercore = require('hypercore')
const feed = hypercore('./my-first-dataset', {valueEncoding: 'utf-8'})

Exercise

  1. Write a function that returns an hypercore feed using a memory storage.
  2. Setup the instance for handling json data.
  3. Before returning the feed, add the following object: { title: 'dat-is-freedom' }.

Tips

  1. hypercore takes as a first parameter a function that defines the storage. This function must follow the random-access-storage interface.
  2. If we give hypercore a filepath instead of a storage function, hypercore will use random-access-file as a default storage.
  3. If you take a look into the hypercore options you will see that we can specify the type of codec to use for parsing the data.

Test

$ npm test ./02

test.js

Solution

solution.js