{"_id":"p-wait-for","_rev":"4664796","name":"p-wait-for","description":"Wait for a condition to be true","dist-tags":{"latest":"6.0.0"},"maintainers":[{"name":"sindresorhus","email":""}],"time":{"modified":"2026-04-10T22:32:57.000Z","created":"2016-10-21T07:03:05.054Z","6.0.0":"2025-09-21T03:45:42.448Z","5.0.2":"2023-03-30T02:34:17.051Z","5.0.1":"2023-03-16T14:47:06.478Z","5.0.0":"2022-07-29T23:49:23.814Z","4.1.0":"2021-07-09T10:19:34.535Z","4.0.0":"2021-04-06T17:51:52.750Z","3.2.0":"2021-01-01T16:00:04.876Z","3.1.0":"2019-04-02T02:47:13.490Z","3.0.0":"2019-03-19T05:05:13.000Z","2.0.1":"2018-11-07T11:24:34.573Z","2.0.0":"2018-07-29T08:23:42.462Z","1.0.0":"2016-10-21T07:03:05.054Z"},"users":{},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"repository":{"type":"git","url":"git+https://github.com/sindresorhus/p-wait-for.git"},"versions":{"6.0.0":{"name":"p-wait-for","version":"6.0.0","description":"Wait for a condition to be true","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/p-wait-for.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"type":"module","exports":{"types":"./index.d.ts","default":"./index.js"},"sideEffects":false,"engines":{"node":">=20"},"scripts":{"test":"xo && ava && tsd"},"keywords":["promise","wait","for","waits","condition","poll","polling","boolean","async","await","promises","bluebird"],"dependencies":{},"devDependencies":{"ava":"^6.4.1","delay":"^6.0.0","time-span":"^5.1.0","tsd":"^0.33.0","xo":"^1.2.2"},"_id":"p-wait-for@6.0.0","gitHead":"81a9d13668a1b2e6e17b79813e43c88de6e2acf2","types":"./index.d.ts","bugs":{"url":"https://github.com/sindresorhus/p-wait-for/issues"},"homepage":"https://github.com/sindresorhus/p-wait-for#readme","_nodeVersion":"20.19.5","_npmVersion":"10.9.2","dist":{"shasum":"c31fdf0a40e2154968a26abc835688d1226dcaa3","size":3934,"noattachment":false,"key":"/p-wait-for/-/p-wait-for-6.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/p-wait-for/download/p-wait-for-6.0.0.tgz"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/p-wait-for_6.0.0_1758426342276_0.24793587575385123"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2025-09-21T03:45:42.448Z","publish_time":1758426342448,"_source_registry_name":"default","_cnpm_publish_time":1758426342448},"5.0.2":{"name":"p-wait-for","version":"5.0.2","description":"Wait for a condition to be true","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/p-wait-for.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"type":"module","exports":"./index.js","engines":{"node":">=12"},"scripts":{"test":"xo && ava && tsd"},"keywords":["promise","wait","for","waits","condition","poll","polling","boolean","async","await","promises","bluebird"],"dependencies":{"p-timeout":"^6.0.0"},"devDependencies":{"ava":"^4.3.1","delay":"^5.0.0","time-span":"^5.1.0","tsd":"^0.22.0","xo":"^0.51.0"},"types":"./index.d.ts","gitHead":"f0499f2957425b71850e6bd7db4fba32f1b81e74","bugs":{"url":"https://github.com/sindresorhus/p-wait-for/issues"},"homepage":"https://github.com/sindresorhus/p-wait-for#readme","_id":"p-wait-for@5.0.2","_nodeVersion":"16.16.0","_npmVersion":"9.2.0","dist":{"shasum":"1546a15e64accf1897377cb1507fa4c756fffe96","size":3350,"noattachment":false,"key":"/p-wait-for/-/p-wait-for-5.0.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/p-wait-for/download/p-wait-for-5.0.2.tgz"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/p-wait-for_5.0.2_1680143656913_0.25284266846057823"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2023-03-30T02:34:17.051Z","publish_time":1680143657051,"_cnpm_publish_time":1680143657051},"5.0.1":{"name":"p-wait-for","version":"5.0.1","description":"Wait for a condition to be true","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/p-wait-for.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"type":"module","exports":"./index.js","engines":{"node":">=12"},"scripts":{"test":"xo && ava && tsd"},"keywords":["promise","wait","for","waits","condition","poll","polling","boolean","async","await","promises","bluebird"],"dependencies":{"p-timeout":"^6.0.0"},"devDependencies":{"ava":"^4.3.1","delay":"^5.0.0","time-span":"^5.1.0","tsd":"^0.22.0","xo":"^0.51.0"},"types":"./index.d.ts","gitHead":"eb5cb217994f740a740d26e1a4fd82d943ed7c09","bugs":{"url":"https://github.com/sindresorhus/p-wait-for/issues"},"homepage":"https://github.com/sindresorhus/p-wait-for#readme","_id":"p-wait-for@5.0.1","_nodeVersion":"18.14.2","_npmVersion":"9.2.0","dist":{"shasum":"1edd9434394048701c5d213751d750231219c273","size":3328,"noattachment":false,"key":"/p-wait-for/-/p-wait-for-5.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/p-wait-for/download/p-wait-for-5.0.1.tgz"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/p-wait-for_5.0.1_1678978026243_0.8611596097536547"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2023-03-16T14:47:06.478Z","publish_time":1678978026478,"_cnpm_publish_time":1678978026478},"5.0.0":{"name":"p-wait-for","version":"5.0.0","description":"Wait for a condition to be true","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/p-wait-for.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"type":"module","exports":"./index.js","engines":{"node":">=12"},"scripts":{"test":"xo && ava && tsd"},"keywords":["promise","wait","for","waits","condition","poll","polling","boolean","async","await","promises","bluebird"],"dependencies":{"p-timeout":"^6.0.0"},"devDependencies":{"ava":"^4.3.1","delay":"^5.0.0","time-span":"^5.1.0","tsd":"^0.22.0","xo":"^0.51.0"},"types":"./index.d.ts","gitHead":"f6716eb5e1eab6560c9614ccb74ab062e832ccdf","bugs":{"url":"https://github.com/sindresorhus/p-wait-for/issues"},"homepage":"https://github.com/sindresorhus/p-wait-for#readme","_id":"p-wait-for@5.0.0","_nodeVersion":"14.19.3","_npmVersion":"8.3.2","dist":{"shasum":"67e0f7e83969f7e0da59f6f0b9fd38452eb8dbd5","size":3321,"noattachment":false,"key":"/p-wait-for/-/p-wait-for-5.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/p-wait-for/download/p-wait-for-5.0.0.tgz"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/p-wait-for_5.0.0_1659138563584_0.7896461669335804"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2022-07-29T23:49:29.424Z","publish_time":1659138563814,"_cnpm_publish_time":1659138563814},"4.1.0":{"name":"p-wait-for","version":"4.1.0","description":"Wait for a condition to be true","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/p-wait-for.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"type":"module","exports":"./index.js","engines":{"node":">=12"},"scripts":{"test":"xo && ava && tsd"},"keywords":["promise","wait","for","waits","condition","poll","polling","boolean","async","await","promises","bluebird"],"dependencies":{"p-timeout":"^5.0.0"},"devDependencies":{"ava":"^3.15.0","delay":"^5.0.0","time-span":"^4.0.0","tsd":"^0.14.0","xo":"^0.38.2"},"gitHead":"1cb1d24decfbcabe0ace93784df2eca6440eab77","bugs":{"url":"https://github.com/sindresorhus/p-wait-for/issues"},"homepage":"https://github.com/sindresorhus/p-wait-for#readme","_id":"p-wait-for@4.1.0","_nodeVersion":"16.2.0","_npmVersion":"7.10.0","dist":{"shasum":"290f126f49bbd7c84e0cedccb342cd631aaa0f16","size":2346,"noattachment":false,"key":"/p-wait-for/-/p-wait-for-4.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/p-wait-for/download/p-wait-for-4.1.0.tgz"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/p-wait-for_4.1.0_1625825974198_0.14773614960542902"},"_hasShrinkwrap":false,"publish_time":1625825974535,"_cnpm_publish_time":1625825974535,"_cnpmcore_publish_time":"2021-12-16T11:26:34.552Z"},"4.0.0":{"name":"p-wait-for","version":"4.0.0","description":"Wait for a condition to be true","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/p-wait-for.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"type":"module","exports":"./index.js","engines":{"node":">=12"},"scripts":{"test":"xo && ava && tsd"},"keywords":["promise","wait","for","waits","condition","poll","polling","boolean","async","await","promises","bluebird"],"dependencies":{"p-timeout":"^5.0.0"},"devDependencies":{"ava":"^3.15.0","delay":"^5.0.0","time-span":"^4.0.0","tsd":"^0.14.0","xo":"^0.38.2"},"gitHead":"edc93ea3ed4e6fdea0a6e4cf3fb78a5250a707bf","bugs":{"url":"https://github.com/sindresorhus/p-wait-for/issues"},"homepage":"https://github.com/sindresorhus/p-wait-for#readme","_id":"p-wait-for@4.0.0","_nodeVersion":"12.20.1","_npmVersion":"6.14.10","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"b4f488eef4365c295f6b21b852b95752d077b670","size":2330,"noattachment":false,"key":"/p-wait-for/-/p-wait-for-4.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/p-wait-for/download/p-wait-for-4.0.0.tgz"},"directories":{},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/p-wait-for_4.0.0_1617731512637_0.7978968341716086"},"_hasShrinkwrap":false,"publish_time":1617731512750,"_cnpm_publish_time":1617731512750,"_cnpmcore_publish_time":"2021-12-16T11:26:34.761Z"},"3.2.0":{"name":"p-wait-for","version":"3.2.0","description":"Wait for a condition to be true","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/p-wait-for.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"engines":{"node":">=8"},"scripts":{"test":"xo && ava && tsd"},"keywords":["promise","wait","for","waits","condition","poll","polling","boolean","async","await","promises","bluebird"],"dependencies":{"p-timeout":"^3.0.0"},"devDependencies":{"ava":"^1.4.1","delay":"^4.1.0","time-span":"^3.0.0","tsd":"^0.7.1","xo":"^0.24.0"},"gitHead":"df45dd3cde7dc49ba00de23de5a92f351f967fe0","bugs":{"url":"https://github.com/sindresorhus/p-wait-for/issues"},"homepage":"https://github.com/sindresorhus/p-wait-for#readme","_id":"p-wait-for@3.2.0","_nodeVersion":"15.5.0","_npmVersion":"6.14.10","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"640429bcabf3b0dd9f492c31539c5718cb6a3f1f","size":2502,"noattachment":false,"key":"/p-wait-for/-/p-wait-for-3.2.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/p-wait-for/download/p-wait-for-3.2.0.tgz"},"directories":{},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/p-wait-for_3.2.0_1609516804727_0.882239530688842"},"_hasShrinkwrap":false,"publish_time":1609516804876,"_cnpm_publish_time":1609516804876,"_cnpmcore_publish_time":"2021-12-16T11:26:34.948Z"},"3.1.0":{"name":"p-wait-for","version":"3.1.0","description":"Wait for a condition to be true","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/p-wait-for.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=8"},"scripts":{"test":"xo && ava && tsd"},"keywords":["promise","wait","for","waits","condition","poll","polling","boolean","async","await","promises","bluebird"],"dependencies":{"p-timeout":"^3.0.0"},"devDependencies":{"ava":"^1.4.1","delay":"^4.1.0","time-span":"^3.0.0","tsd":"^0.7.1","xo":"^0.24.0"},"gitHead":"d4aca6d4f1f0935eb622382a82373d16a1321fdc","bugs":{"url":"https://github.com/sindresorhus/p-wait-for/issues"},"homepage":"https://github.com/sindresorhus/p-wait-for#readme","_id":"p-wait-for@3.1.0","_nodeVersion":"8.15.0","_npmVersion":"6.9.0","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"9da568a2adda3ea8175a3c43f46a5317e28c0e47","size":2378,"noattachment":false,"key":"/p-wait-for/-/p-wait-for-3.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/p-wait-for/download/p-wait-for-3.1.0.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/p-wait-for_3.1.0_1554173233346_0.6117480431125537"},"_hasShrinkwrap":false,"publish_time":1554173233490,"_cnpm_publish_time":1554173233490,"_cnpmcore_publish_time":"2021-12-16T11:26:35.177Z"},"3.0.0":{"name":"p-wait-for","version":"3.0.0","description":"Wait for a condition to be true","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/p-wait-for.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=8"},"scripts":{"test":"xo && ava && tsd-check"},"keywords":["promise","wait","for","waits","condition","poll","polling","boolean","async","await","promises","bluebird"],"dependencies":{"p-timeout":"^3.0.0"},"devDependencies":{"ava":"^1.3.1","delay":"^4.1.0","time-span":"^3.0.0","tsd-check":"^0.5.0","xo":"^0.24.0"},"gitHead":"9093f4e6e0f3ffe21959a32e43adb4105e0a9bf0","bugs":{"url":"https://github.com/sindresorhus/p-wait-for/issues"},"homepage":"https://github.com/sindresorhus/p-wait-for#readme","_id":"p-wait-for@3.0.0","_npmVersion":"6.4.1","_nodeVersion":"10.15.1","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"b2fe5cc0706de9ea442c1d6691a302a48e342d1c","size":2267,"noattachment":false,"key":"/p-wait-for/-/p-wait-for-3.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/p-wait-for/download/p-wait-for-3.0.0.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/p-wait-for_3.0.0_1552971912865_0.8215618225252734"},"_hasShrinkwrap":false,"publish_time":1552971913000,"_cnpm_publish_time":1552971913000,"_cnpmcore_publish_time":"2021-12-16T11:26:35.381Z"},"2.0.1":{"name":"p-wait-for","version":"2.0.1","description":"Wait for a condition to be true","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/p-wait-for.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=6"},"scripts":{"test":"xo && ava"},"keywords":["promise","wait","for","waits","condition","poll","polling","boolean","async","await","promises","bluebird"],"dependencies":{"p-timeout":"^2.0.1"},"devDependencies":{"ava":"*","delay":"^3.0.0","time-span":"^2.0.0","xo":"*"},"gitHead":"fef5dd9e3d3d3f81c1ce1eac3dc950a64f384362","bugs":{"url":"https://github.com/sindresorhus/p-wait-for/issues"},"homepage":"https://github.com/sindresorhus/p-wait-for#readme","_id":"p-wait-for@2.0.1","_npmVersion":"6.4.1","_nodeVersion":"8.12.0","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"bc4dc3410dcba8ca4a92354f5b44f5c4ee6b6d7f","size":2033,"noattachment":false,"key":"/p-wait-for/-/p-wait-for-2.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/p-wait-for/download/p-wait-for-2.0.1.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/p-wait-for_2.0.1_1541589874451_0.39454136392264405"},"_hasShrinkwrap":false,"publish_time":1541589874573,"_cnpm_publish_time":1541589874573,"_cnpmcore_publish_time":"2021-12-16T11:26:35.565Z"},"2.0.0":{"name":"p-wait-for","version":"2.0.0","description":"Wait for a condition to be true","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/p-wait-for.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=6"},"scripts":{"test":"xo && ava"},"files":["index.js"],"keywords":["promise","wait","for","waits","condition","poll","polling","boolean","async","await","promises","bluebird"],"dependencies":{"p-timeout":"^2.0.1"},"devDependencies":{"ava":"*","delay":"^3.0.0","time-span":"^2.0.0","xo":"*"},"gitHead":"849661a4c839abaf982710161f5791851a1770d4","bugs":{"url":"https://github.com/sindresorhus/p-wait-for/issues"},"homepage":"https://github.com/sindresorhus/p-wait-for#readme","_id":"p-wait-for@2.0.0","_npmVersion":"6.2.0","_nodeVersion":"8.11.3","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"57a0367fb2ed23fcf1cc71db78b119a2068ca0f1","size":1988,"noattachment":false,"key":"/p-wait-for/-/p-wait-for-2.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/p-wait-for/download/p-wait-for-2.0.0.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/p-wait-for_2.0.0_1532852622371_0.767313834099898"},"_hasShrinkwrap":false,"publish_time":1532852622462,"_cnpm_publish_time":1532852622462,"_cnpmcore_publish_time":"2021-12-16T11:26:36.040Z"},"1.0.0":{"name":"p-wait-for","version":"1.0.0","description":"Wait for a condition to be true","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/p-wait-for.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=4"},"scripts":{"test":"xo && ava"},"files":["index.js"],"keywords":["promise","wait","for","waits","condition","poll","polling","boolean","async","await","promises","bluebird"],"devDependencies":{"ava":"*","delay":"^1.3.1","time-span":"^1.0.0","xo":"*"},"xo":{"esnext":true},"gitHead":"a11253981fae90c8539cae5ba1418981be689c95","bugs":{"url":"https://github.com/sindresorhus/p-wait-for/issues"},"homepage":"https://github.com/sindresorhus/p-wait-for#readme","_id":"p-wait-for@1.0.0","_shasum":"874dd6418abef2a1990520409a4bb6b0621f8b90","_from":".","_npmVersion":"2.15.9","_nodeVersion":"4.6.0","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"874dd6418abef2a1990520409a4bb6b0621f8b90","size":1922,"noattachment":false,"key":"/p-wait-for/-/p-wait-for-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/p-wait-for/download/p-wait-for-1.0.0.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/p-wait-for-1.0.0.tgz_1477033382804_0.17285202839411795"},"directories":{},"publish_time":1477033385054,"_hasShrinkwrap":false,"_cnpm_publish_time":1477033385054,"_cnpmcore_publish_time":"2021-12-16T11:26:36.265Z"}},"readme":"# p-wait-for\n\n> Wait for a condition to be true\n\nCan be useful for polling.\n\n## Install\n\n```sh\nnpm install p-wait-for\n```\n\n## Usage\n\n```js\nimport pWaitFor from 'p-wait-for';\nimport {pathExists} from 'path-exists';\n\nawait pWaitFor(() => pathExists('unicorn.png'));\nconsole.log('Yay! The file now exists.');\n```\n\n## API\n\n### pWaitFor(condition, options?)\n\nReturns a `Promise` that resolves when `condition` returns `true`. Rejects if `condition` throws or returns a `Promise` that rejects.\n\n#### condition\n\nType: `Function`\n\nExpected to return `Promise<boolean> | boolean` or a value from `pWaitFor.resolveWith()`.\n\n#### options\n\nType: `object`\n\n##### interval\n\nType: `number`\\\nDefault: `20`\n\nNumber of milliseconds to wait after `condition` resolves to `false` before calling it again.\n\n##### timeout\n\nType: `number | TimeoutOptions`\\\nDefault: `Infinity`\n\nNumber of milliseconds to wait before automatically rejecting with a `TimeoutError`.\n\nYou can customize the timeout `Error` by specifying `TimeoutOptions`.\n\n```js\nimport pWaitFor from 'p-wait-for';\nimport {pathExists} from 'path-exists';\n\nawait pWaitFor(() => pathExists('unicorn.png'), {\n\ttimeout: {\n\t\tmilliseconds: 100,\n\t\tmessage: new Error('Time’s up!')\n\t}\n});\n\nconsole.log('Yay! The file now exists.');\n```\n\n###### milliseconds\n\nType: `number`\n\nMilliseconds before timing out.\n\nPassing `Infinity` will cause it to never time out.\n\n###### message\n\nType: `string | Error`\n\nSpecify a custom error message or error. If not specified, the default error message will be 'Promise timed out after {milliseconds} milliseconds' where {milliseconds} is replaced with the actual timeout value.\n\nIf you do a custom error, it's recommended to sub-class `TimeoutError`.\n\n###### fallback\n\nType: `Function`\n\nDo something other than rejecting with an error on timeout.\n\nYou could for example retry with more attempts.\n\nExample:\n\n```js\nimport pWaitFor from 'p-wait-for';\nimport {pathExists} from 'path-exists';\n\nconst result = await pWaitFor(() => pathExists('unicorn.png'), {\n\ttimeout: {\n\t\tmilliseconds: 50,\n\t\tfallback: () => {\n\t\t\tconsole.log('Time’s up! Executed the fallback function.');\n\t\t\treturn 'default-value';\n\t\t},\n\t}\n});\n\nconsole.log(result); // 'default-value'\n```\n\n##### before\n\nType: `boolean`\\\nDefault: `true`\n\nWhether to run the check immediately rather than starting by waiting `interval` milliseconds.\n\nUseful for when the check, if run immediately, would likely return `false`. In this scenario, set `before` to `false`.\n\n##### signal\n\nType: `AbortSignal`\n\nAn `AbortSignal` to cancel the wait operation.\n\n### pWaitFor.resolveWith(value)\n\nResolve the main promise with a custom value.\n\n```js\nimport pWaitFor from 'p-wait-for';\nimport {pathExists} from 'path-exists';\n\nconst path = await pWaitFor(async () => {\n\tconst path = getPath();\n\treturn await pathExists(path) && pWaitFor.resolveWith(path);\n});\n\nconsole.log(path);\n```\n\n### TimeoutError\n\nExposed for instance checking.\n\n## Related\n\n- [p-whilst](https://github.com/sindresorhus/p-whilst) - Calls a function repeatedly while a condition returns true and then resolves the promise\n- [More…](https://github.com/sindresorhus/promise-fun)\n","_attachments":{},"homepage":"https://github.com/sindresorhus/p-wait-for#readme","bugs":{"url":"https://github.com/sindresorhus/p-wait-for/issues"},"license":"MIT"}