Every line of 'node js async parallel example' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.
27 function benchAsyncParallel (done) { 28 async.parallel([somethingA, somethingA, somethingA], done) 29 }
9 function example() { 10 const err = erotic() 11 setTimeout(() => { 12 throw err('example error') 13 }, 10) 14 }
16 function parallel(done) { 17 var async = require('async'); 18 var asyncDone = require('async-done'); 19 20 var context = this; 21 var tasks = context.tasks; 22 23 async.map(tasks, function (task, itemDone) { 24 asyncDone(function (taskDone) { 25 return task.run.call(context, taskDone); 26 }, itemDone); 27 }, done); 28 }
1052 asyncFunction(node, body) { 1053 let head = 'function'; 1054 1055 if (node.identifier) 1056 head += ' ' + node.identifier.text; 1057 1058 let outerParams = node.params.map((x, i) => { 1059 let p = x.pattern || x.identifier; 1060 return p.type === 'Identifier' ? p.value : '__$' + i; 1061 }).join(', '); 1062 1063 let wrapper = node.kind === 'async-generator' ? 'asyncGen' : 'async'; 1064 1065 if (body === undefined) 1066 body = node.body.text; 1067 1068 this.markRuntime('async'); 1069 1070 return `${ head }(${ outerParams }) { ` + 1071 `return _esdown.${ wrapper }(function*(${ this.joinList(node.params) }) ` + 1072 `${ body }.apply(this, arguments)); }`; 1073 }
588 function asyncJS(js, fn) { 589 return new AsyncQueue(js, fn); 590 }
50 function webpackAsync(webpackConfig): Promise { 51 return new Promise((resolve, reject) => { 52 const compiler = webpack(webpackConfig) 53 compiler.run((err, stats) => { 54 const statsJson = stats.toJson() 55 const { errors, warnings } = statsJson 56 57 if (err) { 58 log('Webpack compiler encountered a fatal error.') 59 reject(new PluginError('webpack', err.toString())) 60 } 61 if (errors.length > 0) { 62 log('Webpack compiler encountered errors.') 63 reject(new PluginError('webpack', errors.toString())) 64 } 65 if (warnings.length > 0) { 66 log('Webpack compiler encountered warnings.') 67 reject(new PluginError('webpack', warnings.toString())) 68 } 69 70 resolve(statsJson) 71 }) 72 }) 73 }
112 (function ManyInstancesAsync() { 113 print('ManyInstancesAsync...'); 114 let promise = WebAssembly.compile(buffer); 115 assertPromiseResult(promise, compiled_module => { 116 let instance_1 = new WebAssembly.Instance(compiled_module); 117 let instance_2 = new WebAssembly.Instance(compiled_module); 118 assertTrue(instance_1 != instance_2); 119 }); 120 })();
34 return function asyncFunction() { 35 const args = Array.from(arguments); 36 return new Promise(function (resolve, reject) { 37 let gen; 38 39 function step(next) { 40 const value = next.value; 41 if (next.done) { 42 return resolve(value); 43 } 44 if (value instanceof Promise) { 45 return value.then( 46 result => step(gen.next(result)), 47 error => { 48 try { 49 step(gen.throw(error)); 50 } catch (err) { 51 throw err; 52 } 53 } 54 ).catch((err) => { 55 warn("Unhandled error in async function.", err); 56 reject(err); 57 }); 58 } 59 step(gen.next(value)); 60 } 61 62 if (typeof func !== "function") { 63 reject(new TypeError("Expected a Function.")); 64 } 65 // not a generator, wrap it. 66 if (func.constructor.name !== "GeneratorFunction") { 67 gen = (function*() { 68 return func.call(self, ...args); 69 }()); 70 } else { 71 gen = func.call(self, ...args); 72 } 73 try { 74 step(gen.next()); 75 } catch (err) { 76 warn("The generator threw immediately.", err); 77 reject(err); 78 } 79 }); 80 };
261 function async (args, state, output) { 262 assert(args.sync); 263 output.success({ async: 'async' }); 264 }
29 module.exports = function parallel(tasks) { 30 if (Array.isArray(tasks)) { 31 return parallelArrayTasks(tasks); 32 } else if (typeof tasks === 'object') { 33 return parallelObjectTasks(tasks); 34 } 35 36 return Promise.reject(new Error('First argument to parallel must be an array or an object')); 37 };