aggregate-base
Base class for aggregate operation, sush as http request, write file.
Usage
npm i aggregate-base --save
You can wrap Class for aggregate operation, if you have a Logger that write log to file.
{ this; } { // your implementation }
However, it has bad performance that write file system every function call, so you can use this module to merge the operations.
const wrap = ; { this; } { this; } { // your implementation } const WrapLogger = ;
The module will create a loop (configured by interval), it will collect data by intercepting the specified intercept
method, and call flush
method after interval
with all collected data.
Options
- interval: the time between flush
- intercept: the intercept method name of class, the method will not be run.
- interceptTransform: the function that can tranform the arguments of intercept method, if it return false, it won't cache this data
- flush: the flush method name of class.
- close: the close method name of class, it should be a async function.