Skip to content

Instantly share code, notes, and snippets.

@kunle
Created April 21, 2017 18:07
Show Gist options
  • Save kunle/522daf95ef420c6cfe9c61c843296e1f to your computer and use it in GitHub Desktop.
Save kunle/522daf95ef420c6cfe9c61c843296e1f to your computer and use it in GitHub Desktop.
JS Bin Async parallel loop // source https://jsbin.com/tepufik
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="Async parallel loop">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script src="https://rawgit.com/caolan/async/v1.5.2/dist/async.min.js"></script>
<script id="jsbin-javascript">
let x = [100, 20, 40, 50, 60];
let funcs = x.map((e)=> (cb) => { setTimeout(()=>{console.log(`done ${e}`);cb(null,e+' done');}, e*10);});
async.parallel(funcs, (err, results) => { console.log('results', results);});
</script>
<script id="jsbin-source-javascript" type="text/javascript">let x = [100, 20, 40, 50, 60];
let funcs = x.map((e)=> (cb) => { setTimeout(()=>{console.log(`done ${e}`);cb(null,e+' done');}, e*10);});
async.parallel(funcs, (err, results) => { console.log('results', results);});</script></body>
</html>
let x = [100, 20, 40, 50, 60];
let funcs = x.map((e)=> (cb) => { setTimeout(()=>{console.log(`done ${e}`);cb(null,e+' done');}, e*10);});
async.parallel(funcs, (err, results) => { console.log('results', results);});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment