forked from HowProgrammingWorks/AsynchronousProgramming
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathe-asyncjs-parallel.js
More file actions
33 lines (26 loc) · 612 Bytes
/
Copy pathe-asyncjs-parallel.js
File metadata and controls
33 lines (26 loc) · 612 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
'use strict';
const async = require('async');
console.log('Parallel array of function');
const arr = [
(callback) => callback(null, 'uno'),
(callback) => callback(null, 'due'),
(callback) => callback(null, 'tre')
];
async.parallel(
arr,
(err, res) => {
console.dir({ err, res });
}
);
console.log('Parallel hash of function');
const obj = {
key1: (callback) => callback(null, 'uno'),
key2: (callback) => callback(new Error('Oh, shit'), 'due'),
key3: (callback) => callback(null, 'tre')
};
async.parallel(
obj,
(err, res) => {
console.dir({ error: err.message, res });
}
);