Socket
Book a DemoInstallSign in
Socket

batch-do

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

batch-do

Do batched tasks easily

0.0.6
latest
Source
npmnpm
Version published
Maintainers
1
Created
Source

batch-do

Do batched tasks easily

Features

  • Relatively fast
  • Single micro-task batching
  • ESM & CJS compatible

How it works

Installation

We recommend install via npm because of it's cache and flat node modules tree

npm i batch-do

then you able to import to Node.js/Browser easily

// Node.js
const batch = require("batch-do");
const { createContext } = batch;

// ES6
import batch, { createContext } from "batch-do";

Usage

const [state: number, setState: (value: number) => void] = React.useState(0);
batch(() => {
  setState(state + 1);
});

Documentation

batch

batch(() => {
  console.log("log 1");
}, ctx?);
batch(() => {
  console.log("log 2");
}, ctx?);
// log 1
// log 2

Arguments list

  • ctx - Context list

createContext

const ctx = createContext(
  resolveBatchs,
  pendingResolve,
  awaitBatch,
  maxCallsPerBatch
);

Arguments list

  • resolveBatchs - Function to apply batched functions and frees up current batch pending list
  • pendingResolve - Function to resolve apply batchs function
  • awaitBatch - Merge all async batches into single call or ordered
  • maxCallsPerBatch - Argument to enable max limit for batches

License

MIT

Keywords

batch

FAQs

Package last updated on 22 Sep 2020

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

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.