How to use multileveldown - 6 common examples

To help you get started, we’ve selected a few multileveldown examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Level / party / index.js View on Github external
module.exports = function (dir, opts) {
  if (!opts) opts = {}
  if (!has(opts, 'retry')) opts.retry = true

  var sockPath = process.platform === 'win32'
    ? '\\\\.\\pipe\\level-party\\' + path.resolve(dir)
    : path.join(dir, 'level-party.sock')

  var client = multileveldown.client(opts)

  client.open(tryConnect)

  function tryConnect () {
    if (!client.isOpen()) return

    var socket = net.connect(sockPath)
    var connected = false

    socket.on('connect', function () {
      connected = true
    })

    // we pass socket as the ref option so we dont hang the event loop
    pump(socket, client.createRpcStream({ ref: socket }), socket, function () {
      if (!client.isOpen()) return
github ipfs-shipyard / ipfs-npm-registry-mirror / packages / common / utils / fs-repo.js View on Github external
constructor (path, opts) {
      super(path, {
        ...opts,
        db: () => memdown()
      })

      this.db = multileveldown.client({
        retry: true,
        valueEncoding: 'binary',
        compression: false // same default as go
      })
      this.path = path
      this.open()
    }
github maxogden / dat-core / lib / multiprocess.js View on Github external
encode.updates({mainLayer: that.mainLayer, changes: that.changes})

          decode.adds(function (req, cb) {
            log.add(req.links, req.value, req.options, function (err, result) {
              encode.adds({
                id: req.id,
                error: err && err.message,
                notFound: err && err.notFound,
                value: result
              })
            })
            cb()
          })

          if (sock.unref) sock.unref()
          multileveldown.server(db, {encode: encode, decode: decode})
          pump(sock, stream, sock)
        })
github ipfs-shipyard / ipfs-npm-registry-mirror / packages / common / utils / fs-repo.js View on Github external
var server = net.createServer((sock) => {
        sock.on('error', () => {
          sock.destroy()
        })

        sock.pipe(multileveldown.server(db)).pipe(sock)
      })
github Level / party / index.js View on Github external
var server = net.createServer(function (sock) {
            if (sock.unref) sock.unref()
            sockets.push(sock)
            pump(sock, multileveldown.server(db), sock, function () {
              sockets.splice(sockets.indexOf(sock), 1)
            })
          })
github maxogden / dat-core / lib / multiprocess.js View on Github external
module.exports = function (opts) {
  var that = new events.EventEmitter()

  var leaderEncoders = []
  var sockPath = opts.sockPath

  var client = multileveldown.client({retry: true})
  var clientAdds = []
  var clientEncode
  var leader = false
  var log
  var clientLog

  that.changes = 0
  that.mainLayer = null
  that.leader = that.follower = false

  that.update = function (update) {
    that.mainLayer = update.mainLayer
    that.changes = update.changes

    if (!leader) return

multileveldown

multilevel implemented using leveldowns with reconnect support

MIT
Latest version published 3 years ago

Package Health Score

54 / 100
Full package analysis

Popular multileveldown functions

Similar packages