Skip to content

Perform large-scale array reductions in split batches, with optional throttling.

License

Notifications You must be signed in to change notification settings

nberlette/reducebatch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

reduceBatch()

Perform array reductions in batches, with throttling.

Latest NPM Release Types: Included Contributors Issues License


Installation

PNPM (recommended)
pnpm install reducebatch
Yarn (also good)
yarn add reducebatch
NPM (if you must...)
npm install --save reducebatch

Usage

This package supports both ES Module and CommonJS (node) syntaxes.

ES Modules

import { reduceBatch, reduceBatchSync } from "reducebatch";
Treeshakable!
import reduceBatchSync from "reducebatch/sync";

CommonJS

const { reduceBatch, reduceBatchSync } = require("reducebatch");

Examples

// fill an array with 5000 consecutive numeric values
const bigArray = Array.from(Array(5000), (_, i) => i);

reduceBatch(bigArray, (acc, cur) => acc + cur, 0 /* initialVal  */, 100 /* batchSize */, 500 /* rateLimit */).then(
  console.log
);

// ... 12497500
// batchSize: 100 (50 batches of 100)
// rateLimit: 500 (maximum per second)

Contributing

One of the most overlooked aspects of the Open Source community is the impact of contributions. Projects (like reduceBatch), and their maintainers (like me 👋 ), depend on contributions from other members like yourself.

Furthermore, they're the cornerstone of why our community continues to be such an amazing place to learn, inspire, and create.

Any contributions you make are greatly appreciated.

Guidelines

  • Found a bug? Have a feature request? Please open an issue and let me know!
  • Create a dedicated PR for each feature/change to the API.
  • Please also read through the Code of Conduct beforehand.
  • Please make sure you check your spelling and grammar.

Creating a Pull Request

  1. Fork the project
  2. Create your feature branch
  git checkout -b feature/something-dope
  1. Commit your changes
  git commit -m 'Some info about what you added...'
  1. Push to the Branch
  git push -u origin feature/something-dope
  1. Open a Pull Request
# Using the GitHub CLI
gh pr create --title "[feature]: something dope!"

License

MIT © Nicholas Berlette

About

Perform large-scale array reductions in split batches, with optional throttling.

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Sponsor this project

Packages