当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Promise.all方法代码示例

本文整理汇总了TypeScript中es6-promise.Promise.all方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Promise.all方法的具体用法?TypeScript Promise.all怎么用?TypeScript Promise.all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在es6-promise.Promise的用法示例。


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

示例1: allFilesExist

function allFilesExist(files: Array<string>): Promise<any> {
  const fs = require('fs');

  return Promise.all(files.map(filepath => promised(cb => fs.stat(`${BUILD_PUBLIC_DIR}/${filepath}`, cb), false)))
    // make sure that all stats are truthy
    .then(stats => stats.reduce((all, current) => all && current, true));
}
开发者ID:ududsha,项目名称:gulp-typescript-webpack-react-hotreload,代码行数:7,代码来源:gulpfile.ts

示例2: getWidgets

    protected async getWidgets(): Promise<HomeWidgets_01_00_00> {
        // Using async/await on ES6 promises

        let serviceResults = await Promise.all([
            this.homeWidgetsService.getExhibitors(),
            this.homeWidgetsService.getHistory(),
            this.homeWidgetsService.getRegitrationLogin(),
            this.homeWidgetsService.getCategories(),
            this.homeWidgetsService.getOfficialStores(),
            this.homeWidgetsService.getSell(),
            this.homeWidgetsService.getSiteInformation(),
            this.homeWidgetsService.getTermsAndConditions()
        ]);
        
        let homeWidgets = new HomeWidgets_01_00_00();
        homeWidgets.exhibitors = serviceResults[0];
        homeWidgets.history = serviceResults[1];
        homeWidgets.registrationLogin = serviceResults[2];
        homeWidgets.categories = serviceResults[3];
        homeWidgets.officialStores = serviceResults[4];
        homeWidgets.sell = serviceResults[5];
        homeWidgets.siteInformation = serviceResults[6];
        homeWidgets.termsAndConditons = serviceResults[7];

        return Promise.resolve(homeWidgets);
    }
开发者ID:francovitali,项目名称:cart-backend-poc,代码行数:26,代码来源:getHomeWidgetsTask_01_00_00.ts

示例3: it

 it('should resolve on read', () => {
     return Promise.all([
         buf.write('world').should.be.fulfilled,
         buf.read().should.eventually.equal('hello'),
         buf.read().should.eventually.equal('world')
     ]);
 });
开发者ID:petermanser,项目名称:proc-that,代码行数:7,代码来源:Buffer.spec.ts

示例4: promised

 const writeIndexHtmlUsingManifests = (manifest: Array<string>): Promise<any> =>
   Promise.all([
     promised(cb => fs.readFile(`${SRC_DIR}/index.dust`, 'utf8', cb)),
     promised(cb => mkdirp(BUILD_PUBLIC_DIR, cb)),
   ])
     .then(([content]) => dust.compile(content, 'index'))
     .then(dust.loadSource)
     .then(() => promised(cb => dust.render('index', { manifest }, cb)))
     .then(html => promised(cb => fs.writeFile(`${BUILD_PUBLIC_DIR}/index.html`, html, cb)));
开发者ID:ompanda,项目名称:gulp-typescript-webpack-react-hotreload,代码行数:9,代码来源:gulpfile.ts

示例5: resolve

 return new Promise<CourseTeachers>((resolve, reject) => {
     let ans: CourseTeachers = obj;
     Promise.all([
          ]
     ).then((values) => {
         resolve(ans);
     }).catch((error) => {
         reject(error);
     })
 })
开发者ID:lesh-dev,项目名称:core,代码行数:10,代码来源:api_connect.ts


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