1.2.15 • Published 4 years ago
@cloudflare/util-async v1.2.15
cf-util-async
Cloudflare Async Util
Installation
$ npm install cf-util-async
Usage
Running async functions in a series:
import http from 'cf-util-http';
import {series} from 'cf-util-async';
series([
cb => http.get('endpoint-1.json', null, cb), // If an error occurs, then the rest of the callbacks are not called.
cb => http.get('endpoint-2.json', null, cb)
], (err, results) => {
if (err) {
console.log(err.body); // > { errors: [{ message: 'Error!' }] }
} else {
console.log(res.body); // > [{ result: { id: 1, ... } }, { result: { id: 2, ... } }]
}
});
Running async functions in parallel:
import http from 'cf-util-http';
import {parallel} from 'cf-util-async';
parallel([
cb => http.get('endpoint-1.json', null, cb),
cb => http.get('endpoint-2.json', null, cb)
], (err, results) => {
if (err) {
console.log(err.body); // > { errors: [{ message: 'Error!' }] }
} else {
console.log(res.body); // > [{ result: { id: 1, ... } }, { result: { id: 2, ... } }]
}
});
1.2.15
4 years ago
1.2.13
4 years ago
1.2.14
4 years ago
1.2.12
4 years ago
1.2.11
5 years ago
1.2.8
5 years ago
1.2.9
5 years ago
1.2.7
5 years ago
1.2.5
5 years ago
1.2.4
5 years ago
1.2.3
6 years ago
1.2.2
6 years ago
1.2.1
6 years ago
1.2.0
7 years ago
1.1.1
7 years ago
1.1.0
7 years ago
1.0.13
7 years ago
1.0.12
7 years ago
1.0.11
7 years ago
1.0.10
7 years ago
1.0.9
7 years ago
1.0.8
7 years ago
1.0.7
7 years ago
1.0.6
7 years ago
1.0.4
7 years ago
1.0.3
7 years ago
1.0.2
7 years ago
1.0.1
7 years ago