Skip to content

Instantly share code, notes, and snippets.

@juliangruber
Created January 26, 2018 10:50
Show Gist options
  • Save juliangruber/bd24612ad337708ba65f4a28fcf0dbb1 to your computer and use it in GitHub Desktop.
Save juliangruber/bd24612ad337708ba65f4a28fcf0dbb1 to your computer and use it in GitHub Desktop.
const fs = require('fs')
const hyperdrive = require('hyperdrive')
const src = `/tmp/${Math.random()}/`
console.log(src)
const storage = require('dat-storage')(src)
const archive = hyperdrive(storage, { latest: true, indexing: true })
archive.writeFile('/dat.json', 'hi', err => {
if (err) throw err
//console.log(fs.readFileSync(`${src}/dat.json`)) // => empty
archive.readFile('/dat.json', (err, data) => {
if (err) throw err // => error (couldn't satisfy length)
console.log('data', data)
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment