Every line of 'node.js async series 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.
9 function example() { 10 const err = erotic() 11 setTimeout(() => { 12 throw err('example error') 13 }, 10) 14 }
191 Tapable.prototype.applyPluginsAsyncSeries = Tapable.prototype.applyPluginsAsync = function applyPluginsAsyncSeries(name) { 192 var args = Array.prototype.slice.call(arguments, 1); 193 var callback = args.pop(); 194 var plugins = this._plugins[name]; 195 if(!plugins || plugins.length === 0) return callback(); 196 var i = 0; 197 var _this = this; 198 args.push(copyProperties(callback, function next(err) { 199 if(err) return callback(err); 200 i++; 201 if(i >= plugins.length) { 202 return callback(); 203 } 204 plugins[i].apply(_this, args); 205 })); 206 plugins[0].apply(this, args); 207 };
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 };
12 function AsyncIterator(array, step, start, end){ 13 this.array = array; 14 this.currentIndex = -1; 15 this.stepFn = step || EmptyFunction; 16 this.startFn = start || EmptyFunction; 17 this.endFn = end || EmptyFunction; 18 }
68 export function isAsync(val) { 69 return val?.[Symbol.toStringTag] === 'AsyncFunction' 70 }
149 exports.async = function asyncFunction(iter) { 150 return new Promise((resolve, reject) => { 151 resume('next', undefined); 152 function resume(type, value) { 153 try { 154 let result = iter[type](value); 155 if (result.done) { 156 resolve(result.value); 157 } else { 158 Promise.resolve(result.value).then( 159 x => resume('next', x), 160 x => resume('throw', x)); 161 } 162 } catch (x) { 163 reject(x); 164 } 165 } 166 }); 167 };
96 export function IsAsyncIterable(value: AsyncIterable | Other): value is AsyncIterable { 97 return IsObject(value) 98 && Symbol.asyncIterator in value; 99 }
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 }
155 function maybeAddAsync(asyncValue, body) { 156 if (!asyncValue) { 157 return body 158 } 159 160 var xret = { 161 type: 'ReturnStatement', 162 argument: CallExpression( 163 Identifier('_$tg'), 164 [asyncValue, MemberExpression(Identifier('arguments'), Literal(0), true)] 165 ) 166 } 167 168 return CallExpression( 169 MemberExpression(body, Identifier('then')), 170 [FunctionExpression(null, [], [xret])] 171 ) 172 }