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


TypeScript bluebird.mapSeries函数代码示例

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