Skip to content

Instantly share code, notes, and snippets.

@creationix
Created June 20, 2017 17:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save creationix/5fea2bad61ab38dcd8852a154457a788 to your computer and use it in GitHub Desktop.
Save creationix/5fea2bad61ab38dcd8852a154457a788 to your computer and use it in GitHub Desktop.
// 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)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment