How to use the delay.js function in delay

To help you get started, we’ve selected a few delay examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github inker / draw / src / model / fetch-parse-pots.ts View on Github external
export async function tryFetch(url: string) {
  while (!navigator.onLine) {
    console.error("you're offline, retrying...")
    await delay(1000)
  }
  const response = await fetch(proxify(url, 'latin1'))
  if (response.status !== 200) {
    throw new Error(`${url}: ${response.status}`)
  }
  const text = await response.text()
  if (text.includes('<title>404 Not Found</title>')) {
    // stupid me
    throw new Error(`${url}: 404`)
  }
  return text
}
github inker / draw / src / model / fetchPotsData.ts View on Github external
async function tryFetch(url: string) {
  while (!navigator.onLine) {
    console.error("you're offline, retrying...")
    await delay(1000)
  }
  const text = await proxy(url, 'latin1')
  if (text.includes('<title>404 Not Found</title>')) {
    // stupid me
    throw new Error(`${url}: 404`)
  }
  return text
}
github inker / draw / src / routes / Pages / index.tsx View on Github external
// stage,
        season,
      })

      setPopup({
        waiting: false,
        error: null,
      })
    } catch (err) {
      console.error(err)
      setPopup({
        waiting: false,
        error: 'Could not fetch data',
      })

      await delay(1000)
      const {
        tournament: newTournament,
        stage: newStage,
      } = params

      const newSeason = pots && season !== currentSeasonByTournament(newTournament, newStage)
        ? season
        : undefined
      onSeasonChange(newTournament, newStage, newSeason)
      setPopup({
        error: null,
      })
    }
  }
github inker / draw / src / utils / animateContentTransfer.ts View on Github external
export default async (sourceCell: HTMLElement, targetCell: HTMLElement, duration: number) => {
  const fakeCell = makeFakeCell(sourceCell)
  airborneDiv.appendChild(fakeCell)

  const targetCellBox = targetCell.getBoundingClientRect()
  fakeCell.style.transition = `transform ${duration}ms ease-in-out`
  adjustPositioning(fakeCell, targetCellBox)

  await transitionEnd(fakeCell)
  if (isFirefox) {
    await delay(0)
  }

  airborneDiv.removeChild(fakeCell)
}
github inker / draw / src / utils / hooks / useTimeout / index.ts View on Github external
const runCalculatingTimer = async (oldValue: T) => {
    dispatchLongCalculating({
      type: types.set,
      payload: oldValue,
    })
    await delay(delayMs)
    dispatchLongCalculating({
      type: types.set,
      payload: oldValue,
    })
  }

delay

Delay a promise a specified amount of time

MIT
Latest version published 1 year ago

Package Health Score

73 / 100
Full package analysis

Popular delay functions