How to use the bluebird.Promise function in bluebird

To help you get started, we’ve selected a few bluebird 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 DearDesi / desirae / lib / node-adapters / fsapi.js View on Github external
if (!opts.dotfiles && ('.' === name[0])) {
      return false;
    }

    if (opts.extensions && opts.extensions.length) {
      if (!opts.extensions.some(function (ext) {
        return new RegExp('\\.' + escapeRegExp(ext) + '$').test(name);
      })) {
        return false;
      }
    }

    return true;
  }

  return new PromiseA(function (resolve) {
    var walker = walk.walk(trueRoot)
      ;

    walker.on('nodeError', function (filepath, stat, next) {
      //stats.forEach(function (stat) {
      if (!filter(stat.name)) {
        return;
      }

      stat.error.path = path.join(strip(prefix, filepath), stat.name);
      files.push({
        name: stat.name
      , relativePath: strip(prefix, filepath)
      , path: path.join(strip(prefix, filepath), stat.name)

      , type: undefined
github process-engine / bpmn-studio / src / services / tutorial-service / tutorial.service.ts View on Github external
private waitUntilDiagramIsDeployed(cancelCallback?: Function): Promise {
    return new Bluebird.Promise((resolve: Function, reject: Function, onCancel: Function): void => {
      const subscription: Subscription = this.eventAggregator.subscribeOnce(
        environment.events.tutorial.diagramDeployed,
        () => {
          resolve();
        },
      );

      onCancel(() => {
        subscription.dispose();

        if (cancelCallback) {
          cancelCallback();
        }
      });
    });
  }
github nylas-mail-lives / nylas-mail / packages / cloud-workers / src / workers / send-later.es6 View on Github external
async deleteS3Attachment(accountId, objectId) {
    const uploadId = `${accountId}-${objectId}`;

    return new Promise((resolve, reject) => {
      s3.deleteObject({
        Bucket: BUCKET_NAME,
        Key: uploadId,
      }, (err, data) => {
        if (err) {
          reject(err);
        }

        resolve(data);
      })
    });
  }
github markfinger / unfort / file_system / utils.ts View on Github external
export function stat(path: string): Promise {
  return new Promise((res, rej) => {
    fs.stat(path, (err, data) => {
      if (err) return rej(err);
      res(data);
    });
  });
}
github marvinroger / homie-server / lib / servers / ota.js View on Github external
start () {
    return new Promise((resolve, reject) => {
      this.server.listen(PORT, () => {
        let host = this.server.address().address;
        let port = this.server.address().port;
        resolve({ host: host, port: port });
      }).on('error', (err) => {
        reject(err);
      });
    });
  }
github crucialfelix / supercolliderjs / src / lang / sclang.js View on Github external
interpret(
    code: string,
    nowExecutingPath: ?string,
    asString: boolean,
    postErrors: boolean,
    getBacktrace: boolean
  ): Promise {
    return new Promise((resolve, reject) => {
      var escaped = code
        .replace(/[\n\r]/g, '__NL__')
        .replace(/\\/g, '__SLASH__')
        .replace(/\"/g, '\\"');
      var guid = cuid();

      var args = [
        '"' + guid + '"',
        '"' + escaped + '"',
        nowExecutingPath ? '"' + nowExecutingPath + '"' : 'nil',
        asString ? 'true' : 'false',
        postErrors ? 'true' : 'false',
        getBacktrace ? 'true' : 'false'
      ].join(',');

      this.stateWatcher.registerCall(guid, { resolve, reject });
github markfinger / unfort / compiler / compiler.ts View on Github external
resolveIdentifier(identifier: string, file: File): Promise {
    const {fileName, baseDirectory, trap} = file;
    return new Promise((res, rej) => {
      browserResolve(
        identifier,
        {
          filename: fileName,
          basedir: baseDirectory,
          modules: browserifyBuiltins,
          readFile: (path, cb) => trap.readTextCallBack(path, cb),
          isFile: (path, cb) => trap.isFileCallBack(path, cb)
        },
        (err, fileName) => {
          if (err) return rej(err);
          res(fileName);
        }
      );
    });
  }
github process-engine / bpmn-studio / src / services / tutorial-service / tutorial.service.ts View on Github external
private waitForDiagramAlreadyExistsModalToStart(): Promise {
    return new Bluebird.Promise((resolve: Function): void => {
      this.eventAggregator.subscribeOnce(environment.events.tutorial.diagramAlreadyExistsModalStarted, () => {
        setTimeout(() => {
          resolve();
        }, 0);
      });
    });
  }
github MoonMail / MoonMail / events / lib / send_email_service.js View on Github external
_invokeLambda(params) {
    return new Promise((resolve, reject) => {
      this.lambdaClient.invoke(params, (err, data) => {
        if (err) {
          logger().error('SendEmailService._invokeLambda', 'Error invoking lambda', err, err.stack);
          reject(err);
        } else {
          logger().debug('SendEmailService._invokeLambda', 'Invoked successfully', params);
          resolve(data);
        }
      });
    });
  }
github abecms / abecms / src / cli / cms / operations / initSite.js View on Github external
askQuestions() {
    var p = new Promise(resolve => {
      inquirer
        .prompt([
          {
            type: 'input',
            name: 'name',
            message:
              "Enter the name of the project you want to create (only letters and '-' allowed)"
          },
          {
            type: 'confirm',
            name: 'theme',
            message: 'Do you want to install a theme ?',
            default: true
          },
          {
            type: 'list',