Socket
Socket
Sign inDemoInstall

p-wait-for

Package Overview
Dependencies
2
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    p-wait-for

Wait for a condition to be true


Version published
Weekly downloads
903K
increased by1.82%
Maintainers
1
Install size
14.4 kB
Created
Weekly downloads
 

Readme

Source

p-wait-for Build Status

Wait for a condition to be true

Can be useful for polling.

Install

$ npm install p-wait-for

Usage

const pWaitFor = require('p-wait-for');
const pathExists = require('path-exists');

(async () => {
	await pWaitFor(() => pathExists('unicorn.png'));
	console.log('Yay! The file now exists.');
})();

API

pWaitFor(condition, [options])

Returns a Promise that resolves when condition returns true. Rejects if condition throws or returns a Promise that rejects.

condition

Type: Function

Expected to return a boolean or a Promise for a boolean.

options

Type: Object

interval

Type: number
Default: 20

Number of milliseconds to wait before retrying condition.

timeout

Type: number
Default: Infinity

Number of milliseconds to wait before automatically rejecting.

  • p-whilst - Calls a function repeatedly while a condition returns true and then resolves the promise
  • More…

License

MIT © Sindre Sorhus

Keywords

FAQs

Last updated on 07 Nov 2018

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc