How to use the async-es.reflectAll 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 mflorence99 / el-aws / renderer / app / pages / s3 / services / s3.ts View on Github external
loadBucketMetadata(path: string,
                     cb: (metadata: BucketMetadata) => void): void {
    const { bucket } = this.path.analyze(path);
    const params = { Bucket: bucket };
    const funcs = async.reflectAll({
      acceleration: async.apply(this.getBucketAcceleration.bind(this), params),
      acl: async.apply(this.getBucketAcl.bind(this), params),
      encryption: async.apply(this.getBucketEncryption.bind(this), params),
      logging: async.apply(this.getBucketLogging.bind(this), params),
      tagging: async.apply(this.getBucketTagging.bind(this), params),
      versioning: async.apply(this.getBucketVersioning.bind(this), params),
      website: async.apply(this.getBucketWebsite.bind(this), params)
    });
    // now load them all in parallel
    async.parallelLimit(funcs, config.numParallelOps, (err, data: { value }) => {
      // NOTE: we are ignoring errors and only recording metadata actually found
      // reason: a bucket with no tags for example errors on the tagging call
      // TODO: while developing, log this nicely
      console.group(`%cloadBucketMetadata('${bucket}')`, `color: #004d40`);
      const metadata = Object.keys(funcs).reduce((acc, key) => {
        acc[key] = data[key].value || { };
github mflorence99 / el-aws / renderer / app / pages / s3 / services / s3.ts View on Github external
loadFileMetadata(path: string,
                   cb: (metadata: FileMetadata) => void): void {
    const { bucket, prefix, version } = this.path.analyze(path);
    const params = {
      Bucket: bucket,
      Key: prefix,
      VersionId: version
    };
    const funcs = async.reflectAll({
      acl: async.apply(this.getObjectAcl.bind(this), params),
      head: async.apply(this.getObjectHead.bind(this), params),
      tagging: async.apply(this.getObjectTagging.bind(this), params)
    });
    // now load them all in parallel
    async.parallelLimit(funcs, config.numParallelOps, (err, data: { value }) => {
      // NOTE: we are ignoring errors and only recording metadata actually found
      // reason: a file with no tags for example errors on the tagging call
      // TODO: while developing, log this nicely
      console.group(`%cloadFileMetadata('${path}')`, `color: #006064`);
      const metadata = Object.keys(funcs).reduce((acc, key) => {
        acc[key] = data[key].value || { };
        console.log(`%c${key} %c${JSON.stringify(acc[key])}`, 'color: black', 'color: grey');
        return acc;
      }, { } as FileMetadata);
      console.groupEnd();
github mflorence99 / el-aws / renderer / app / pages / ddb / services / ddb.ts View on Github external
deleteItems(tableName: string,
              keys: DDB.Key[],
              cb: Function): void {
    // build a list of delete functions
    const funcs = async.reflectAll(keys.map(key => {
      const params = {
        Key: key,
        TableName: tableName
      };
      return async.apply(this.deleteItem.bind(this), params);
    }));
    // now delete them, one at a time
    async.series(funcs, (err, data) => cb());
  }

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