append-tree icon indicating copy to clipboard operation
append-tree copied to clipboard

README tweak

Open creationix opened this issue 8 years ago • 1 comments

In the readme, you mention that the hypercore feed can be faked with:

any append-only log that supports .append() and .length

But in testing, I found more was needed. So I made a simple minimal interface.

// Fake hypercore feed for testing and learning
var values = []
var feed = {
  append (value, cb) {
    console.log('APPEND', {value, cb})
    values.push(value)
    nextTick(cb)
  },
  get (index, options, cb) {
    console.log('GET', {index, options, cb})
    nextTick(cb, null, values[index])
  },
  get length () {
    console.log('LENGTH')
    return values.length
  },
  ready (cb) {
    console.log('READY', {cb})
    nextTick(cb)
  }
}

creationix avatar Jun 20 '17 17:06 creationix

Maybe mention it needs all 4 and .length is a getter.

creationix avatar Jun 20 '17 17:06 creationix