atomic-batcher

WebJar for atomic-batcher

Лицензия

Лицензия

MIT
Группа

Группа

org.webjars.npm
Идентификатор

Идентификатор

atomic-batcher
Последняя версия

Последняя версия

1.0.2
Дата

Дата

Тип

Тип

jar
Описание

Описание

atomic-batcher
WebJar for atomic-batcher
Ссылка на сайт

Ссылка на сайт

http://webjars.org
Система контроля версий

Система контроля версий

https://github.com/mafintosh/atomic-batcher

Скачать atomic-batcher

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/org.webjars.npm/atomic-batcher/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>atomic-batcher</artifactId>
    <version>1.0.2</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/atomic-batcher/
implementation 'org.webjars.npm:atomic-batcher:1.0.2'
// https://jarcasting.com/artifacts/org.webjars.npm/atomic-batcher/
implementation ("org.webjars.npm:atomic-batcher:1.0.2")
'org.webjars.npm:atomic-batcher:jar:1.0.2'
<dependency org="org.webjars.npm" name="atomic-batcher" rev="1.0.2">
  <artifact name="atomic-batcher" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='atomic-batcher', version='1.0.2')
)
libraryDependencies += "org.webjars.npm" % "atomic-batcher" % "1.0.2"
[org.webjars.npm/atomic-batcher "1.0.2"]

Зависимости

Библиотека не имеет зависимостей. Это самодостаточное приложение, которое не зависит ни от каких других библиотек.

Модули Проекта

Данный проект не имеет модулей.

atomic-batcher

A simple batching function that allows you to atomically batch a series of operations. If you are looking for the same thing with a stream interface checkout byte-stream.

npm install atomic-batcher

build status

Usage

var batcher = require('atomic-batcher')
var db = require('level')('some.db')

var batch = batcher(function work (ops, cb) {
  // only one batch will happen at the time
  console.log('Batching:', ops, '\n')
  db.batch(ops, cb)
})

batch({type: 'put', key: 'hello', value: 'world-1'})
batch({type: 'put', key: 'hello', value: 'world-2'})
batch({type: 'put', key: 'hello', value: 'world-3'})
batch({type: 'put', key: 'hi', value: 'hello'}, function () {
  console.log('Printing latest values:\n')
  db.get('hello', console.log) // returns world-3
  db.get('hi', console.log) // returns hello
})

Running the above example will print

Batching: [ { type: 'put', key: 'hello', value: 'world-1' } ]

Batching: [ { type: 'put', key: 'hello', value: 'world-2' },
  { type: 'put', key: 'hello', value: 'world-3' },
  { type: 'put', key: 'hi', value: 'hello' } ]

Printing latest values:

null 'world-3'
null 'hello'

API

var batch = batcher(worker)

Create a new batching function. worker should be a function that accepts a batch and a callback, (batch, cb). Only one batch is guaranteed to be run at the time.

The batch function accepts a value or an array of values and a callback, batch(value(s), cb). The callback is called when the batch containing the values have been run.

License

MIT

Версии библиотеки

Версия
1.0.2