git ssb

0+

cel-desktop / ssb-pkg



Tree: 65191f9a9664f013ebe726bb95a1a54b086e1bd5

Files: 65191f9a9664f013ebe726bb95a1a54b086e1bd5 / test / test-79-npm / batch / batch.js

435 bytesRaw
1'use strict';
2
3var Batch = require('batch');
4var batch = new Batch();
5
6batch.concurrency(4);
7
8var ids = [ 4, 7, 12, 25 ];
9
10ids.forEach(function () {
11 batch.push(function (done) {
12 setTimeout(function () {
13 done();
14 }, 100);
15 });
16});
17
18var passed = 0;
19
20batch.on('progress', function () {
21 passed += 1;
22});
23
24batch.end(function (error) {
25 if (error) {
26 throw error;
27 }
28 if (passed > 3) {
29 console.log('ok');
30 }
31});
32

Built with git-ssb-web