range emitter hooks for leveldb
client and server using multileveldown, range-emitter and ltgt
const websocket = require('websocket-stream')
const multileveldown = require('multileveldown')
const rangeEmitter = require('level-range-emitter').client
const db = multileveldown.client({ keyEncoding: 'utf8', valueEnoding: 'json', retry: true })
const re = rangeEmitter(db)
;(function connect () {
const protocol = window.location.protocol === 'https:' ? 'wss' : 'ws'
const url = `${protocol}://${window.location.host}/db`
const ws = websocket(url)
const remote = db.connect()
re.session(remote, ws)
ws.on('close', window.setTimeout.bind(window, connect, 3000))
})()
re.subscribe((key, type) => console.log('changed %s', key, type))
const lre = require('level-range-emitter').server(db)
const session = lre.session
const dbStream = multileveldown.server(dbInstance)
session(dbStream, stream)