lodash#reverse JavaScript Examples

The following examples show how to use lodash#reverse. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: workflows.js    From holo-schedule with MIT License 6 votes vote down vote up
syncEndedLives = async () => {
  const cashedLives = getCachedEndedLives() ?? []
  const startBefore = cashedLives.length ? Math.min(
    ...cashedLives.map(({ start_at: startAt }) => getUnix(startAt)),
  ) + 1 : getUnix()

  const lives = filterLives(await getEndedLives({
    membersMask: getMembersMask(getSubscriptionByMember()),
    startAfter: getUnixBeforeDays(3),
    startBefore,
    limit: 25,
  }))

  await Promise.resolve({
    [ENDED_LIVES]: limitRight(uniqRightBy([...reverse(lives), ...cashedLives], 'id'), MAX_LIVES_LENGTH),
  }).then(data => store.set(data))
    .catch(data => store.set(data, { local: false }))

  return getCachedEndedLives()
}
Example #2
Source File: Chart.js    From covid19 with MIT License 6 votes vote down vote up
calculateDayOffsets = (sortedDailyCounts = [], benchmarkCountryISO) => {
  const countryBenchmark = benchmarkCountryISO
  const countryCounts = groupBy(sortedDailyCounts, 'country.iso')
  const benchmarkCounts = countryCounts[countryBenchmark] || []
  const revBenchmarkCounts = reverse(benchmarkCounts)

  let countries = {}

  revBenchmarkCounts.forEach((count, i) => {
    if (i == revBenchmarkCounts.length - 1) return

    const currentCount = count
    const previousCount = revBenchmarkCounts[i + 1]

    for (const country in countryCounts) {
      const counts = countryCounts[country]

      counts.forEach((count) => {
        if (countries[country]) return

        if (
          count.totalCases < currentCount.totalCases &&
          count.totalCases > previousCount.totalCases
        ) {
          countries[country] = daysBetween(
            new Date(currentCount.date.date),
            new Date(count.date.date)
          )
        }
      })
    }
  })

  return countries
}
Example #3
Source File: index.js    From holo-schedule with MIT License 5 votes vote down vote up
uniqRightBy = (array, ...args) => reverse(uniqBy(reverse([...array]), ...args))