本文整理汇总了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;未经允许,请勿转载。 |
请发表评论