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),
cb => http.get('endpoint-2.json', null, cb)
], (err, results) => {
if (err) {
console.log(err.body);
} else {
console.log(res.body);
}
});
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);
} else {
console.log(res.body);
}
});