How to use the async-es.mapLimit function in async-es

To help you get started, we’ve selected a few async-es examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ironscript / ironscript / iron / evalAsync.js View on Github external
evalAsync( _func, env, (err, _env, _, func) => {
						if (func instanceof Function) {
							let cbfn = (arg, _cb) => {
								nextTick (func, null, env, (err, _env, _, val) => {_cb(err, val);}, arg.val, arg.index);
							}
							if (_map.equal(xarray[0]))
								mapLimit (arr, 32, cbfn, (err, newarr) => {
									if (seq.__itype__==='sequence') cb( err, env, null, new Sequence(newarr));
									else cb( err, env, null, newarr);
								});
							else 
								filterLimit (arr, 32, cbfn, (err, newarr) => {
									let retarr = [];
									for (let it of newarr) retarr.push(it.val);
									if (seq.__itype__==='sequence') cb( err, env, null, new Sequence(retarr));
									else cb( err, env, null, retarr);
								});
						}
						else cb( Cell.stringify(_func)+' is not a Function');
					});
				}
github ironscript / ironscript / iron / evalAsync.js View on Github external
else if (func instanceof Object && func.__itype__ === 'specialform') {
					func = func.func;
					let args = xarray.slice(1);
					let _env = new Env (null, null, env);
					func (null, _env, cb, ...args);
				}

				else if (func instanceof Function) {
					let args = xarray.slice(1);
					let evalArg = (arg, _cb) => {
						evalAsync( arg, env, (err, env, _, argval) => {
							_cb( err, argval);
						});
					};
					
					mapLimit (args, 64, evalArg, (err, argvals) => {
						let _env = new Env (null, null, env);
						nextTick (func, err, _env, cb, ...argvals);
					});
				}
				else {
					cb (null, env, null, x);
				}
			});
		}
github ironscript / ironscript / iron / evalAsync.js View on Github external
}
				else cb( Cell.stringify(_seqn)+' is not an Array or Sequence');
			});
		}
		else if (_dot.equal(xarray[0])) {
			let args = xarray.slice(1);
			let cmd = x.ctx;
			if (x.ctx === null) cmd = 'get';

			let evalArg = (arg, _cb) => {
				evalAsync( arg, env, (err, env, _, argval) => {
					nextTick (_cb, err, argval);
				});
			};
			
			mapLimit (args, 32, evalArg, (err, argvals) => {
				let ref = new Reference (cmd, ...argvals);
				cb( err, env, null, ref.value);
			});
		}

		else if (_if.equal(xarray[0])) {
			let test = xarray[1];
			let then = xarray[2];
			let othr = xarray[3];
			evalAsync( test, env, (err, env, _, res) => {
				let expr = res ? then : othr;
				evalAsync( expr, env, cb);
			});
		}
		else if (_try.equal(xarray[0])) {
			let expr = xarray[1];
github ironscript / ironscript / iron / specialforms / def.js View on Github external
cellToArr (value, [], env, (err, _env, _, args) => {
			
					mapLimit (args, 32, evalArg(env), (err, argvals) => {
						let names = name;
						let arglist = Cell.list(argvals);
						while (names instanceof Cell) {
							def (names.car, arglist.car, env, (err) => {
								if (err) cb (err);
							});
							names = names.cdr;
							arglist = arglist.cdr;
						}
						if (names !== null) def (names, arglist, env, (err) => {
							if (err) cb (err);
						});
						
						cb (null, env, null, value);
					});
				});

async-es

Higher-order functions and common patterns for asynchronous code

MIT
Latest version published 3 months ago

Package Health Score

86 / 100
Full package analysis