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

TypeScript bluebird.map函数代码示例

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

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



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

示例1: putStatusToStream

            .then((emailDataList: Array<EmailData>) => {

                const emailDataListWithTriggers: Array<EmailData> =
                    emailDataList.filter((emailData) => emailData.triggeredSendKey !== undefined);

                const triggers: Promise<Array<any>> = Promise.map(emailDataListWithTriggers, createTriggeredSend).map(sendTriggeredSend);
                const subscriptions: Promise<Array<any>> = Promise.map(emailDataList, createSubscription).map(subscribeEmailToList);

                return Promise.join(triggers, subscriptions)
                    .map((responses: Array<any>) => {
                        return responses.map((response: any) => {
                            if (!response.body.Results[0]) throw "No results";
                            return response.body.Results;
                        });
                    })
                    .map((allResponses: Array<Array<any>>) => {
                        allResponses.map((results: Array<any>) => {
                            results.map((result: any) => {
                                console.log(JSON.stringify(result));
                                if (result.StatusCode !== 'OK') {
                                    console.log("Failed! StatusCode: " + result.StatusCode + " StatusMessage: " + result.StatusMessage);
                                    throw result;
                                }
                                return result;
                            });
                        });
                    })
                    .then(() => putStatusToStream(makeSuccessPutRequest(emailDataList)))
                    .catch((error) => {
                        console.log(error);
                        putStatusToStream(makeFailurePutRequest(emailDataList, error))
                    })
                    .then(() => Promise.resolve(emailDataList));
            })
开发者ID:sndrs,项目名称:email-signup,代码行数:34,代码来源:triggersubscriberhandler.ts


示例2: checkBrowser

/**
 * Try to detect a single browser definition, which may dispatch multiple `checkOneBrowser` calls,
 * one for each binary. If Windows is detected, only one `checkOneBrowser` will be called, because
 * we don't use the `binary` field on Windows.
 */
function checkBrowser(browser: Browser): Promise<(boolean | FoundBrowser)[]> {
  if (Array.isArray(browser.binary) && os.platform() !== 'win32') {
    return Bluebird.map(browser.binary, (binary: string) => {
      return checkOneBrowser(extend({}, browser, { binary }))
    })
  }
  return Bluebird.map([browser], checkOneBrowser)
}
开发者ID:YOU54F,项目名称:cypress,代码行数:13,代码来源:detect.ts


