• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript async.map函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中async.map函数的典型用法代码示例。如果您正苦于以下问题:TypeScript map函数的具体用法?TypeScript map怎么用?TypeScript map使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了map函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: function

 Page.find({}, function(err, pages) {
   if (err) {
     log.error(err);
     return;
   }
   // Make sure the page corresponds to a livedb document
   async.map(pages, function(page, callback) {
     LiveSync.fetch(page._id.toString(), function(err, liveDocument) {
       if (err) {
         callback(err);
         return;
       }
       if (!liveDocument.type) {
         LiveSync.createDocument(page._id.toString(), page.content, function(err) {
           if (err) {
             callback(err);
             return;
           }
           log.warn("Created missing livedb document for page: " + page._id);
           callback(null, null);
         });
       } else {
         log.debug("Found livedb document for " + page._id);
         callback(null, null);
       }
     });
   }, function(err, result) {
     if (err) {
       log.error(err);
     }
   });
 });
开发者ID:MisterTea,项目名称:TidalWave,代码行数:32,代码来源:sanitize.ts


示例2: call

    public call(
      methodsToCall: CallMethodRequestLike | CallMethodRequestLike[],
      callback?: ResponseCallback<any>
    ): any {

        const isArray = _.isArray(methodsToCall);
        if (!isArray) {
            methodsToCall = [methodsToCall as CallMethodRequestLike];
        }

        async.map(methodsToCall as CallMethodRequestLike[],
          (methodToCall, innerCallback: (err: Error | null, result?: CallMethodResult) => void) => {

              const callMethodRequest = new CallMethodRequest(methodToCall);

              callMethodHelper(
                this.server, this.session, this.addressSpace, callMethodRequest,
                (err: Error | null, result?: CallMethodResultOptions) => {

                    let callMethodResult: CallMethodResult;
                    if (err) {
                        callMethodResult = new CallMethodResult({
                            statusCode: StatusCodes.BadInternalError
                        });
                    } else {
                        callMethodResult = new CallMethodResult(result);
                    }
                    innerCallback(null, callMethodResult);
                });

          }, (err?: Error | null, callMethodResults?: any) => {
              callback!(null, isArray ? callMethodResults! : callMethodResults![0]);
          });
    }
开发者ID:node-opcua,项目名称:node-opcua,代码行数:34,代码来源:pseudo_session.ts


示例3: function

DataForm.prototype.getListFields = function (resource : Resource, doc: mongoose.Document, cb) {

  function getFirstMatchingField(keyList, type?) {
    for (var i = 0; i < keyList.length; i++) {
      var fieldDetails = resource.model.schema['tree'][keyList[i]];
      if (fieldDetails.type && (!type || fieldDetails.type.name === type) && keyList[i] !== '_id') {
        resource.options.listFields = [{field: keyList[i]}];
        return doc[keyList[i]];
      }
    }
  }

  var that = this;
  var display = '';
  var listFields = resource.options.listFields;

  if (listFields) {
    async.map(listFields, function(aField, cbm) {
      if (typeof doc[aField.field] !== 'undefined') {
        if (aField.params) {
          if (aField.params.ref) {
            var lookupResource = that.getResource(resource.model.schema['paths'][aField.field].options.ref);
            if (lookupResource) {
              var hiddenFields = that.generateHiddenFields(lookupResource, false);
              hiddenFields.__v = 0;
              lookupResource.model.findOne({ _id: doc[aField.field] }).select(hiddenFields).exec( function (err, doc2) {
                if (err) {
                  cbm(err);
                } else {
                  that.getListFields(lookupResource, doc2, cbm);
                }
              });
            }
          }
        } else {
          cbm(null, doc[aField.field]);
        }
      } else {
        cbm(null,'')
      }
    }, function(err,results){
      if (err) {
        cb (err);
      } else {
        if (results) {
          cb(err, results.join(' ').trim())
        } else {
          console.log('No results ' + listFields);
        }
      }
    });
  } else {
    var keyList = Object.keys(resource.model.schema['tree']);
    // No list field specified - use the first String field,
    display = getFirstMatchingField(keyList, 'String') ||
        // and if there aren't any then just take the first field
      getFirstMatchingField(keyList);
    cb(null, display.trim());
  }
};
开发者ID:zettacristiano,项目名称:forms-angular,代码行数:60,代码来源:data_form.ts


示例4: readChecksumsCached

function readChecksumsCached(node: FSNodeStructure,
                             parentPath: string,
                             callback: (error: Error, node?: FSNode) => void): void {
  const path = join(parentPath, node.name);
  if (node.type == 'directory') {
    async.map<FSNodeStructure, FSNode>(node.children, (childNode, callback) => {
      readChecksumsCached(childNode, path, callback);
    }, (error, nodes) => {
      if (error) return callback(error);
      // the directory checksum is somewhat arbitrary, but relatively simple
      const checksum = hashString(nodes.map(node => node.name + node.checksum).join('\n'));
      callback(null, Object.assign(node, {checksum, children: nodes}));
    });
  }
  else if (node.type == 'file') {
    // files require a checksum
    getSet(cacheClient, path, (path, callback) => {
      // fallback: actually read the file
      hashStream(createReadStream(path), callback);
    }, (error, checksum) => {
      // console.log(`getSet result for "${path}":`, error, checksum);
      callback(null, Object.assign(node, {checksum, children: undefined}));
    });
  }
  else if (node.type == 'symlink') {
    // it's a silly checksum, but it keeps things uniform
    const checksum = hashString(node.target);
    callback(null, Object.assign(node, {checksum, children: undefined}));
  }
  else {
    callback(null, Object.assign(node, {checksum: nullChecksum, children: undefined}));
  }
}
开发者ID:chbrown,项目名称:fs-ui,代码行数:33,代码来源:fs-helpers.ts


