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

TypeScript async.eachLimit函数代码示例

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

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



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

示例1: Array

    .then(function (paths: string[]) {

      let requiredArray: any[] = new Array();

      async.eachLimit(paths, 1, function (path: string, next: Function) {

        if (path.indexOf('.') !== -1) {

          let requiredItem: any = require(path);

          if (requiredItem && requiredItem.default) {

            requiredArray.push(requiredItem.default);

          }

        }

        return next();

      }, function () {

        deferred.resolve(requiredArray);

      });

    });
开发者ID:tybeck,项目名称:portfolio-v2,代码行数:27,代码来源:required.ts


示例2: function

    deleteKongConsumers: function (deleteList: DeleteConsumerItem[], callback: ErrorCallback) {
        debug('deleteKongConsumers()');

        async.eachLimit(deleteList, MAX_PARALLEL_CALLS, function (deleteItem: DeleteConsumerItem, callback) {
            const consumerId = deleteItem.kongConsumer.consumer.id;
            info(`Deleting consumer with ID ${consumerId}`);
            utils.kongDeleteConsumer(consumerId, callback);
        }, callback);
    },
开发者ID:Haufe-Lexware,项目名称:wicked.portal-kong-adapter,代码行数:9,代码来源:kong.ts


示例3: callback

 wicked.getApis(function (err, apiList) {
     if (err)
         return callback(err);
     // Get the group list from wicked
     const groups = utils.getGroups().groups;
     // HACK_SCOPES: Make the scope lists Kong compatible (wicked has more info than Kong)
     for (let i = 0; i < apiList.apis.length; ++i) {
         // HACK_SCOPES: This cast is needed to allow changing the scopes to a simple string array (instead of the structure wicked uses).
         const api = apiList.apis[i] as any;
         if (api.auth === 'oauth2' && api.settings) {
             if (api.settings.scopes) {
                 const newScopes = [];
                 for (let scope in api.settings.scopes) {
                     // Take only the keys.
                     newScopes.push(scope);
                 }
                 api.settings.scopes = newScopes;
             } else {
                 api.settings.scopes = [];
             }
             // Now also add the groups as scopes.
             for (let g = 0; g < groups.length; ++g) {
                 api.settings.scopes.push(`wicked:${groups[g].id}`);
             }
             // HACK_PASSTHROUGH_REFRESH: For APIs with passthrough scopes and passthrough users,
             // refresh tokens are created via the "password" grant; this means we must allow it in Kong as well.
             {
                 const _api = api as WickedApi;
                 if (_api.passthroughUsers && _api.passthroughScopeUrl) {
                     _api.settings.enable_password_grant = true;
                 }
             }
         }
     }
     // Enrich apiList with the configuration.
     async.eachLimit(apiList.apis, MAX_PARALLEL_CALLS, function (apiDef: ApiDescription, callback) {
         wicked.getApiConfig(apiDef.id, function (err, apiConfig: KongApiConfig) {
             if (err)
                 return callback(err);
             apiDef.config = checkApiConfig(apiConfig);
             return callback(null);
         });
     }, function (err) {
         if (err)
             return callback(err);
         _actualApis = apiList;
         _actualApisDate = now;
         return callback(null, apiList);
     });
 });
开发者ID:Haufe-Lexware,项目名称:wicked.portal-kong-adapter,代码行数:50,代码来源:portal.ts


