Skip to content

Instantly share code, notes, and snippets.

@sethvincent
Last active August 29, 2015 14:11
Show Gist options
  • Save sethvincent/2d28a1f57319300b61f4 to your computer and use it in GitHub Desktop.
Save sethvincent/2d28a1f57319300b61f4 to your computer and use it in GitHub Desktop.
level-dat browserifies
require('set-immediate')
var http = require('http')
var es = require('event-stream')
var ldat = require('level-dat')
var level = require('levelup')
var leveljs = require('level-js')
var xhr = require('xhr')
var db = level('./db', { db: leveljs, valueEncoding: 'json' })
dat = ldat(db)
xhr('http://127.0.0.1:6461/api/changes?data=true', function (err, res, body) {
read = es.readArray(JSON.parse(body).rows)
read.pipe(dat.createChangesWriteStream())
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment