@emartech/object-batcher-js

中文文档
1.12.0发布于 2026/07/28MITESM + CJS近 30 天下载 2281

Used primarily by @emartech/rabbitmq-client's batch consumer.

原始使用文档
文档目录3 节
  1. Initialize
  2. Pushing an item into the object batcher
  3. Reseting state of batcher

Object Batcher

Used primarily by @emartech/rabbitmq-client's batch consumer.

Usage

Initialize


const ObjectBatcher = require('@emartech/object-batcher-js');

const objectBatcher = new ObjectBatcher(callback_fn, {
  batchSize,
  batchTimeout,
  [prefetchCount]
});

The callback function will be called after the batchTimeout expires or the pushed items count reaches the set batchSize or the overall pushed items count reaches the given prefecthCount.

Pushing an item into the object batcher

objectBatcher.add(groupBy, payload);

Different payloads with the same groups will be batched and the callback will be called with (groupBy, payloads) arguments.

Reseting state of batcher

objectBatcher.resetState();

This method is mostly useful during testing. Before each test case you could call resetState to ensure the leftover state from previous run does not interfere with the current one.


updating all dependencies to highest to create new release if you want new release the commits have to begin with "fix(...)" or "feat(...)"

Copyright EMARSYS 2020 All rights reserved.

版本与发布记录

@emartech/object-batcher-js 共发布 23 个版本,首次发布于 2017/05/24;过去 12 个月发布了 2 个版本。

版本发布日期距今
1.12.0latest2026/07/283 个月前
1.11.02026/01/0810 个月前
1.10.02025/10/271 年前
1.9.02025/10/171.1 年前
1.8.12025/10/011.1 年前
1.8.02024/10/162 年前

关于 @emartech/object-batcher-js 的常见问题

@emartech/object-batcher-js 是什么?

Used primarily by @emartech/rabbitmq-client's batch consumer.

如何安装 @emartech/object-batcher-js?

在项目目录运行 npm install @emartech/object-batcher-js,或使用 pnpm add / yarn add / bun add。

@emartech/object-batcher-js 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/emartech__object-batcher-js 是否存在。

@emartech/object-batcher-js 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@emartech/object-batcher-js 可以商用吗?

@emartech/object-batcher-js 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@emartech/object-batcher-js 的下载量有多少?

根据 npm 官方下载统计,@emartech/object-batcher-js 在 2026/10/14 – 2026/11/12 这 30 天内被下载 2,281 次,日均约 76 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@emartech/object-batcher-js 还在维护吗?

最新版本 1.12.0 发布于 2026/07/28(3 个月前);至今共发布 23 个版本,其中过去 12 个月发布了 2 个;首次发布于 2017/05/24。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。