當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript promise.all函數代碼示例

本文整理匯總了TypeScript中promise.all函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript all函數的具體用法?TypeScript all怎麽用?TypeScript all使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了all函數的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: beforeEach

	beforeEach(function() {
		return Promise.all([
			systemjs.import('./src/stores/route-store'),
			systemjs.import('./src/dispatcher')
		]).then(function(modules) {
			routeStore = new modules[0].routeStore.constructor();
			dispatcher = modules[1].dispatcher;
		});
	});
開發者ID:eriklarko,項目名稱:YetAnotherGTDApp,代碼行數:9,代碼來源:route-store-test.ts

示例2: expect

 db.collection("coll_group_1").then(coll => {
     Promise.all([
         coll.insert({
             _id: 1111,
             name: 'eeee',
             age: 22
         }, {chain: true}),
         coll.insert({
             _id: 1112,
             name: 'dddd',
             age: 23
         }, {chain: true}),
         coll.insert({
             _id: 1113,
             name: 'cccc',
             age: 22
         }, {chain: true}),
         coll.insert({
             _id: 1114,
             name: 'bbbb',
             age: 25
         }, {chain: true}),
         coll.insert({
             _id: 1115,
             name: 'aaaa',
             age: 23
         })
     ]).then(() => {
         var docs = coll.aggregate([{
             $group: {
                 _id: "$age",
                 count: {
                     $sum: 1
                 },
                 total_id: {
                     $sum: "$_id"
                 },
                 total_age: {
                     $sum: '$age'
                 }
             }
         }]);
         
         expect(docs).to.exist;
         expect(docs).to.be.instanceof(Array);
         expect(docs).to.have.length(3);
         
         done();
     });
 });
開發者ID:EastolfiWebDev,項目名稱:MongoPortable,代碼行數:50,代碼來源:Aggregation.spec.ts

示例3: getResult

 getResult(): Promise.IThenable<User> {
     if (_.isUndefined(this.passwordPromise)) {
         throw new Error("You need to set password first");
     }
    
     return Promise.all([
         this.passwordPromise,
     ]).then(([password]) => {
         return {
             id: this.email,
             email: this.email,
             password: password,
             salt: this.salt
         }
     });
 }
開發者ID:kamilbiela,項目名稱:auth360-backend,代碼行數:16,代碼來源:UserBuilder.ts

示例4: reject

                .then((token) => {

                    const promises: Array<Promise.IThenable<ISeverityCountResult>> = [];

                    [SeverityType.Low, SeverityType.Medium, SeverityType.High, SeverityType.Critical].forEach((severity) => {
                        const q = qs.stringify({
                            fields: 'severityString',
                            limit: 1,
                            filters: `severity:${severity}+isSuppressed:false`,
                            excludeFilters: true
                        });

                        promises.push(
                            new Promise<ISeverityCountResult>((resolve, reject) => {
                                msg.http(FoDApiHelper.getApiUri(`/api/v3/releases/${releaseId}/vulnerabilities?${q}`))
                                    .headers({
                                        'authorization': `Bearer ${token}`,
                                        'content-type': 'application/octet-stream'
                                    })
                                    .get()((err: any, res: any, body: any) => {
                                        if (err)
                                            return reject(err);

                                        const result = JSON.parse(body);

                                        if (result && result.totalCount && result.items) {
                                            return resolve({ severityId: severity, severityType: result.items[0].severityString, count: result.totalCount });
                                        }

                                        return resolve(null);
                                    });
                            }));
                    });

                    return Promise.all(promises);
                })
開發者ID:mtgibbs,項目名稱:hubot-fod,代碼行數:36,代碼來源:hubot-fod.ts


注:本文中的promise.all函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。