🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

delay-map-batch

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

delay-map-batch

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

latest
Source
npmnpm
Version
0.1.2
Version published
Maintainers
1
Created
Source

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.

Keywords

map

FAQs

Package last updated on 20 Jul 2018

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