How to use the delay 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 semantic-release / npm / test / helpers / npm-registry.js View on Github external
async function start() {
  await getStream(await docker.pull(IMAGE));

  container = await docker.createContainer({
    Tty: true,
    Image: IMAGE,
    PortBindings: {[`${COUCHDB_PORT}/tcp`]: [{HostPort: `${SERVER_PORT}`}]},
    Env: [`COUCHDB_USER=${COUCHDB_USER}`, `COUCHDB_PASSWORD=${COUCHDB_PASSWORD}`],
  });

  await container.start();
  await delay(4000);

  try {
    // Wait for the registry to be ready
    await pRetry(() => got(`http://${SERVER_HOST}:${SERVER_PORT}/registry/_design/app`, {cache: false}), {
      retries: 7,
      minTimeout: 1000,
      factor: 2,
    });
  } catch (_) {
    throw new Error(`Couldn't start npm-docker-couchdb after 2 min`);
  }

  // Create user
  await got(`http://${SERVER_HOST}:${SERVER_PORT}/_users/org.couchdb.user:${NPM_USERNAME}`, {
    json: true,
    auth: `${COUCHDB_USER}:${COUCHDB_PASSWORD}`,
github Yoctol / bottender / src / plugins / withTyping.js View on Github external
const delay =
          methodOptions &&
          typeof methodOptions === 'object' &&
          typeof methodOptions.delay === 'number'
            ? methodOptions.delay
            : options.delay;

        if (methodOptions) {
          args[len - 1] = omit(methodOptions, ['delay']);
        }

        if (this.typingOn) {
          await this.typingOn();
        }

        await sleep(delay);

        return _method.call(context, ...args);
      };
      /* eslint-enable func-names */
github mizchi / next-editor / src / ui / components / utils / Initializer.tsx View on Github external
async componentDidMount() {
      // UI Boot
      await delay(150)
      const { isFirstVisit, ...actions } = this.props

      if (isFirstVisit) {
        // Start omotenashi
        // Remove first visit flag
        await actions.setConfigValue({ key: "isFirstVisit", value: false })

        // Open scratch.md as user first view
        actions.loadFile({ filepath: "/playground/scratch.md" })

        // TODO: Reload git on init. Sometimes initialze on git is failing
        await delay(300)
        actions.initializeGitStatus("/playground")
      }

      // TODO: dirty hack to focus
      // Focus first element
      await delay(150)
      const target = (document as any).querySelector("textarea")
      target && target.focus()
    }
  })
github alexcroox / jira-timer-menubar / main.js View on Github external
app.on('ready', async () => {

  // transparency workaround https://github.com/electron/electron/issues/2170
  await delay(10)

  mb = menubar({
    alwaysOnTop: process.env.NODE_ENV === 'development',
    icon: path.join(app.getAppPath(), '/static/tray.png'),
    width: 500,
    minWidth: 500,
    maxWidth: 500,
    minHeight: 530,
    hasShadow: false,
    preloadWindow: true,
    resizable: true,
    transparent: true,
    frame: false,
    toolbar: false
  })
github saltyshiomix / react-ssr / packages / express-engine-jsx / src / bin / react-ssr-dev.ts View on Github external
async function dev() {
  let proc;
  const wrapper = () => {
    if (proc) {
      proc.kill();
    }
  };
  process.on('SIGINT', wrapper);
  process.on('SIGTERM', wrapper);
  process.on('exit', wrapper);

  proc = serve(server, false);

  await delay(300);

  // const app = module.exports.__REACT_SSR_EXPRESS__;

  // app.listen(8888, async () => {
  //   const url = (route) => `http://localhost:8888${route}`;

  //   spinner.create(`Building '/'`);
  //   await got(url('/'));

  //   spinner.create(`Building '/' (test 2)`);
  //   await got(url('/'));

  //   spinner.create(`Building '/' (test 3)`);
  //   await got(url('/'));

  //   spinner.clear('Success!');
github sindresorhus / alfy / test / fetch.js View on Github external
test('cache', async t => {
	const alfy = createAlfy();

	t.deepEqual(await alfy.fetch(`${URL}/cache`, {maxAge: 5000}), {hello: 'world'});
	t.deepEqual(await alfy.fetch(`${URL}/cache`, {maxAge: 5000}), {hello: 'world'});

	await delay(5000);

	t.deepEqual(await alfy.fetch(`${URL}/cache`, {maxAge: 5000}), {hello: 'world!'});
});
github Wildhoney / Switzerland / src / middleware / intersect / __tests__ / index.js View on Github external
async (t, { page, utils }) => {
        const name = 'x-example';
        await utils.waitForUpgrade(name);

        await page.evaluate(name => {
            const node = document.createElement(name);
            node.style.display = 'block';
            node.style.width = '200px';
            node.style.height = '300px';
            node.style.transform = 'translate(0, -250px)';
            document.body.append(node);
            return node.idle();
        }, name);
        await delay(100);
        t.snapshot(await utils.innerHTML(name));

        await page.evaluate(name => {
            const node = document.querySelector(name);
            node.style.transform = 'translate(0, -100px)';
        }, name);
        await delay(100);
        t.snapshot(await utils.innerHTML(name));

        await page.evaluate(name => {
            const node = document.querySelector(name);
            node.style.transform = 'translate(0, 0)';
        }, name);
        await delay(100);
        t.snapshot(await utils.innerHTML(name));
    }
github VladimirIvanin / insales-uploader / lib / taskManager.js View on Github external
function taskRunner(){
      self.lock = true;
      delay(self.options.delay).then(() => {
        self.tasks[self.taskList[0].task](self.taskList[0].param).then(content => {
          let _content = content || {};

          self.taskList.splice(0, 1);
          self.lock = false;
          if (self.options.statusBar && statusBar) {
            statusBar.tick(_content);
          }

          if (_.size(self.taskList) > 0){
            return taskRunner();
          }else{
            resolve(self.taskList)
            return;
          }
        })
github welovekpop / munar / packages / munar-plugin-dj-history-skip / src / index.js View on Github external
async maybeSkip (adapter, current) {
    const history = await adapter.getDJHistory().getRecent(this.options.limit)
    const dj = await adapter.getDJBooth().getDJ()
    if (this.exemptions.check(dj)) {
      return
    }

    const lastPlay = history.find((entry) => this.isHistoryMatch(entry, current))
    if (lastPlay) {
      const duration = moment.duration(Date.now() - lastPlay.playedAt, 'milliseconds')
      adapter.send(
        `@${dj.username} This song was played ${duration.humanize()} ago` +
        (lastPlay.user ? ` by ${lastPlay.user.username}` : '') +
        '.'
      )
      await delay(500)
      await lockskip(adapter, { position: this.options.position })
    }
  }
}
github Jameskmonger / creature-chess / src / shared / game / game.ts View on Github external
private async runReadyPhase() {
        log(`Entering phase ${GamePhase[GamePhase.READY]}`);

        this.phase = GamePhase.READY;

        this.players.forEach(p => p.enterReadyPhase(this.turnSimulator, this.opponentProvider));

        await delay(this.phaseLengths[GamePhase.READY] * 1000);
    }

delay

Delay a promise a specified amount of time

MIT
Latest version published 12 months ago

Package Health Score

77 / 100
Full package analysis

Popular delay functions