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

TypeScript bluebird.mapSeries函数代码示例

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

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



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

示例1: async

    await bluebird.mapSeries(items, async (item: any) => {
      let ideograms = ideogramsConverter.convertUtf16ToIdeograms(item.ideogram);
      ideograms = replaceall('%', '', ideograms);
      if (!ideograms) {
        return;
      }

      i += 1;

      profiler(`${i} - ${ideograms}`);

      const phrases = await PhraseRepository.findByLanguageAndRlike(
        language,
        ideograms,
      );
      if (phrases.length === 0) {
        return;
      }

      await bluebird.mapSeries(phrases, async (phrase: any) => {
        await knex('cjk_has_phrase').insert({
          cjk_id: item.id,
          phrase_id: phrase.id,
        });
      });
    });
开发者ID:pierophp,项目名称:pinyin,代码行数:26,代码来源:cjk.repository.ts


示例2: Number

          .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()
            })
          })
开发者ID:seffalabdelaziz,项目名称:botpress,代码行数:27,代码来源:daemon.ts


示例3: Function

const _sendBroadcast = Promise.method(row => {
  let dropPromise = Promise.resolve(false)

  if (row.filters) {
    dropPromise = Promise.mapSeries(JSON.parse(row.filters), filter => {
      let fnBody = filter.trim()
      if (!/^return /i.test(fnBody)) {
        fnBody = 'return ' + fnBody
      }

      const fn = new Function('bp', 'userId', 'platform', fnBody)
      return Promise.method(fn)(bp, row.userId, row.platform)
    }).then(values => {
      return _.some(values, v => {
        if (v !== true && v !== false) {
          bp.logger.warn('Filter returned something other ' + 'than a boolean (or a Promise of a boolean)')
        }

        return typeof v !== 'undefined' && v !== null && v !== true
      })
    })
  }

  return dropPromise.then(drop => {
    if (drop) {
      bp.logger.debug(`Drop sending #${row.scheduleId} to user: ${row.userId}. Reason = Filters`)
      return
    }
    return bp.renderers.sendToUser(row.userId, '#!' + row.text)
  })
})
开发者ID:seffalabdelaziz,项目名称:botpress,代码行数:31,代码来源:daemon.ts


示例4: detectBrowsers

/** returns list of detected browsers */
function detectBrowsers(): Bluebird<Browser[]> {
  // we can detect same browser under different aliases
  // tell them apart by the full version property
  const removeDuplicates = uniqBy(prop('version'))
  return Bluebird.mapSeries(browsers, checkOneBrowser)
    .then(_.compact)
    .then(removeDuplicates) as Bluebird<Browser[]>
}
开发者ID:lgandecki,项目名称:cypress,代码行数:9,代码来源:detect.ts


示例5:

 return Promise.join(getVolunteers, getTaskPool, (volunteers, tasks) => {
     return Promise.mapSeries(volunteers.map<Volunteer>(), (volunteer) => {
         if (tasks.length > 0) {
             const task = tasks.pop();
             return TaskFsm.assign(task, volunteer)
             .then(() => task.getProposalMessage(volunteer))
             .then(message => message.send());
         }
     });
 });
开发者ID:CMUBigLab,项目名称:cmuNodeFbot,代码行数:10,代码来源:remind_new_tasks.ts


示例6: referencePhrases

  static async referencePhrases() {
    const words = await knex('cjk')
      .where({
        type: 'W',
        simplified: 1,
      })
      .select('id', 'ideogram');

    const characters = await knex('cjk')
      .whereRaw('type = "C" AND frequency < 999 AND simplified = 1')
      .select('id', 'ideogram');

    const items = words.concat(characters);

    const language = await LanguageRepository.findOneByCode('cmn-hans');

    let i = 0;

    const ideogramsConverter = new IdeogramsConverter();

    await bluebird.mapSeries(items, async (item: any) => {
      let ideograms = ideogramsConverter.convertUtf16ToIdeograms(item.ideogram);
      ideograms = replaceall('%', '', ideograms);
      if (!ideograms) {
        return;
      }

      i += 1;

      profiler(`${i} - ${ideograms}`);

      const phrases = await PhraseRepository.findByLanguageAndRlike(
        language,
        ideograms,
      );
      if (phrases.length === 0) {
        return;
      }

      await bluebird.mapSeries(phrases, async (phrase: any) => {
        await knex('cjk_has_phrase').insert({
          cjk_id: item.id,
          phrase_id: phrase.id,
        });
      });
    });
  }
