# delay-map-batch

> Enumerate array by batch, there will be a delay in milliseconds before processing the next batch.

Latest version **0.1.2** (published 2018-07-20) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install delay-map-batch
pnpm add delay-map-batch
yarn add delay-map-batch
bun add delay-map-batch
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.1.2 |
| Published | 2018-07-20 |
| First published | 2018-06-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 9.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | frank-deng |
| Maintainers | frank-deng |
| Keywords | map, batch, delay, timeout |

## Links

- npm: https://www.npmjs.com/package/delay-map-batch
- Repository: https://github.com/frank-deng/delay-map-batch
- Homepage: https://github.com/frank-deng/delay-map-batch#readme
- Issues: https://github.com/frank-deng/delay-map-batch/issues
- npm.io page: https://npm.io/package/delay-map-batch

## Recent versions

- 0.1.2 (latest) — 2018-07-20
- 0.1.1 — 2018-06-26
- 0.1.0 — 2018-06-24

## README

delay-map-batch
===============

Enumerate array by batch, there will be a delay in milliseconds before processing the next batch.

Installation
------------

Node

	var DelayMapBatch = require('delay-map-batch');

Browser

	<script type='text/javascript' src='delay-map-batch.min.js'></script>


Usage
-----

	DelayMapBatch([1,2,3,4,5], (n, index)=>{
		//Do some stuff
		console.log(n);
	}, {
		batchSize: 1000,
	}).then(()=>{
		//Mapping finished
	});

With 2s delay between batches:

	DelayMapBatch([1,2,3,4,5], (n, index)=>{
		//Do some stuff
		console.log(n);
	}, {
		batchSize: 1000,
		delay: 2000,
	}).then(()=>{
		//Mapping finished
	});


API Documentation
-----------------

### `DelayMapBatch(array, mapFunction, [params])`

Parameters

* `array`: The array to be enumerated.
* `mapFunction`: The function called for each element of the array, accept 2 parameters, first is the element enumerated, second is the index of the element in the array.
* `params`: Parameters for enumerating array.

Returns

A `Promise()` object, you can use `then()` to add functions to be executed after enumeration finished, or add `catch()` to catch exceptions when there is anything thrown from the map function.

Tests
-----

Run `npm test` to run the test cases.

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