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

TypeScript async.mapLimit函数代码示例

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

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



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

示例1: callback

    wicked.getAuthServerNames(function (err, authServerNames) {
        if (err)
            return callback(err);
        async.mapLimit(authServerNames, MAX_PARALLEL_CALLS, function (authServerName, callback) {
            wicked.getAuthServer(authServerName, callback);
        }, function (err, authServers: WickedAuthServer[]) {
            if (err)
                return callback(err);
            debug(JSON.stringify(authServers, null, 2));
            // Fix auth server and API auth server IDs; also adapt
            // the upstream_url (canonicalize it).
            for (let i = 0; i < authServers.length; ++i) {
                const as = authServers[i] as WickedAuthServer;
                const id = `${authServerNames[i]}-auth`;
                as.id = id;
                if (as.config.api.hasOwnProperty('id'))
                    delete as.config.api.id;
                as.config.api.name = id;

                try {
                    const url = new URL(as.config.api.upstream_url);
                    as.config.api.upstream_url = url.toString();
                } catch (err) {
                    const msg = `getAuthServerApis(): upstream_url for auth server ${authServerNames[i]} is not a valid URL: ${as.config.api.upstream_url}`;
                    return callback(new WickedError(msg, 500));
                }

                checkApiConfig(as.config);
            }
            callback(null, authServers);
        });
    });
开发者ID:Haufe-Lexware,项目名称:wicked.portal-kong-adapter,代码行数:32,代码来源:portal.ts


示例2: mapLimit

const parseAndReportFiles = (fileGlobs: string[], program: ReporterProgramArgs): void => {
    // Get all files and their resolved globs
    const files = globby.sync(fileGlobs, {
        cwd: process.cwd(),
        ignore: program.ignore || [],
        onlyFiles: true,
    });

    if (!files || !files.length) {
        console.log(logSymbols.warning, 'No files found for reporting');
        process.exit(1);
    }

    // Parallel read all of the given files
    mapLimit(
        files,
        concurrencyLimit,
        (file, cb) => readFile(resolve(process.cwd(), file), 'utf8', cb),
        (err, results: string[]) => {
            if (err) {
                console.log(err);
                process.exit(1);
            }
            const todos = results
                .map(content => JSON.parse(content))
                // filter files without any parsed content
                .filter(item => item && item.length > 0)
                .reduce((items, item) => items.concat(item), []);

            outputTodos(todos, program);
        }
    );
};
开发者ID:pgilad,项目名称:leasot,代码行数:33,代码来源:cli-reporter.ts


示例3: function

 deleteAppConsumers: function (appId, subscriptionList, callback) {
     debug('deleteAppConsumers(): ' + appId);
     async.mapLimit(subscriptionList, MAX_ASYNC_CALLS, function (subsInfo, callback) {
         sync.deleteAppSubscriptionConsumer(subsInfo, callback);
     }, function (err, results) {
         if (err)
             return callback(err);
         debug('deleteAppConsumers() for app ' + appId + ' succeeded.');
         callback(null);
     });
 },
开发者ID:Haufe-Lexware,项目名称:wicked.portal-kong-adapter,代码行数:11,代码来源:sync.ts


示例4: function

 getKongConsumers: function (portalConsumers: ConsumerInfo[], callback: Callback<ConsumerInfo[]>): void {
     debug('getKongConsumers()');
     async.mapLimit(
         portalConsumers,
         MAX_PARALLEL_CALLS,
         (portalConsumer, callback) => getKongConsumerInfo(portalConsumer, callback),
         function (err, results) {
             if (err) {
                 error(err);
                 error(err.stack);
                 return callback(err);
             }
             debug('getKongConsumers() succeeded.');
             return callback(null, results as ConsumerInfo[]);
         });
 },
开发者ID:Haufe-Lexware,项目名称:wicked.portal-kong-adapter,代码行数:16,代码来源:kong.ts


