How to use the async-es.nextTick 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 / higher.js View on Github external
if (!exited) {
        nextTick (_cb, _err, _env, null, null);
        exited = true;
      }
    }

    let $catch = (_errclass, catchFn) => {
      if (err instanceof _errclass) 
        catchFn();
    }

    let $yield = (retval) => {
      nextTick (_cb, null, _env, null, retval);
    }

    nextTick (f, $return, $throw, $catch, $yield, _env.par, ...args);
  }
}
github ironscript / ironscript / iron / import.js View on Github external
nextTick (evalAsync, p.parse(), _env, (err, _env, _cb, val) => {
        _env.defc('__base_dir__', basedir);
        nextTick (cb, null, _env, null, null);
      });
    }
github ironscript / ironscript / iron / stream.js View on Github external
constructor (core, env) {
    this.__itype__ = 'stream';
    this.env = env;
    this.core = core;
    this.value = undefined;

    this.callbacks = [];
    this.addcb = (cb) => { this.callbacks.push(cb); }

    this.push = (val) => {
      this.value = val;
      if (val !== null && val !== undefined) for (let cb of this.callbacks)
        nextTick (cb, null, this.env, null, val);
    }

    nextTick (this.core, (val) => {
      this.value = val;
      if (val !== null && val !== undefined) for (let cb of this.callbacks) 
        nextTick (cb, null, this.env, null, val);
    });
  }
github ironscript / ironscript / iron / evalAsync.js View on Github external
nextTick (evalAsync, xarray[0], env, (err, env, _, func) => {
				if (func instanceof Object && func.__itype__ === "env") {
					let acell = x.cdr;
					let reduced = func.rho.reduce (acell, env);
					if (reduced === null)  //cb( null, env, null, null);
						evalAsync ( Cell.list(xarray.slice(1)), env, cb);
					else 
						nextTick (evalAsync, reduced, env, cb);
				}
				
				else if (func instanceof Object && func.__itype__ === 'stream') {
					func.addcb(cb)
					cb( err, env, null, func.value);
				}
				
				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);
github ironscript / ironscript / iron / import.js View on Github external
if (imported.has(filename)) {
      let importEnv = imported.get(filename);
      if (namesList) {
        if (namesList instanceof Cell) {
          while (namesList instanceof Cell) {
            _env.syncAndBind(namesList.car, importEnv.get(namesList.car));
            namesList = namesList.cdr;
          }
        }
        else if (_all.equal(namesList)) _env.map = new Map([..._env.map, ...importEnv.map]);
      }
      nextTick (cb, null, _env, null, importEnv);
    }
    else {
			_env.defc('__base_dir__', sourceDir);
      nextTick (readSource, err, _env, (err, __env, _cb, src) => {
				_env.defc('__base_dir__', basedir);
        let p = new Parser ({name:sourcename, buffer:src});
       	
				let execenv = new Env (null, null, env);
				execenv.defc('__base_dir__', sourceDir);

				nextTick (evalAsync, p.parse(), execenv, (err, importEnv, _cb, val) => {
          imported.set (filename, importEnv);
          if (namesList) {
            if (namesList instanceof Cell) {
              while (namesList instanceof Cell) {

                _env.syncAndBind(namesList.car, importEnv.get(namesList.car));
                namesList = namesList.cdr;
              }
            }
github ironscript / ironscript / iron / interpret.js View on Github external
export function _eval (err, env, cb, src, name) {
  if (!name) name = 'unnamed';
  let p = new Parser ({name: name, buffer: src});
  nextTick (evalAsync, p.parse(), globalenv(), (err, _env, _cb, val) => {
    if (cb) nextTick (cb, err, env, null, _env);
  });
}
github ironscript / ironscript / iron / evalAsync.js View on Github external
evalAsync( args[i], _env, (err, __env, _, argval) => {
						i += 1;
						nextTick (callback, err, argval);
					});
				},
github ironscript / ironscript / iron / browser_env.js View on Github external
function _readsource (err, env, cb, id) {
    let source = document.getElementById(id).text;
    nextTick(cb, null, env, null, source);
  }
  env.bind(new IronSymbol ('_readsource'), _readsource);
github ironscript / ironscript / iron / higher.js View on Github external
export function fx (err, env, cb, f) {
  if (err) cb (err);
  nextTick (cb, null, env, null, ( err, _env, _cb,  ...args) => {
    let val = f(...args);
    nextTick (_cb, null, _env, null, val);
  });
}
github ironscript / ironscript / iron / import.js View on Github external
nextTick (evalAsync, p.parse(), execenv, (err, importEnv, _cb, val) => {
          imported.set (filename, importEnv);
          if (namesList) {
            if (namesList instanceof Cell) {
              while (namesList instanceof Cell) {

                _env.syncAndBind(namesList.car, importEnv.get(namesList.car));
                namesList = namesList.cdr;
              }
            }
            else if (_all.equal(namesList)) _env.map = new Map([..._env.map, ...importEnv.map]);
          }
          nextTick (cb, null, _env, null, importEnv);
        });
      } , basename(sourcename));

async-es

Higher-order functions and common patterns for asynchronous code

MIT
Latest version published 2 months ago

Package Health Score

89 / 100
Full package analysis