Socket
Book a DemoInstallSign in
Socket

basic-batch

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

basic-batch

Basic result batching to easily process results to database or an http endpoint in groups

Source
npmnpm
Version
1.0.3
Version published
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
Created
Source

Basic Batch

The most basic of batches

It's Brittney Batch

Install

npm install --save basic-batch

Example

const {
  setTimeout,
} = require('timers/promises');

const BasicBatch = require('./index');
const batch = new BasicBatch;

batch.on('processReady', ({ items, done }) => {
|   items.then(res => {
|   |   console.log(res);
|   |   done();
|   });
});

batch.push(setTimeout(1000, 100)); // valid promise
batch.push(1000); // static value
batch.push(new Promise((resolve, reject) => { reject('WTF'); })); // rejected promise

batch.cleanup(); //make sure to run cleanup, this will flush the queue if you make it to the end of execution without hitting the limit

It's that basic

FAQs

Package last updated on 11 Aug 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts