How to use run-async - 2 common examples

To help you get started, we’ve selected a few run-async 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 aam229 / inquirer-path / src / PathPrompt.js View on Github external
submitAnswer(submitMulti: boolean = false) {
    const answer = this.opt.multi && submitMulti ?
      this.paths :
      this.autocomplete.getPath().getAbsolutePath();

    const validate = runAsync(this.opt.validate);
    const filter = runAsync(this.opt.filter);

    let promiseChain = validate(answer, this.answers, this.opt.multi ? this.paths : null)
      .then((isValid) => {
        if (isValid !== true) {
          throw isValid;
        }
        return answer;
      })
      .then(filter);

    if (!this.opt.multi) {
      // Render the final path
      promiseChain = promiseChain.then((finalAnswer) => {
        this.renderer.render(finalAnswer);
        return finalAnswer;
      });
github aam229 / inquirer-path / src / PathPrompt.js View on Github external
submitAnswer(submitMulti: boolean = false) {
    const answer = this.opt.multi && submitMulti ?
      this.paths :
      this.autocomplete.getPath().getAbsolutePath();

    const validate = runAsync(this.opt.validate);
    const filter = runAsync(this.opt.filter);

    let promiseChain = validate(answer, this.answers, this.opt.multi ? this.paths : null)
      .then((isValid) => {
        if (isValid !== true) {
          throw isValid;
        }
        return answer;
      })
      .then(filter);

    if (!this.opt.multi) {
      // Render the final path
      promiseChain = promiseChain.then((finalAnswer) => {
        this.renderer.render(finalAnswer);
        return finalAnswer;

run-async

Utility method to run function either synchronously or asynchronously using the common `this.async()` style.

MIT
Latest version published 2 years ago

Package Health Score

65 / 100
Full package analysis

Popular run-async functions