示例5: has_auth

    app.post(`${namespace}s`, has_body, has_auth(), //mk_valid_body_mw(user_schema),
        function (req: restify.Request, res: restify.Response, next: restify.Next) {
            type IResult = Array<[IContact, IPatient]>;

            async.mapLimit(req.body.patients, 1, createPatient, (error, results: IResult) => {
                if (error) return next(fmtError(error));

                res.json(201, {patients: results});
                return next();
            });


            /*
             Patient.createEach(req.body.patients).exec((error, patients: Array<IPatient>) => {
             if (error) return next(fmtError(error));
             res.json(201, {'patients': patients});
             return next();
             });
             */
        }
开发者ID:healthplatform,项目名称:rest-api,代码行数:20,代码来源:routes.ts


示例6: mapLimit

 return new Promise<BlockDetailsByBlock>((resolve, reject) => {
   if (blockNumbers.length === 0) return resolve([]);
   console.log(`Fetching blocks details from ${blockNumbers[0]} to ${blockNumbers[blockNumbers.length - 1]}`);
   let fetchedBlockCount = 0;
   let highestBlockFetched = 0;
   mapLimit(blockNumbers, BLOCK_DOWNLOAD_PARALLEL_LIMIT, (blockNumber, nextBlockNumber) => {
     augur.rpc.eth.getBlockByNumber([blockNumber, false], (err: Error|null, block: BlockDetail): void => {
       if (err) return nextBlockNumber(new Error("Could not get block"));
       if (block == null) return nextBlockNumber(new Error(`Block ${blockNumber} returned null response. This is usually an issue with a partially sync'd parity warp node. See: https://github.com/paritytech/parity-ethereum/issues/7411`));
       fetchedBlockCount++;
       if (fetchedBlockCount % 10 === 0) console.log(`Fetched ${fetchedBlockCount} / ${blockNumbers.length} block details (current: ${highestBlockFetched})`);
       if (blockNumber > highestBlockFetched) highestBlockFetched = blockNumber;
       nextBlockNumber(undefined, [blockNumber, block]);
     });
   }, (err: Error|undefined, blockDetails: Array<[number, BlockDetail]>) => {
     if (err) return reject(err);
     const blockDetailsByBlock = _.fromPairs(blockDetails);
     resolve(blockDetailsByBlock);
   });
 });
开发者ID:AugurProject,项目名称:augur_node,代码行数:20,代码来源:download-augur-logs.ts


示例7: mapLimit

const parseAndReportFiles = (fileGlobs: string[], program: ProgramArgs): void => {
    // Get all files and their resolved globs
    const files = globby.sync(fileGlobs, {
        cwd: process.cwd(),
        ignore: program.ignore || [],
        onlyFiles: true,
        deep: true,
        unique: true,
        matchBase: true,
    });

    if (!files || !files.length) {
        console.log(logSymbols.warning, 'No files found for parsing');
        process.exit(1);
    }

    // Parallel read all of the given files
    mapLimit(
        files,
        CONCURRENCY_LIMIT,
        (file, cb) => readFile(resolve(process.cwd(), file), 'utf8', cb),
        (err, results: string[]) => {
            if (err) {
                console.log(err);
                process.exit(1);
            }
            const todos = results
                .map(function(content: string, index: number) {
                    return parseContentSync(content, program, files[index]);
                })
                // filter files without any parsed content
                .filter(item => item && item.length > 0)
                .reduce((items, item) => items.concat(item), []);

            outputTodos(todos, program);
        }
    );
};
开发者ID:pgilad,项目名称:leasot,代码行数:38,代码来源:cli.ts


示例8: parseInt

import * as async from  "async";

var concurrencyCount = 0;
var fetchUrl = (url, callback) => {
    var delay = parseInt(((Math.random() * 10000000) % 2000).toString(), 10);
    concurrencyCount++;
    console.log('现在的并发数是', concurrencyCount, ',正在抓取的是', url, ',耗时' + delay + '毫秒');
    setTimeout(() => {
        concurrencyCount--;
        callback(null, url + 'html content');

    }, delay);
}


var urls = [];
for (var i = 0; i < 30; i++) {
    urls.push('http://datasource_' + i);
}


async.mapLimit(urls,5,(url,callback)=>{
    fetchUrl(url,callback);
},(err,result)=>{
    console.log('final:');
    console.log(result);
})


开发者ID:wangyibu,项目名称:node-lessons,代码行数:27,代码来源:demo.ts


示例9: enrichApplications

function enrichApplications(applicationList: WickedApplication[], apiPlans: WickedApiPlanCollection, apiList: ApiDescriptionCollection, callback: Callback<ConsumerInfo[]>) {
    debug('enrichApplications(), applicationList = ' + utils.getText(applicationList));
    async.mapLimit(applicationList, MAX_PARALLEL_CALLS, function (appInfo, callback) {
        getApplicationData(appInfo.id, callback);
    }, function (err, results) {
        if (err)
            return callback(err);

        const consumerList = [];
        for (let resultIndex = 0; resultIndex < results.length; ++resultIndex) {
            const appInfo = results[resultIndex].application;
            const appSubsInfo = results[resultIndex].subscriptions;
            for (let subsIndex = 0; subsIndex < appSubsInfo.length; ++subsIndex) {
                const appSubs = appSubsInfo[subsIndex];
                // Only propagate approved subscriptions
                if (!appSubs.approved)
                    continue;

                let groupName = appSubs.api;
                // Check if this API is part of a bundle
                const apiDesc = apiList.apis.find(a => a.id === appSubs.api);
                if (apiDesc) {
                    // API_BUNDLE: Use bundle as group name; this will mean that access tokens/API Keys for this API
                    // will also work for any other API which is part of this bundle.
                    if (apiDesc.bundle)
                        groupName = apiDesc.bundle;
                } else {
                    warn(`enrichApplications: Could not find API configuration for API ${appSubs.api}`);
                }

                debug(utils.getText(appSubs));
                const consumerInfo: ConsumerInfo = {
                    consumer: {
                        username: utils.makeUserName(appSubs.application, appSubs.api),
                        custom_id: appSubs.id
                    },
                    plugins: {
                        acls: [{
                            group: groupName
                        }]
                    }
                };
                if ("oauth2" == appSubs.auth) {
                    let redirectUris = appInfo.redirectUris;
                    if (!redirectUris || redirectUris.length == 0)
                        redirectUris = ['https://dummy.org'];
                    consumerInfo.plugins.oauth2 = [{
                        name: appSubs.application,
                        client_id: appSubs.clientId,
                        client_secret: appSubs.clientSecret,
                        redirect_uri: redirectUris
                    }];
                } else if (!appSubs.auth || "key-auth" == appSubs.auth) {
                    consumerInfo.plugins["key-auth"] = [{
                        key: appSubs.apikey
                    }];
                } else {
                    let err2 = new Error('Unknown auth strategy: ' + appSubs.auth + ', for application "' + appSubs.application + '", API "' + appSubs.api + '".');
                    return callback(err2);
                }

                // Now the API level plugins from the Plan
                const apiPlan = getPlanById(apiPlans, appSubs.plan);
                if (!apiPlan) {
                    const err = new Error('Unknown API plan strategy: ' + appSubs.plan + ', for application "' + appSubs.application + '", API "' + appSubs.api + '".');
                    return callback(err);
                }

                if (apiPlan.config && apiPlan.config.plugins) {
                    consumerInfo.apiPlugins = utils.clone(apiPlan.config.plugins);
                }
                else {
                    consumerInfo.apiPlugins = [];
                }
                // Fix #148: Apply Redis also for ratelimiting from Plans
                checkCorsAndRateLimitingPlugins(apiDesc.name, consumerInfo.apiPlugins);

                consumerList.push(consumerInfo);
            }
        }

        debug(utils.getText(consumerList));

        return callback(null, consumerList);
    });
}
开发者ID:Haufe-Lexware,项目名称:wicked.portal-kong-adapter,代码行数:86,代码来源:portal.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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