Last active
October 30, 2019 20:41
-
-
Save hackergrrl/518ca15fdf70791940b23658bad2f162 to your computer and use it in GitHub Desktop.
corestorage api
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let store = corestore('my-storage-dir' || ram() || webstore()) | |
// Map a discovery key or local-name to a key. | |
store.keyFromDiscoveryKey(discoKey, cb) | |
store.keyFromLocalName('my-feed', cb) | |
// Create a new hypercore, which can include a local name. (creates + loads) | |
let core = store.create('localname', { valueEncoding: 'utf-8' }) | |
core.ready(cb) | |
// Get an existing hypercore by key or local name. Local names are purely local & aren't shared over the network. | |
// Loads the core if it isn't loaded. | |
store.get(id, cb) | |
// Returns boolean true/false if core is loaded from disk. | |
store.isLoaded(id, cb) | |
// Unload a hypercore. | |
store.close(id, cb) | |
// Close all hypercores. | |
store.closeAll(cb) | |
// Unload and delete a hypercore. | |
store.delete(id, cb) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Wow Nice! quick feedback:
Is it possible to drop the
ready()
pattern? My gut is trying to tell me something that it's gonna be problematic to define "ready"-state when we start working with sparse-loaded cores. an asyncstore.list()
would maybe fullfill the same functionality?I haven't paid enough attention yet so i'm not sure if the following comment is relevant:
I'm little bit curious if it's possible to slim down kappa-core and deprecate
kappa#writer(name, cb)
,kappa#feed(key)
andkappa#feeds()
methods. Been exprimenting with the thought of letting kappa only handle indexing regardless of which source it's feeds are from.. Having said that, i haven't yet thought of how to alternatively provide feeds to kappa.