Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/odsod/foreach-batch
Batch processing that keeps the UI responsive. Browserifyable.
https://github.com/odsod/foreach-batch
Last synced: about 1 month ago
JSON representation
Batch processing that keeps the UI responsive. Browserifyable.
- Host: GitHub
- URL: https://github.com/odsod/foreach-batch
- Owner: odsod
- License: mit
- Created: 2014-03-10T13:19:22.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2014-04-05T10:43:47.000Z (almost 11 years ago)
- Last Synced: 2024-10-14T06:27:50.383Z (3 months ago)
- Language: JavaScript
- Size: 171 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
forEachBatch
============[![Build Status](https://travis-ci.org/odsod/foreach-batch.svg)](https://travis-ci.org/odsod/foreach-batch)
A simple combinator for deferred batch processing to keep the UI responsive under long-running
computations.Syntax
------```
forEach(arr, callback, batchSize[, progressCallback[, timeoutDelay])
```Description
-----------I wrote this to build a big [Lunr.js](https://github.com/olivernn/lunr.js) search index without
blocking the UI and without using WebWorkers.```javascript
var forEachBatch = require('foreach-batch');// Process everything at once - will possibly block the UI
stuff.forEach(someExpensiveFunction);// Process in batches of 10 - giving the UI some breathing room in between batches
forEachBatch(stuff, someExpensiveFunction, 10, function(progress) {
console.log(progress); // ...and we can keep track of our progress
}, 1000); // ...and we can control how long to wait between batches
```Installation
------------```
npm install foreach-batch
```