开发者ID:pierophp,项目名称:pinyin,代码行数:47,代码来源:cjk.repository.ts


示例7: retry

    .then(rows => {
      let abort = false
      return Promise.mapSeries(rows, row => {
        if (abort) {
          return
        }
        return retry(() => _sendBroadcast(row), {
          max_tries: 3,
          interval: 1000,
          backoff: 3
        })
          .then(() => {
            return knex('broadcast_outbox')
              .where({ userId: row['scheduleUser'], scheduleId: row['scheduleId'] })
              .delete()
              .then(() => {
                return knex('broadcast_schedules')
                  .where({ id: row['scheduleId'] })
                  .update({ sent_count: knex.raw('sent_count + 1') })
                  .then(() => emitChanged())
              })
          })
          .catch(err => {
            abort = true

            bp.logger.error(`Broadcast #${row['scheduleId']}' failed. Broadcast aborted. Reason: ${err.message}`)

            bp.notifications.send({
              level: 'error',
              message: 'Broadcast #' + row['scheduleId'] + ' failed.' + ' Please check logs for the reason why.',
              url: '/logs'
            })

            return knex('broadcast_schedules')
              .where({ id: row['scheduleId'] })
              .update({
                errored: knex.bool.true()
              })
              .then(() => {
                return knex('broadcast_outbox')
                  .where({ scheduleId: row['scheduleId'] })
                  .delete()
                  .then(() => emitChanged())
              })
          })
      })
    })
开发者ID:seffalabdelaziz,项目名称:botpress,代码行数:47,代码来源:daemon.ts


示例8: uniqBy

export const detect = (goalBrowsers?: Browser[]): Bluebird<FoundBrowser[]> => {
  // we can detect same browser under different aliases
  // tell them apart by the name and the version property
  if (!goalBrowsers) {
    goalBrowsers = browsers
  }

  const removeDuplicates = uniqBy((browser: FoundBrowser) =>
    props(['name', 'version'], browser)
  )
  const compactFalse = (browsers: any[]) => compact(browsers) as FoundBrowser[]

  return Bluebird.mapSeries(goalBrowsers, checkBrowser)
    .then(flatten)
    .then(compactFalse)
    .then(removeDuplicates)
}
开发者ID:YOU54F,项目名称:cypress,代码行数:17,代码来源:detect.ts


示例9: emitChanged

    await Promise.map(schedules, async schedule => {
      const timezones = await db.getUsersTimezone()

      await Promise.mapSeries(timezones, async tz => {
        await db.setBroadcastOutbox(botId, schedule, tz)
        const { count } = await db.getOutboxCount(botId, schedule)

        await db.updateTotalCount(schedule, count)

        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:alexsandrocruz,项目名称:botpress,代码行数:18,代码来源:daemon.ts


示例10: Promise

  .then(() => {
    console.info('Tables of %s deleted.', CONFIG.DATABASE.DBNAME)

    const STORAGE = CONFIG.STORAGE
    Promise.mapSeries(Object.keys(STORAGE), storage => {
      const storageDir = STORAGE[storage]

      return new Promise((res, rej) => {
        rimraf(storageDir, err => {
          if (err) return rej(err)

          console.info('%s deleted.', storageDir)
          return res()
        })
      })
    })
    .then(() => process.exit(0))
  })
开发者ID:jiang263,项目名称:PeerTube,代码行数:18,代码来源:cleaner.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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