level-range-emitter

3.0.0 • Public • Published

level-range-emitter

range emitter hooks for leveldb

client and server using multileveldown, range-emitter and ltgt

js-standard-style Greenkeeper badge downloads

client example

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))

server example

  const lre = require('level-range-emitter').server(db)
  const session = lre.session
  const dbStream = multileveldown.server(dbInstance)
  session(dbStream, stream)

Package Sidebar

Install

npm i level-range-emitter

Weekly Downloads

0

Version

3.0.0

License

MIT

Unpacked Size

6.52 kB

Total Files

6

Last publish

Collaborators

  • jameskyburz