Created
January 26, 2018 10:50
-
-
Save juliangruber/bd24612ad337708ba65f4a28fcf0dbb1 to your computer and use it in GitHub Desktop.
This file contains 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
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