# callback-chunk

> A simple JS library to chunk an array of callbacks asynchronously

Latest version **0.1.2** (published 2022-03-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install callback-chunk
pnpm add callback-chunk
yarn add callback-chunk
bun add callback-chunk
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.2 |
| Published | 2022-03-21 |
| First published | 2021-02-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Giancarlo Fontela da Luz |
| Maintainers | giancarl021 |
| Keywords | batch, chunk |

## Links

- npm: https://www.npmjs.com/package/callback-chunk
- Repository: https://github.com/Giancarl021/callback-chunk
- npm.io page: https://npm.io/package/callback-chunk

## Recent versions

- 0.1.2 (latest) — 2022-03-21
- 0.1.1 — 2021-02-05
- 0.1.0 — 2021-02-05

## README

# callback-chunk

A simple JS library to chunk an array of callbacks asynchronously

## Installation

npm:
```bash
npm install callback-chunk --save
```

Yarn:
```bash
yarn add callback-chunk
```
## Usage

Import the module:
```javascript
const chunk = require('callback-chunk');
```

Call the function with your Array of callbacks:
```javascript
const ticks = 50; // Number of calls at once
const callbacks = [
    () => { /* your code here */ },
    // ...
];

await chunk(
    callbacks, // The callbacks Array (Array of functions)
    ticks, // The number of functions called at once
    console.log // Custom logger, defaults to null
);
```

## Example

```javascript
const chunk = require('callback-chunk');

async function main() {
    const callbacks = new Array(30)
        .fill(
            () => new Promise(
                resolve => setTimeout(() => resolve(), Math.floor(Math.random() * 5000))
            )
        );
    
    console.log('Started chunking...');

    await chunk(callbacks, 10, console.log);

    console.log('Finished chunking');
}

main().catch(console.error);
```

---
_Source: https://npm.io/package/callback-chunk · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
