reducebatch
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

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

  • [x] Found a bug? Have a feature request? Please open an issue and let me know!
  • [x] Create a dedicated PR for each feature/change to the API.
  • [x] Please also read through the Code of Conduct beforehand.
  • [x] 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

Package Sidebar

Install

npm i reducebatch

Weekly Downloads

1

Version

0.1.1

License

MIT

Unpacked Size

12.2 kB

Total Files

15

Last publish

Collaborators

  • nberlette