Skip to content

Instantly share code, notes, and snippets.

@juliangruber
Created March 5, 2017 13:29
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 juliangruber/e5b682585e3708a86659be63dd2f9c64 to your computer and use it in GitHub Desktop.
Save juliangruber/e5b682585e3708a86659be63dd2f9c64 to your computer and use it in GitHub Desktop.
var rad = require('random-access-directory')
var store = rad(procss.env.HOME + '/.dat/')
// create a first store
store = store('hypercore.txt')
store.get(0, ...)
// create another store, based on the first one
// this way modules can pass the store instance
// down to child modules
store = store('hyperdrive.txt')
var feed = hypercore(store('hypercore.txt'))
// ok so a module that wants to use an
// abstract-random-access store but also needs
// some for dependent modules, needs to require
// you to pass a random-access-directory instance.
// what though if you want all to be in-memory?
// should we instead turn this module into one
// that works with any abstract-random-access
// store? then it could be something like this:
var store = multirandom(function (name) {
return raf(basedir + '/' + name)
})
// create a first store
store = store('hypercore.txt')
store.get(0, ...)
// create another store, based on the first one
// this way modules can pass the store instance
// down to child modules
store = store('hyperdrive.txt')
// this means, do we want to introduce a new
// interface, the abstract-random-access-FACTORY?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment