# level-change-processor

> follows a changes-feed and processes each entry, storing state in a leveldb

Latest version **1.0.0** (published 2015-01-16) · BSD license · 0 weekly downloads

## Install

```sh
npm install level-change-processor
pnpm add level-change-processor
yarn add level-change-processor
bun add level-change-processor
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2015-01-16 |
| First published | 2015-01-16 |
| Weekly downloads | 0 |
| License | BSD |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 8 |
| Author | max ogden |
| Maintainers | maxogden |
| Keywords | leveldb, dat, hyperdata |

## Links

- npm: https://www.npmjs.com/package/level-change-processor
- Repository: https://github.com/maxogden/level-change-processor
- Issues: https://github.com/maxogden/level-change-processor/issues
- npm.io page: https://npm.io/package/level-change-processor

## Dependencies (2)

- [inherits](https://npm.io/package/inherits.md) ^2.0.1
- [readable-stream](https://npm.io/package/readable-stream.md) ^1.0.33

## Alternatives

- [vest](https://npm.io/package/vest.md) — 50.1K weekly downloads
- [@regle/core](https://npm.io/package/@regle/core.md) — 47.0K weekly downloads
- [typeof-arguments](https://npm.io/package/typeof-arguments.md) — 12.5K weekly downloads
- [@lokalise/projects-engine-contracts](https://npm.io/package/@lokalise/projects-engine-contracts.md) — 978 weekly downloads
- [@osjwnpm/nam-laboriosam-quibusdam](https://npm.io/package/@osjwnpm/nam-laboriosam-quibusdam.md) — 70 weekly downloads

## Recent versions

- 1.0.0 (latest) — 2015-01-16

## README

# level-change-processor

[![NPM](https://nodei.co/npm/level-change-processor.png)](https://nodei.co/npm/level-change-processor/)

[![Build Status](https://travis-ci.org/maxogden/level-change-processor.svg?branch=master)](https://travis-ci.org/maxogden/level-change-processor)
![dat](http://img.shields.io/badge/Development%20sponsored%20by-dat-green.svg?style=flat)

Follows a [changes-feed](http://npmjs.org/changes-feed) and processes each entry, storing state in a [levelup](http://npmjs.org/levelup). Automatically handles resuming the changes processing from where it left off when restarted.

Designed for creating secondary indexes with leveldb but can be used in many different applications.

## Usage

### `require('level-change-processor')(opts)`

Construct a new change processor instance.

`opts` is an object:

- `db` (*required*) - a levelup to store the change state in
- `feed` (*required*) - a `changes-feed` instance
- `worker` (*required*) - a function (see below) that processes each change
- `key` (default `latest`) - a key to use to store the change state in the `db` above
- `dbOptions` (default `{valueEncoding: 'utf8'}`) - options to pass to the `db` `.get` and `.put` calls

example:

```js
var processor = changeProcessor({
  db: stateDb,
  feed: feed,
  worker: worker
})
```

#### Worker function

A function that takes two arguments: `(change, cb)`.

`change` will be an object with these properties:

- `change` - this will be a js `Number` that increments by 1 for every change, starting at `1`
- `value` - this will be the change payload that the changes feed writes to you. usually is a `Buffer` but depends on the feed

These are the two guaranteed properties. There may be other properties on `change` depending on the feed.

#### error handling

To catch errors attach a `processor.on('error', errorHandler)` event

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