# append-batch

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

Latest version **0.0.2** (published 2017-10-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install append-batch
pnpm add append-batch
yarn add append-batch
bun add append-batch
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.2 |
| Published | 2017-10-14 |
| First published | 2016-11-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | 'Dominic Tarr' |
| Maintainers | dominictarr |

## Links

- npm: https://www.npmjs.com/package/append-batch
- Repository: https://github.com/flumedb/append-batch
- Issues: https://github.com/flumedb/append-batch/issues
- npm.io page: https://npm.io/package/append-batch

## Recent versions

- 0.0.2 (latest) — 2017-10-14
- 0.0.1 — 2016-11-06
- 0.0.0 — 2016-11-05

## README

# 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.

``` js
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

---
_Source: https://npm.io/package/append-batch · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