示例4: mkdirp

  const doExport = () => {
    exportWindow.webContents.removeListener("did-finish-load", doExport);
    exportWindow.webContents.send("setText", { title: "Superpowers — Exporting...", text: "Exporting..." });

    exportWindow.setProgressBar(0);
    let progress = 0;
    const progressMax = data.files.length;
    const buildPath = `/builds/${data.projectId}/${data.buildId}`;
    const systemsPath = "/systems/";

    async.eachLimit(data.files, 10, (file: string, cb: (err: Error) => any) => {

      let outputFilename = file;
      if (startsWith(outputFilename, buildPath)) {
        // Project build files are served on the build port
        outputFilename = outputFilename.substr(buildPath.length);
        file = `${data.baseURL}:${data.buildPort}${file}`;
      } else {
        // Other files are served on the main port
        file = `${data.baseURL}:${data.mainPort}${file}`;

        if (startsWith(outputFilename, systemsPath)) {
          // Output system files at the root
          outputFilename = outputFilename.substr(outputFilename.indexOf("/", systemsPath.length));
        }
      }
      outputFilename = outputFilename.replace(/\//g, path.sep);

      const outputPath = `${data.outputFolder}${outputFilename}`;
      exportWindow.webContents.send("setText", { text: outputPath });

      http.get(file, (response) => {
        mkdirp(path.dirname(outputPath), (err: Error) => {
          const localFile = fs.createWriteStream(outputPath);
          localFile.on("finish", () => {
            progress++;
            exportWindow.setProgressBar(progress / progressMax);
            cb(null);
          });
          response.pipe(localFile);
        });
      }).on("error", cb);
    } , (err: Error) => {
      exportWindow.setProgressBar(-1);
      if (err != null) { alert(err); return; }
      exportWindow.webContents.send("setText", { title: "Superpowers — Exported", text: "Exported to ", showItemInFolder: { text: data.outputFolder, target: data.outputFolder } } );
    });
  };
开发者ID:mk-pmb,项目名称:superpowers-app,代码行数:48,代码来源:export.ts


示例5: startExport

  function startExport() {
    exportWindow.webContents.removeListener("did-finish-load", startExport);
    exportWindow.webContents.send("set-export-status", { title: "Superpowers — Exporting...", text: "Exporting..." });

    let isFolderEmpty = false;
    try { isFolderEmpty = fs.readdirSync(options.outputFolder).length === 0; }
    catch (e) { exportWindow.webContents.send("set-export-status", { text: `Error while checking if output folder is empty: ${e.message}` }); return; }
    if (!isFolderEmpty) { exportWindow.webContents.send("set-export-status", { text: "Output folder must be empty." }); return; }

    exportWindow.setProgressBar(0);
    let progress = 0;
    const progressMax = options.files.length;
    const buildPath = `/builds/${options.projectId}/${options.buildId}`;
    const systemsPath = "/systems/";

    async.eachLimit(options.files, 10, processFile, onExportFinished);

    function processFile(file: string, cb: (err: Error) => any) {
      let outputFilename = file;
      if (startsWith(outputFilename, buildPath)) {
        // Project build files are served on the build port
        outputFilename = outputFilename.substr(buildPath.length);
        file = `${options.baseURL}:${options.buildPort}${file}`;
      } else {
        // Other files are served on the main port
        file = `${options.baseURL}:${options.mainPort}${file}`;

        if (startsWith(outputFilename, systemsPath)) {
          // Output system files at the root
          outputFilename = outputFilename.substr(outputFilename.indexOf("/", systemsPath.length));
        }
      }
      outputFilename = outputFilename.replace(/\//g, path.sep);

      const outputPath = `${options.outputFolder}${outputFilename}`;
      exportWindow.webContents.send("set-export-status", { text: outputPath });

      http.get(file, (response) => {
        mkdirp(path.dirname(outputPath), (err: Error) => {
          const localFile = fs.createWriteStream(outputPath);
          localFile.on("finish", () => { progress++; exportWindow.setProgressBar(progress / progressMax); cb(null); });
          response.pipe(localFile);
        });
      }).on("error", cb);
    }
  }
开发者ID:AgileJoshua,项目名称:superpowers-app,代码行数:46,代码来源:ipc.ts


示例6: callback

 utils.kongGetAllConsumers(function (err, allConsumers) {
     if (err)
         return callback(err);
     const kongConsumerInfos: ConsumerInfo[] = [];
     async.eachLimit(allConsumers.data, MAX_PARALLEL_CALLS, function (kongConsumer: KongConsumer, callback) {
         enrichConsumerInfo(kongConsumer, function (err, consumerInfo) {
             if (err)
                 return callback(err);
             kongConsumerInfos.push(consumerInfo);
             return callback(null);
         });
     }, function (err) {
         if (err)
             return callback(err);
         return callback(null, kongConsumerInfos);
     });
 });
开发者ID:Haufe-Lexware,项目名称:wicked.portal-kong-adapter,代码行数:17,代码来源:kong.ts


示例7: createProfile

        }],
        'subscriptions': [(callback) => {
            repo.getSubscriptions(uid, callback);
        }],
        'saveData': ['user', 'friends', 'subscriptions', (callback, results) => {
            fs.writeFile(tempFolder + uid + '.json', JSON.stringify(results), 'utf-8', callback);
        }],
        'profile': ['saveData', (callback, results) => {
            var profile = createProfile(results);
            callback(null, profile);
        }],
        'saveProfile': ['profile', (callback, results) => {
            fs.writeFile(tempFolder + uid + '-profile.json', JSON.stringify(results.profile), 'utf-8', callback);
        }]
    }, finalCallback);
}

/** Run */
var allData = [];
async.eachLimit(selections.humans, 10, function (uid, callback) {
    collectProfileData(uid, function (err, result) {
        logger.debug('Done: ', uid);
        allData.push(result.profile);
        callback(err, result);
    });
}, function (err) {
    if (err) {
        return logger.error(err);
    }
    logger.debug('Data: ', allData.length);
});
开发者ID:soramusoka,项目名称:social-data-analysis,代码行数:31,代码来源:index.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript async.eachOfLimit函数代码示例发布时间:2022-05-25
下一篇:
TypeScript async.each函数代码示例发布时间: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