示例3: return

	return(built.then(() =>

		// Add mappings to any extra packages listed in command line options.

		Promise.map(options.mapPackages || [], (name: string) =>
			findPackage(name, path.resolve(basePath, 'package.json'), basePath, fixTbl, repoTbl)
		)
开发者ID:charto,项目名称:cbuild,代码行数:7,代码来源:cbuild.ts


示例4: processActivityPubHttpBroadcast

async function processActivityPubHttpBroadcast (job: kue.Job) {
  logger.info('Processing ActivityPub broadcast in job %d.', job.id)

  const payload = job.data as ActivitypubHttpBroadcastPayload

  const body = await computeBody(payload)
  const httpSignatureOptions = await buildSignedRequestOptions(payload)

  const options = {
    method: 'POST',
    uri: '',
    json: body,
    httpSignature: httpSignatureOptions,
    timeout: JOB_REQUEST_TIMEOUT
  }

  const badUrls: string[] = []
  const goodUrls: string[] = []

  await Bluebird.map(payload.uris, uri => {
    return doRequest(Object.assign({}, options, { uri }))
      .then(() => goodUrls.push(uri))
      .catch(() => badUrls.push(uri))
  }, { concurrency: BROADCAST_CONCURRENCY })

  return ActorFollowModel.updateActorFollowsScore(goodUrls, badUrls, undefined)
}
开发者ID:jiang263,项目名称:PeerTube,代码行数:27,代码来源:activitypub-http-broadcast.ts


示例5: knex

    .then(schedules => {
      return Promise.map(schedules, schedule => {
        return knex('users')
          .distinct('timezone')
          .select()
          .then(timezones => {
            return Promise.mapSeries(timezones, ({ timezone: tz }) => {
              const initialTz = tz
              const sign = Number(tz) >= 0 ? '+' : '-'
              tz = padDigits(Math.abs(Number(tz)), 2)
              const relTime = moment(`${schedule['date_time']}${sign}${tz}`, 'YYYY-MM-DD HH:mmZ').toDate()
              const adjustedTime = this.db.knex.date.format(schedule['ts'] ? schedule['ts'] : relTime)

              const whereClause = _.isNil(initialTz) ? 'where timezone IS NULL' : 'where timezone = :initialTz'

              const sql = `insert into broadcast_outbox ("userId", "scheduleId", "ts")
            select userId, :scheduleId, :adjustedTime
            from (
              select id as userId
              from users
              ${whereClause}
            ) as q1`

              return knex
                .raw(sql, {
                  scheduleId: schedule['id'],
                  adjustedTime,
                  initialTz
                })
                .then()
            })
          })
          .then(() => {
            return knex('broadcast_outbox')
              .where({ scheduleId: schedule['id'] })
              .select(knex.raw('count(*) as count'))
              .then()
              .get(0)
              .then(({ count }) => {
                return knex('broadcast_schedules')
                  .where({ id: schedule['id'] })
                  .update({
                    outboxed: knex.bool.true(),
                    total_count: count
                  })
                  .then(() => {
                    bp.logger.info('Scheduled broadcast #' + schedule['id'], '. [' + count + ' messages]')

                    if (schedule['filters'] && JSON.parse(schedule['filters']).length > 0) {
                      bp.logger.info(
                        `Filters found on broadcast #${schedule['id']}. Filters are applied at sending time.`
                      )
                    }

                    emitChanged()
                  })
              })
          })
      })
    })
开发者ID:seffalabdelaziz,项目名称:botpress,代码行数:60,代码来源:daemon.ts


示例6: execute

  execute(project, kube) {
    logger.info("Running build!");

    // For now, until Kube supports running one-off jobs (with
    // containers with "privileged mode" turned on to allow nesting),
    // we need to reach out to an *existing* dockerd already running
    // in our cluster (or elsewhere) in order to build images.

    // Now, we have to strategically decide how and when to ship
    // images from the build location (which *may* be a node!) to all
    // of nodes that will run the kube job.  we don't want to be
    // piping bits through the user's laptop if ever avoidable.  If
    // it's a single nod deployment, it's easy, because the image will
    // be on that docker node used by that kubelet already.  Now, say
    // you have a simple environment consisting of two nodes, we have
    // to ship that image to the other node.  We still do not want to
    // ship through the user's laptop, because asymmetric home ISP
    // horrors.

    // now, the right answer might be to always deploy a Pod
    // containing Docker Index (using an image from the public Docker
    // Hub, to avoid chicken/egg issues) in the most basic mode (ie.,
    // a singleton with storage on a UNIX fs, which doesn't scale for
    // shit but is great for getting started and won't depend on Riak
    // CS), and shove the things through that.

    // TODO: this should be injected
    var builder = new DirectBuilder(project, project.env.getBuilderDockerHost(), project.env.getBuilderDockerPort());
    return Promise.map(project.images, function(image) {
        return builder.build(image);
    });
  }
开发者ID:orospakr,项目名称:diatropikon,代码行数:32,代码来源:build.ts


示例7: test4

function test4() {
	const unsorted: number[] = [];

	function compare(a: number, b: number) { return(a - b); }

	for(let num = 0; num < 100; ++num) {
		unsorted[num] = ~~(Math.random() * 50);
	}

	const correct = unsorted.slice(0).sort(compare);

	const queue = new TaskQueue(Promise, 1);
	const result: number[] = [];
	const start = new Date().getTime();

	return(
		Promise.map(
			unsorted,
			(item: number) => queue.add(
				() => {
					const delta = new Date().getTime() - start - item * 10;
					if(delta > 0 && delta < 20) result.push(item);
				},
				item * 10
			)
		).then(
			() => result.join(' ') == correct.join(' ') && ++testCount
		)
	);
}
开发者ID:charto,项目名称:cwait,代码行数:30,代码来源:test.ts


示例8:

 .map(regions, (region: any) => {
   const ec2Client = new aws.EC2({ region: region });
   return bluebird
     .map(filters, (filterSet: any) => {
       return ec2Client
         .describeImages({
           Filters: filterSet.Filters
         })
         .promise()
         .then((ami: any) => {
           const set: any = {};
           if (ami.Images[0]) {
             set[filterSet.Name] = ami.Images[0].ImageId
               ? ami.Images[0].ImageId
               : 'NOT_SUPPORTED';
           } else {
             set[filterSet.Name] = 'NOT_SUPPORTED';
           }
           return set;
         });
     })
     .then((results: any) => {
       results = results.reduce((prev: any, current: any) => {
         const key = Object.keys(current)[0];
         prev[key] = current[key];
         return prev;
       }, {});
       return { region: region, images: results };
     });
 })
开发者ID:arminhammer,项目名称:wolkenkratzer,代码行数:30,代码来源:ec2meta.macro.ts


示例9: assistanceList

	/**
	 * 协助列表
	 */
	public async assistanceList(ctx: any) {
		let args = ctx.request.query;
		debug(">>>>args:", args)
		let userAgent = ctx.req.headers['user-agent'];
		let referer = ctx.req.headers['referer'];
		let pageIndex = args.pageIndex ? (args.pageIndex - 1) * 5 : 0;
		let assistancies = await AssistanceModel.findAll({
			offset: pageIndex,
			limit: 5,
			order: [['created_at', 'desc']]
		});
		let total = await AssistanceModel.count();
		let assistanceInfos: AssistanceInfo[] = assistancies;
		await Bluebird.map(assistanceInfos, async (item, index) => {
			let userRecord = await item.getUserModel();
			debug(userRecord.user_name)
			item.user_name = (userRecord && userRecord.user_name) ? userRecord.user_name : "缺省";//发起协助的用户名(业务用户users)
			item.imageArr = item.images ? item.imageArr = item.images.split(",") : [];
			return item;
		})
		await ctx.render('assistance-list', {
			title: '申请协助',
			userAgent,
			referer,
			currentIndex: args.pageIndex || 1,
			total,
			assistanceInfos
		})
	};
开发者ID:yuedun,项目名称:nodejs-koa,代码行数:32,代码来源:platform.ts


示例10: parse

let parser = parse({delimiter: ",", columns: true}, function(err, data){
    return Promise.map<BeaconRow, any>(data, function(b) {
        return new BeaconSlot({
            id: b.bid,
            lat: b.lat,
            long: b.lng,
            edge: b.edge,
            floor: b.floor,
            start_node: b.start,
            end_node: b.end,
            deployment_id: 6,
        }).save(null, {method: "insert"})
        .then(function(slot) {
            return new Beacon({
                id: b.bid,
                minor_id: b.minor,
                slot: slot.id,
                deployment_id: 6,
            }).save(null, {method: "insert"})
            .then(function(beacon) {
                return slot.save({beacon_id: beacon.id}, {method: "update"});
            });
        }).then(() => process.exit())
        .catch(err => {
            console.log(err);
            process.exit(1);
        });
    });
});
开发者ID:CMUBigLab,项目名称:cmuNodeFbot,代码行数:29,代码来源:import_beacon_csv.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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