示例5: function

export var syncAll = function(callback) {
  // TODO: Gracefully kill connections with clients
  async.map(Object.keys(pageConnectionMap), function(docName, innerCallback) {
    log.warn("SHUTDOWN: Found document "+docName+" in edit mode.  Saving snapshot to DB");
    LiveSync.sync(docName, innerCallback);
  }, function(err, result) {
    callback(err);
  });
};
开发者ID:MisterTea,项目名称:TidalWave,代码行数:9,代码来源:sharejs-handler.ts


示例6: map

 .then(() => map(
     Array.from(entities.keys()),
     (entity_name, cb) =>
         sequelize_obj
             .sync(entities.get(entity_name) as any)
             .then(_ => cb(void 0))
             .catch(cb),
     err => callback(err, { connection: sequelize_obj, entities })
 ))
开发者ID:SamuelMarks,项目名称:restify-utils,代码行数:9,代码来源:index.ts


示例7: done

        async.map( fts, ( target, cb_fts ) => this.get_filtered_target_signature( target, args.cwd, cb_fts ), ( err: boolean, fts_sgns: Array<string> ) => {
            if ( err )
                return done( err );
            if ( fts_sgns.findIndex( x => ! x ) >= 0 ) {
                fts_sgns.forEach( ( sgn, ind ) => { if ( ! sgn ) this.error( `Not found how to read or make '${ fts[ ind ] }'` ); } );
                return done( true );
            }
            async.map( nbd, ( build_file, cb_nbd ) => this.new_build_file( "", "", "", cb_nbd ), ( err: boolean, nbd_names: Array<string> ) => {
                if ( err )
                    return done( err );
                //
                let inp_sgns = new Array<string>(), argv = new Array<string|number>();
                for( let tok of res.tokens ) {
                    switch ( tok.type ) {
                        case "Target":
                            argv.push( inp_sgns.length );
                            inp_sgns.push( fts_sgns.shift() );
                            break;
                        case "Quoted":
                            argv.push( tok.str );
                            break;
                        case "SubExpr":
                            argv.push( inp_sgns.length );
                            inp_sgns.push( this.make_signature( "Codegen", [], {
                                output  : nbd_names.shift(),
                                filename: tok.expr,
                                cwd     : args.cwd
                            } ) );
                            break;
                        default:
                            throw `While analyzing ${ cmd }: a token of type ${ tok.type } is not expected after the parsing stage`;
                    }
                }

                if ( res.tokens.length && res.tokens[ 0 ].type == "Quoted" ) {
                    if ( res.tokens.length < 2 || res.tokens[ 1 ].type != "Quoted" )
                        throw `If the first argument is quoted (script content), the second have also to be quoted (the extension of the script)`;
                    argv.splice( 0, 2, inp_sgns.push( this.make_signature( "MakeFile", [], { ext: argv[ 1 ], content: argv[ 0 ], } ) ) - 1 );
                }

                this.run_mission_node( Object.assign( {}, {
                    mission        : "run",
                    redirect       : args.output,
                    cwd            : args.cwd,
                    entry_point    : argv[ 0 ],
                    arguments      : argv.slice( 1 ),
                    local_execution: false,
                    idempotent     : true,
                    run_loc        : true, // for instance, if the entry_point is a js file, we want to ensure that we're not going to execute it on a browser
                }, res.json_data ), inp_sgns, ( err, res ) => {
                    this.outputs.push( args.output );
                    done( err );
                } );
            } );
        } );
开发者ID:hleclerc,项目名称:nsmake,代码行数:55,代码来源:Codegen.ts


示例8: processFiles

  processFiles(args, files, cb) {
    async.map(files, this.processFile.bind(this, args), (err, tasks) => {
      if (err) return cb(err)
      tasks = _.compact(tasks)
      if (tasks.length === 0) {
        return cb()
      }

      cb(null, this.createTaskGraph(this.buildGraphName(args, `files_in_${path.basename(this.currentDir)}`), args, tasks))
    })
  }
开发者ID:instructure,项目名称:ftl-engine,代码行数:11,代码来源:Processor.ts


示例9: repair_client_sessions

export function repair_client_sessions(client: OPCUAClientImpl, callback: (err?: Error) => void): void {

    const self = client;
    debugLog(chalk.red.bgWhite(" Starting sessions reactivation"));
    // repair session
    const sessions = self._sessions;
    async.map(sessions, (session: ClientSessionImpl, next: (err?: Error) => void) => {
        repair_client_session(client, session, next);
    }, (err) => {
        return callback(err!);
    });
}
开发者ID:node-opcua,项目名称:node-opcua,代码行数:12,代码来源:reconnection.ts


示例10: function

 function (files, next) {
   async.map(
     files,
     function (file, nextFile) {
       var filePath = path.join(nodeModulesPath, file, 'package.json');
       fs.readFile(filePath, 'utf8', function (err, file) {
         file = JSON.parse(file);
         nextFile(null, file);
       });
     },
     function (err, files) {
       next(err, files);
     }
   )
 }
开发者ID:pmoelgaard,项目名称:node_modules-list,代码行数:15,代码来源:index.ts



注:本文中的async.map函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript async.mapLimit函数代码示例发布时间:2022-05-25
下一篇:
TypeScript async.forEachSeries函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap