Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

append-batch

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

append-batch

append stuff to a log. It's important that we can reason about the order, so do not perform parallel writes.

  • 0.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
160
decreased by-23.44%
Maintainers
1
Weekly downloads
 
Created
Source

append-batch

append stuff to a log. It's important that we can reason about the order, so do not perform parallel writes.

To use this, pass in a function that processes a single batch.

Example

an batch append on top of leveldb, using timestamps as keys.

var Append = require('append-batch')
var timestamp = require('monotonic-timestamp')
var db = level(path...) //example with leveldb.

var append = Append(function (batch, cb) {
  var ops = []

  function add (value) {
    opts.push({key: Date.now(), value: value, type: 'put'}
  }
  batch.forEach(function (value) {
    if(Array.isArray(value) value.forEach(add)
    else add(value)
  })

  db.batch(opts, cb)
})

//append a single value
append({foo: 'bar'}, function (err) {
  //the value is definitely written by now
})

api

Append(writeBatch(values, cb)) => append(value, cb)

create an append function. writeBatch is a function that takes an array of values or arrays of values (which represents a batch operation)

License

MIT

FAQs

Package last updated on 14 Oct 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc