Batcher
Extends:
Batcher provides a way to batch a lot of inputs into groups. It has two mechanisms to do this. The first mechanism is to set the 'batchSize' option to the maximum desired size of a single batch. When the buffer has reached this size it will flush the batch. The second option is to set the 'interval' option. If this option is set the batch will be flushed when either maximum batch size is reached or the interval has passed.
Constructor Summary
Public Constructor | ||
public |
constructor(options: IBatcherOptions) |
Member Summary
Public Members | ||
public |
|
|
public |
|
Private Members | ||
private |
_batch: *[] |
|
private |
If the interval options is set, this contains a reference for the set interval |
Method Summary
Public Methods | ||
public |
close() Stop the interval timer. |
|
public |
flush() Flush the current batch. |
|
public |
write(item: unknown) Write an item to the batch. |
Public Constructors
public constructor(options: IBatcherOptions) source
Create a new Batcher and, if the 'interval' option is supplied, start the interval timer.
Params:
Name | Type | Attribute | Description |
options | IBatcherOptions |
|