Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

@alepha/batch

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@alepha/batch

Efficiently process operations in groups by size or time.

Source
npmnpm
Version
0.9.1
Version published
Weekly downloads
277
575.61%
Maintainers
1
Weekly downloads
 
Created
Source

Alepha Batch

Efficiently process operations in groups by size or time.

Installation

This package is part of the Alepha framework and can be installed via the all-in-one package:

npm install alepha

Alternatively, you can install it individually:

npm install @alepha/core @alepha/batch

Module

This module allows you to group multiple asynchronous operations into a single "batch," which is then processed together. This is an essential pattern for improving performance, reducing I/O, and interacting efficiently with rate-limited APIs or databases.

import { Alepha, $hook, run, t } from "alepha";
import { $batch } from "alepha/batch";

class LoggingService {
  // define the batch processor
  logBatch = $batch({
    schema: t.string(),
    maxSize: 10,
    maxDuration: [5, "seconds"],
    handler: async (items) => {
      console.log(`[BATCH LOG] Processing ${items.length} events:`, items);
    },
  });

  // example of how to use it
  onReady = $hook({
    on: "ready",
    handler: async () => {
      this.logBatch.push("Application started.");
      this.logBatch.push("User authenticated.");
      // ... more events pushed from elsewhere in the app
    },
  });
}

API Reference

Descriptors

$batch()

Creates a batch processor. This is useful for grouping multiple operations (like API calls or database writes) into a single one to improve performance.

Keywords

alepha

FAQs

Package last updated on 28 Jul 2025

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