@biorate/batcher
TypeScript icon, indicating that this package has built-in type declarations

1.65.4 • Public • Published

Tasks batcher

Tasks batcher

Features:

  • Group single tasks into batch request

Examples:

import { inject, container, Types, Core } from '@biorate/inversion';
import { IConfig, Config } from '@biorate/config';
import { IBatcher, Batcher } from '@biorate/batcher';

const batcher: IBatcher = new Batcher<{ data: string }, { test: string }>();

batcher.register((tasks) => {
  console.log(tasks);
  // [
  //   [
  //     { data: 'one' },
  //     {
  //       resolve: [Function (anonymous)],
  //       reject: [Function (anonymous)],
  //       metadata: { test: 'one' }
  //     }
  //   ],
  //   [
  //     { data: 'two' },
  //     {
  //       resolve: [Function (anonymous)],
  //       reject: [Function (anonymous)],
  //       metadata: { test: 'two' }
  //     }
  //   ],
  //   [
  //     { data: 'three' },
  //     {
  //       resolve: [Function (anonymous)],
  //       reject: [Function (anonymous)],
  //       metadata: { test: 'three' }
  //     }
  //   ]
  // ]
});
batcher.add({ data: 'one' }, { test: 'one' });
batcher.add({ data: 'two' }, { test: 'two' });
batcher.add({ data: 'three' }, { test: 'three' });

Learn

  • Documentation can be found here - docs.

Release History

See the CHANGELOG

License

MIT

Copyright (c) 2021-present Leonid Levkin (llevkin)

Readme

Keywords

Package Sidebar

Install

npm i @biorate/batcher

Weekly Downloads

1

Version

1.65.4

License

MIT

Unpacked Size

138 kB

Total Files

30

Last publish

Collaborators

  • llevkin