{"_id":"p-event","_rev":"199874","name":"p-event","description":"Promisify an event by waiting for it to be emitted","dist-tags":{"latest":"5.0.1"},"maintainers":[{"name":"sindresorhus","email":""}],"time":{"modified":"2023-03-20T08:22:01.000Z","created":"2017-04-26T17:01:50.528Z","5.0.1":"2021-11-03T15:40:16.907Z","5.0.0":"2021-11-03T11:53:17.267Z","4.2.0":"2020-06-06T06:05:10.134Z","4.1.0":"2019-04-03T05:04:48.603Z","4.0.0":"2019-03-13T16:53:28.807Z","3.0.0":"2019-03-02T19:49:16.825Z","2.3.1":"2019-02-12T03:53:04.263Z","2.3.0":"2019-02-12T03:31:15.204Z","2.2.0":"2019-01-20T15:45:44.007Z","2.1.0":"2018-06-27T06:02:51.512Z","2.0.0":"2018-05-25T19:29:45.896Z","1.2.0":"2017-05-14T15:05:50.048Z","1.3.0":"2017-06-21T22:06:46.714Z","1.1.0":"2017-05-07T10:30:25.926Z","1.0.0":"2017-04-26T17:01:50.528Z"},"users":{},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"repository":{"type":"git","url":"git+https://github.com/sindresorhus/p-event.git"},"versions":{"5.0.1":{"name":"p-event","version":"5.0.1","description":"Promisify an event by waiting for it to be emitted","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/p-event.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.20.0 || ^14.13.1 || >=16.0.0"},"scripts":{"test":"xo && ava && tsd"},"keywords":["promise","events","event","emitter","eventemitter","event-emitter","emit","emits","listener","promisify","addlistener","addeventlistener","wait","waits","on","browser","dom","async","await","promises","bluebird"],"dependencies":{"p-timeout":"^5.0.2"},"devDependencies":{"@types/node":"^16.11.6","ava":"^3.15.0","delay":"^5.0.0","tsd":"^0.18.0","xo":"^0.45.0"},"types":"./index.d.ts","gitHead":"1c83f5fe28f3ab64117d93c3d025b089397df23d","bugs":{"url":"https://github.com/sindresorhus/p-event/issues"},"homepage":"https://github.com/sindresorhus/p-event#readme","_id":"p-event@5.0.1","_nodeVersion":"17.0.1","_npmVersion":"8.1.0","dist":{"shasum":"614624ec02ae7f4f13d09a721c90586184af5b0c","size":6044,"noattachment":false,"key":"/p-event/-/p-event-5.0.1.tgz","tarball":"http://name.csiicloud.com:7001/p-event/download/p-event-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-event_5.0.1_1635954016750_0.3970194135952385"},"_hasShrinkwrap":false,"publish_time":1635954016907,"_cnpm_publish_time":1635954016907,"_cnpmcore_publish_time":"2021-12-13T15:32:56.804Z"},"5.0.0":{"name":"p-event","version":"5.0.0","description":"Promisify an event by waiting for it to be emitted","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/p-event.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.20.0 || ^14.13.1 || >=16.0.0"},"scripts":{"test":"xo && ava && tsd"},"keywords":["promise","events","event","emitter","eventemitter","event-emitter","emit","emits","listener","promisify","addlistener","addeventlistener","wait","waits","on","browser","dom","async","await","promises","bluebird"],"dependencies":{"p-timeout":"^5.0.2"},"devDependencies":{"@types/node":"^16.11.6","ava":"^3.15.0","delay":"^5.0.0","tsd":"^0.18.0","xo":"^0.45.0"},"types":"./index.d.ts","gitHead":"edf7089bdc18a17950eddfba4af9f651aeb96acf","bugs":{"url":"https://github.com/sindresorhus/p-event/issues"},"homepage":"https://github.com/sindresorhus/p-event#readme","_id":"p-event@5.0.0","_nodeVersion":"17.0.1","_npmVersion":"8.1.0","dist":{"shasum":"4a2032bf2ce6ec74d3e5a0bc5328a413f0310ad9","size":6052,"noattachment":false,"key":"/p-event/-/p-event-5.0.0.tgz","tarball":"http://name.csiicloud.com:7001/p-event/download/p-event-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-event_5.0.0_1635940397113_0.05828738430740188"},"_hasShrinkwrap":false,"publish_time":1635940397267,"_cnpm_publish_time":1635940397267,"_cnpmcore_publish_time":"2021-12-13T15:32:57.139Z"},"4.2.0":{"name":"p-event","version":"4.2.0","description":"Promisify an event by waiting for it to be emitted","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/p-event.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","events","event","emitter","eventemitter","event-emitter","emit","emits","listener","promisify","addlistener","addeventlistener","wait","waits","on","browser","dom","async","await","promises","bluebird"],"dependencies":{"p-timeout":"^3.1.0"},"devDependencies":{"@types/node":"^12.0.2","ava":"^1.4.1","delay":"^4.1.0","tsd":"^0.11.0","xo":"^0.24.0"},"gitHead":"5905bc07affc28349ea6ff49c16c35cbe936abf8","bugs":{"url":"https://github.com/sindresorhus/p-event/issues"},"homepage":"https://github.com/sindresorhus/p-event#readme","_id":"p-event@4.2.0","_nodeVersion":"14.4.0","_npmVersion":"6.14.5","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"af4b049c8acd91ae81083ebd1e6f5cae2044c1b5","size":6359,"noattachment":false,"key":"/p-event/-/p-event-4.2.0.tgz","tarball":"http://name.csiicloud.com:7001/p-event/download/p-event-4.2.0.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/p-event_4.2.0_1591423509960_0.6265053099449027"},"_hasShrinkwrap":false,"publish_time":1591423510134,"_cnpm_publish_time":1591423510134},"4.1.0":{"name":"p-event","version":"4.1.0","description":"Promisify an event by waiting for it to be emitted","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/p-event.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=8"},"scripts":{"test":"xo && ava && tsd"},"keywords":["promise","events","event","emitter","eventemitter","event-emitter","emit","emits","listener","promisify","addlistener","addeventlistener","wait","waits","on","browser","dom","async","await","promises","bluebird"],"dependencies":{"p-timeout":"^2.0.1"},"devDependencies":{"@types/node":"^11.13.0","ava":"^1.4.1","delay":"^4.1.0","tsd":"^0.7.2","xo":"^0.24.0"},"gitHead":"3226456732aa20fc20e6a76eda73ed66d77fdf62","bugs":{"url":"https://github.com/sindresorhus/p-event/issues"},"homepage":"https://github.com/sindresorhus/p-event#readme","_id":"p-event@4.1.0","_nodeVersion":"8.15.0","_npmVersion":"6.9.0","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"e92bb866d7e8e5b732293b1c8269d38e9982bf8e","size":6231,"noattachment":false,"key":"/p-event/-/p-event-4.1.0.tgz","tarball":"http://name.csiicloud.com:7001/p-event/download/p-event-4.1.0.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/p-event_4.1.0_1554267888476_0.8612279956572029"},"_hasShrinkwrap":false,"publish_time":1554267888603,"_cnpm_publish_time":1554267888603},"4.0.0":{"name":"p-event","version":"4.0.0","description":"Promisify an event by waiting for it to be emitted","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/p-event.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=8"},"scripts":{"test":"xo && ava && tsd-check"},"keywords":["promise","events","event","emitter","eventemitter","event-emitter","emit","emits","listener","promisify","addlistener","addeventlistener","wait","waits","on","browser","dom","async","await","promises","bluebird"],"dependencies":{"p-timeout":"^2.0.1"},"devDependencies":{"@types/node":"^11.9.5","ava":"^1.2.1","delay":"^4.1.0","tsd-check":"^0.3.0","xo":"^0.24.0"},"gitHead":"13a317a9c05599bdac1f960dedf9b8d866a6db15","bugs":{"url":"https://github.com/sindresorhus/p-event/issues"},"homepage":"https://github.com/sindresorhus/p-event#readme","_id":"p-event@4.0.0","_nodeVersion":"8.15.0","_npmVersion":"6.9.0","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"c2b92cf720f2e1806894532f44ceac46f8d65624","size":6064,"noattachment":false,"key":"/p-event/-/p-event-4.0.0.tgz","tarball":"http://name.csiicloud.com:7001/p-event/download/p-event-4.0.0.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/p-event_4.0.0_1552496008480_0.9183606617940072"},"_hasShrinkwrap":false,"publish_time":1552496008807,"_cnpm_publish_time":1552496008807},"3.0.0":{"name":"p-event","version":"3.0.0","description":"Promisify an event by waiting for it to be emitted","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/p-event.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=8"},"scripts":{"test":"xo && ava && tsd-check"},"keywords":["promise","events","event","emitter","eventemitter","event-emitter","emit","emits","listener","promisify","addlistener","addeventlistener","wait","waits","on","browser","dom","async","await","promises","bluebird"],"dependencies":{"p-timeout":"^2.0.1"},"devDependencies":{"@types/node":"^11.9.5","ava":"^1.2.1","delay":"^4.1.0","tsd-check":"^0.3.0","xo":"^0.24.0"},"gitHead":"a8578a3dfb912f235883e0c84313efeb050cb20e","bugs":{"url":"https://github.com/sindresorhus/p-event/issues"},"homepage":"https://github.com/sindresorhus/p-event#readme","_id":"p-event@3.0.0","_nodeVersion":"10.15.1","_npmVersion":"6.8.0","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"f291d6c076a05c3af17eb6c08bdb6b73cdb826d9","size":6108,"noattachment":false,"key":"/p-event/-/p-event-3.0.0.tgz","tarball":"http://name.csiicloud.com:7001/p-event/download/p-event-3.0.0.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/p-event_3.0.0_1551556156699_0.7442990268698826"},"_hasShrinkwrap":false,"publish_time":1551556156825,"_cnpm_publish_time":1551556156825},"2.3.1":{"name":"p-event","version":"2.3.1","description":"Promisify an event by waiting for it to be emitted","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/p-event.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=6"},"scripts":{"test":"xo && ava"},"keywords":["promise","events","event","emitter","eventemitter","event-emitter","emit","emits","listener","promisify","addlistener","addeventlistener","wait","waits","on","browser","dom","async","await","promises","bluebird"],"dependencies":{"p-timeout":"^2.0.1"},"devDependencies":{"ava":"^1.2.1","delay":"^4.1.0","xo":"^0.24.0"},"gitHead":"aea0ca849de75295d6ae88a55b2f2a6c185b03dd","bugs":{"url":"https://github.com/sindresorhus/p-event/issues"},"homepage":"https://github.com/sindresorhus/p-event#readme","_id":"p-event@2.3.1","_npmVersion":"6.4.1","_nodeVersion":"10.15.0","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"596279ef169ab2c3e0cae88c1cfbb08079993ef6","size":5089,"noattachment":false,"key":"/p-event/-/p-event-2.3.1.tgz","tarball":"http://name.csiicloud.com:7001/p-event/download/p-event-2.3.1.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/p-event_2.3.1_1549943584153_0.8082839608912173"},"_hasShrinkwrap":false,"publish_time":1549943584263,"_cnpm_publish_time":1549943584263},"2.3.0":{"name":"p-event","version":"2.3.0","description":"Promisify an event by waiting for it to be emitted","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/p-event.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=6"},"scripts":{"test":"xo && ava"},"keywords":["promise","events","event","emitter","eventemitter","event-emitter","emit","emits","listener","promisify","addlistener","addeventlistener","wait","waits","on","browser","dom","async","await","promises","bluebird"],"dependencies":{"p-timeout":"^2.0.1"},"devDependencies":{"ava":"^1.2.1","delay":"^4.1.0","xo":"^0.24.0"},"gitHead":"0a8c9cb643694e6032f80c69298ee87dc4d1513b","bugs":{"url":"https://github.com/sindresorhus/p-event/issues"},"homepage":"https://github.com/sindresorhus/p-event#readme","_id":"p-event@2.3.0","_npmVersion":"6.4.1","_nodeVersion":"10.15.0","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"cc8638f8c1a1fae6deb7502c5736873c14089647","size":5094,"noattachment":false,"key":"/p-event/-/p-event-2.3.0.tgz","tarball":"http://name.csiicloud.com:7001/p-event/download/p-event-2.3.0.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/p-event_2.3.0_1549942275074_0.08067438256690718"},"_hasShrinkwrap":false,"publish_time":1549942275204,"_cnpm_publish_time":1549942275204},"2.2.0":{"name":"p-event","version":"2.2.0","description":"Promisify an event by waiting for it to be emitted","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/p-event.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=6"},"scripts":{"test":"xo && ava"},"keywords":["promise","events","event","emitter","eventemitter","event-emitter","emit","emits","listener","promisify","addlistener","addeventlistener","wait","waits","on","browser","dom","async","await","promises","bluebird"],"dependencies":{"p-timeout":"^2.0.1"},"devDependencies":{"ava":"^1.1.0","delay":"^4.1.0","xo":"^0.24.0"},"gitHead":"14afe4170d50706ad2cf6a03da78af25c3aa81d9","bugs":{"url":"https://github.com/sindresorhus/p-event/issues"},"homepage":"https://github.com/sindresorhus/p-event#readme","_id":"p-event@2.2.0","_nodeVersion":"8.15.0","_npmVersion":"6.6.0","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"70d4fa4ba7775219d1ae26ca44bd6f3b46bb91db","size":4633,"noattachment":false,"key":"/p-event/-/p-event-2.2.0.tgz","tarball":"http://name.csiicloud.com:7001/p-event/download/p-event-2.2.0.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/p-event_2.2.0_1547999143863_0.5236108211134338"},"_hasShrinkwrap":false,"publish_time":1547999144007,"_cnpm_publish_time":1547999144007},"2.1.0":{"name":"p-event","version":"2.1.0","description":"Promisify an event by waiting for it to be emitted","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/p-event.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=6"},"scripts":{"test":"xo && ava"},"files":["index.js"],"keywords":["promise","events","event","emitter","eventemitter","event-emitter","emit","emits","listener","promisify","addlistener","addeventlistener","wait","waits","on","browser","dom","async","await","promises","bluebird"],"dependencies":{"p-timeout":"^2.0.1"},"devDependencies":{"ava":"*","delay":"^3.0.0","xo":"*"},"gitHead":"23df74172ab0aa64f990fe31044e525cd8b8274c","bugs":{"url":"https://github.com/sindresorhus/p-event/issues"},"homepage":"https://github.com/sindresorhus/p-event#readme","_id":"p-event@2.1.0","_npmVersion":"5.6.0","_nodeVersion":"8.11.2","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"74de477a4e6b3aa8267240c7099e78ac52cb4db4","size":4027,"noattachment":false,"key":"/p-event/-/p-event-2.1.0.tgz","tarball":"http://name.csiicloud.com:7001/p-event/download/p-event-2.1.0.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/p-event_2.1.0_1530079371418_0.2702400392687685"},"_hasShrinkwrap":false,"publish_time":1530079371512,"_cnpm_publish_time":1530079371512},"2.0.0":{"name":"p-event","version":"2.0.0","description":"Promisify an event by waiting for it to be emitted","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/p-event.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=6"},"scripts":{"test":"xo && ava"},"files":["index.js"],"keywords":["promise","events","event","emitter","eventemitter","event-emitter","emit","emits","listener","promisify","addlistener","addeventlistener","wait","waits","on","browser","dom","async","await","promises","bluebird"],"dependencies":{"p-timeout":"^2.0.1"},"devDependencies":{"ava":"*","delay":"^3.0.0","xo":"*"},"gitHead":"eab39b090cafbf7775577673525452c815968c9a","bugs":{"url":"https://github.com/sindresorhus/p-event/issues"},"homepage":"https://github.com/sindresorhus/p-event#readme","_id":"p-event@2.0.0","_npmVersion":"5.6.0","_nodeVersion":"8.11.1","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"0efccf409c3b3a9ef5cd078ca39de7d446b43799","size":3293,"noattachment":false,"key":"/p-event/-/p-event-2.0.0.tgz","tarball":"http://name.csiicloud.com:7001/p-event/download/p-event-2.0.0.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/p-event_2.0.0_1527276585810_0.6530966498158739"},"_hasShrinkwrap":false,"publish_time":1527276585896,"_cnpm_publish_time":1527276585896},"1.2.0":{"name":"p-event","version":"1.2.0","description":"Promisify an event by waiting for it to be emitted","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/p-event.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=4"},"scripts":{"test":"xo && ava"},"files":["index.js"],"keywords":["promise","events","event","emitter","eventemitter","event-emitter","emit","emits","listener","promisify","addlistener","addeventlistener","wait","waits","on","browser","dom","async","await","promises","bluebird"],"dependencies":{"p-timeout":"^1.1.1"},"devDependencies":{"ava":"*","delay":"^1.3.1","xo":"*"},"gitHead":"80dfb8793b5481f09429f3c01c4df604fa03cde3","bugs":{"url":"https://github.com/sindresorhus/p-event/issues"},"homepage":"https://github.com/sindresorhus/p-event#readme","_id":"p-event@1.2.0","_shasum":"837cfbeb652e497922f22162fb1f4c8487e27173","_from":".","_npmVersion":"3.10.8","_nodeVersion":"6.9.1","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"837cfbeb652e497922f22162fb1f4c8487e27173","size":3150,"noattachment":false,"key":"/p-event/-/p-event-1.2.0.tgz","tarball":"http://name.csiicloud.com:7001/p-event/download/p-event-1.2.0.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/p-event-1.2.0.tgz_1494774347491_0.8959797311108559"},"directories":{},"publish_time":1494774350048,"_hasShrinkwrap":false,"_cnpm_publish_time":1494774350048},"1.3.0":{"name":"p-event","version":"1.3.0","description":"Promisify an event by waiting for it to be emitted","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/p-event.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=4"},"scripts":{"test":"xo && ava"},"files":["index.js"],"keywords":["promise","events","event","emitter","eventemitter","event-emitter","emit","emits","listener","promisify","addlistener","addeventlistener","wait","waits","on","browser","dom","async","await","promises","bluebird"],"dependencies":{"p-timeout":"^1.1.1"},"devDependencies":{"ava":"*","delay":"^1.3.1","xo":"*"},"gitHead":"1674bd43fe7602d2f048d3d199be12d4ef16787c","bugs":{"url":"https://github.com/sindresorhus/p-event/issues"},"homepage":"https://github.com/sindresorhus/p-event#readme","_id":"p-event@1.3.0","_shasum":"8e6b4f4f65c72bc5b6fe28b75eda874f96a4a085","_from":".","_npmVersion":"2.15.11","_nodeVersion":"4.8.3","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"8e6b4f4f65c72bc5b6fe28b75eda874f96a4a085","size":3287,"noattachment":false,"key":"/p-event/-/p-event-1.3.0.tgz","tarball":"http://name.csiicloud.com:7001/p-event/download/p-event-1.3.0.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/p-event-1.3.0.tgz_1498082805774_0.892939229728654"},"directories":{},"publish_time":1498082806714,"_hasShrinkwrap":false,"_cnpm_publish_time":1498082806714},"1.1.0":{"name":"p-event","version":"1.1.0","description":"Promisify an event by waiting for it to be emitted","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/p-event.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=4"},"scripts":{"test":"xo && ava"},"files":["index.js"],"keywords":["promise","events","event","emitter","eventemitter","event-emitter","emit","emits","listener","promisify","addlistener","addeventlistener","wait","waits","on","browser","dom","async","await","promises","bluebird"],"devDependencies":{"ava":"*","delay":"^1.3.1","xo":"*"},"gitHead":"e21ec727f1f39dc4a74138d5828ab951efd8b7e2","bugs":{"url":"https://github.com/sindresorhus/p-event/issues"},"homepage":"https://github.com/sindresorhus/p-event#readme","_id":"p-event@1.1.0","_shasum":"ef5ef2487e9fe4fe3b7d87022783b51254826d30","_from":".","_npmVersion":"4.2.0","_nodeVersion":"7.9.0","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"ef5ef2487e9fe4fe3b7d87022783b51254826d30","size":2957,"noattachment":false,"key":"/p-event/-/p-event-1.1.0.tgz","tarball":"http://name.csiicloud.com:7001/p-event/download/p-event-1.1.0.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/p-event-1.1.0.tgz_1494153025631_0.21685738256201148"},"directories":{},"publish_time":1494153025926,"_hasShrinkwrap":false,"_cnpm_publish_time":1494153025926},"1.0.0":{"name":"p-event","version":"1.0.0","description":"Promisify an event by waiting for it to be emitted","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/p-event.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=4"},"scripts":{"test":"xo && ava"},"files":["index.js"],"keywords":["promise","events","event","emitter","eventemitter","event-emitter","emit","emits","listener","promisify","addlistener","addeventlistener","wait","waits","on","browser","dom","async","await","promises","bluebird"],"devDependencies":{"ava":"*","delay":"^1.3.1","xo":"*"},"gitHead":"3a2a5e5e28682ebdb3d2e81fd6667a1451a9f41d","bugs":{"url":"https://github.com/sindresorhus/p-event/issues"},"homepage":"https://github.com/sindresorhus/p-event#readme","_id":"p-event@1.0.0","_shasum":"f3e5ea67c501cc34c12cc68715c214948142c46f","_from":".","_npmVersion":"2.15.11","_nodeVersion":"4.7.3","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"f3e5ea67c501cc34c12cc68715c214948142c46f","size":2669,"noattachment":false,"key":"/p-event/-/p-event-1.0.0.tgz","tarball":"http://name.csiicloud.com:7001/p-event/download/p-event-1.0.0.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/p-event-1.0.0.tgz_1493226110149_0.8426612266339362"},"directories":{},"publish_time":1493226110528,"_hasShrinkwrap":false,"_cnpm_publish_time":1493226110528}},"readme":"# p-event\n\n> Promisify an event by waiting for it to be emitted\n\nUseful when you need only one event emission and want to use it with promises or await it in an async function.\n\nIt works with any event API in Node.js and the browser (using a bundler).\n\nIf you want multiple individual events as they are emitted, you can use the `pEventIterator()` method. [Observables](https://medium.com/@benlesh/learning-observable-by-building-observable-d5da57405d87) can be useful too.\n\n## Install\n\n```sh\nnpm install p-event\n```\n\n## Usage\n\nIn Node.js:\n\n```js\nimport {pEvent} from 'p-event';\nimport emitter from './some-event-emitter';\n\ntry {\n\tconst result = await pEvent(emitter, 'finish');\n\n\t// `emitter` emitted a `finish` event\n\tconsole.log(result);\n} catch (error) {\n\t// `emitter` emitted an `error` event\n\tconsole.error(error);\n}\n```\n\nIn the browser:\n\n```js\nimport {pEvent} from 'p-event';\n\nawait pEvent(document, 'DOMContentLoaded');\nconsole.log('????');\n```\n\nAsync iteration:\n\n```js\nimport {pEventIterator} from 'p-event';\nimport emitter from './some-event-emitter';\n\nconst asyncIterator = pEventIterator(emitter, 'data', {\n\tresolutionEvents: ['finish']\n});\n\nfor await (const event of asyncIterator) {\n\tconsole.log(event);\n}\n```\n\n## API\n\n### pEvent(emitter, event, options?)\n### pEvent(emitter, event, filter)\n\nReturns a `Promise` that is fulfilled when `emitter` emits an event matching `event`, or rejects if `emitter` emits any of the events defined in the `rejectionEvents` option.\n\n**Note**: `event` is a string for a single event type, for example, `'data'`. To listen on multiple\nevents, pass an array of strings, such as `['started', 'stopped']`.\n\nThe returned promise has a `.cancel()` method, which when called, removes the event listeners and causes the promise to never be settled.\n\n#### emitter\n\nType: `object`\n\nEvent emitter object.\n\nShould have either a `.on()`/`.addListener()`/`.addEventListener()` and `.off()`/`.removeListener()`/`.removeEventListener()` method, like the [Node.js `EventEmitter`](https://nodejs.org/api/events.html) and [DOM events](https://developer.mozilla.org/en-US/docs/Web/Events).\n\n#### event\n\nType: `string | string[]`\n\nName of the event or events to listen to.\n\nIf the same event is defined both here and in `rejectionEvents`, this one takes priority.\n\n#### options\n\nType: `object`\n\n##### rejectionEvents\n\nType: `string[]`\\\nDefault: `['error']`\n\nEvents that will reject the promise.\n\n##### multiArgs\n\nType: `boolean`\\\nDefault: `false`\n\nBy default, the promisified function will only return the first argument from the event callback, which works fine for most APIs. This option can be useful for APIs that return multiple arguments in the callback. Turning this on will make it return an array of all arguments from the callback, instead of just the first argument. This also applies to rejections.\n\nExample:\n\n```js\nimport {pEvent} from 'p-event';\nimport emitter from './some-event-emitter';\n\nconst [foo, bar] = await pEvent(emitter, 'finish', {multiArgs: true});\n```\n\n##### timeout\n\nType: `number`\\\nDefault: `Infinity`\n\nTime in milliseconds before timing out.\n\n##### filter\n\nType: `Function`\n\nA filter function for accepting an event.\n\n```js\nimport {pEvent} from 'p-event';\nimport emitter from './some-event-emitter';\n\nconst result = await pEvent(emitter, '????', value => value > 3);\n// Do something with first ???? event with a value greater than 3\n```\n\n### pEventMultiple(emitter, event, options)\n\nWait for multiple event emissions. Returns an array.\n\nThis method has the same arguments and options as `pEvent()` with the addition of the following options:\n\n#### options\n\nType: `object`\n\n##### count\n\n*Required*\\\nType: `number`\n\nThe number of times the event needs to be emitted before the promise resolves.\n\n##### resolveImmediately\n\nType: `boolean`\\\nDefault: `false`\n\nWhether to resolve the promise immediately. Emitting one of the `rejectionEvents` won't throw an error.\n\n**Note**: The returned array will be mutated when an event is emitted.\n\nExample:\n\n```js\nimport {pEventMultiple} from 'p-event';\n\nconst emitter = new EventEmitter();\n\nconst promise = pEventMultiple(emitter, 'hello', {\n\tresolveImmediately: true,\n\tcount: Infinity\n});\n\nconst result = await promise;\nconsole.log(result);\n//=> []\n\nemitter.emit('hello', 'Jack');\nconsole.log(result);\n//=> ['Jack']\n\nemitter.emit('hello', 'Mark');\nconsole.log(result);\n//=> ['Jack', 'Mark']\n\n// Stops listening\nemitter.emit('error', new Error('????'));\n\nemitter.emit('hello', 'John');\nconsole.log(result);\n//=> ['Jack', 'Mark']\n```\n\n### pEventIterator(emitter, event, options?)\n### pEventIterator(emitter, event, filter)\n\nReturns an [async iterator](https://2ality.com/2016/10/asynchronous-iteration.html) that lets you asynchronously iterate over events of `event` emitted from `emitter`. The iterator ends when `emitter` emits an event matching any of the events defined in `resolutionEvents`, or rejects if `emitter` emits any of the events defined in the `rejectionEvents` option.\n\nThis method has the same arguments and options as `pEvent()` with the addition of the following options:\n\n#### options\n\nType: `object`\n\n##### limit\n\nType: `number` *(non-negative integer)*\\\nDefault: `Infinity`\n\nThe maximum number of events for the iterator before it ends. When the limit is reached, the iterator will be marked as `done`. This option is useful to paginate events, for example, fetching 10 events per page.\n\n##### resolutionEvents\n\nType: `string[]`\\\nDefault: `[]`\n\nEvents that will end the iterator.\n\n### TimeoutError\n\nExposed for instance checking and sub-classing.\n\nExample:\n\n```js\nimport {pEvent} from 'p-event';\n\ntry {\n\tawait pEvent(emitter, 'finish');\n} catch (error) {\n\tif (error instanceof pEvent.TimeoutError) {\n\t\t// Do something specific for timeout errors\n\t}\n}\n```\n\n## Before and after\n\n```js\nimport fs from 'node:fs';\n\nfunction getOpenReadStream(file, callback) {\n\tconst stream = fs.createReadStream(file);\n\n\tstream.on('open', () => {\n\t\tcallback(null, stream);\n\t});\n\n\tstream.on('error', error => {\n\t\tcallback(error);\n\t});\n}\n\ngetOpenReadStream('unicorn.txt', (error, stream) => {\n\tif (error) {\n\t\tconsole.error(error);\n\t\treturn;\n\t}\n\n\tconsole.log('File descriptor:', stream.fd);\n\tstream.pipe(process.stdout);\n});\n```\n\n```js\nimport fs from 'node:fs';\nimport {pEvent} from 'p-event';\n\nasync function getOpenReadStream(file) {\n\tconst stream = fs.createReadStream(file);\n\tawait pEvent(stream, 'open');\n\treturn stream;\n}\n\n(async () => {\n\tconst stream = await getOpenReadStream('unicorn.txt');\n\tconsole.log('File descriptor:', stream.fd);\n\tstream.pipe(process.stdout);\n})()\n\t.catch(console.error);\n```\n\n## Tip\n\n### Dealing with calls that resolve with an error code\n\nSome functions might use a single event for success and for certain errors. Promises make it easy to have combined error handler for both error events and successes containing values which represent errors.\n\n```js\nimport {pEvent} from 'p-event';\nimport emitter from './some-event-emitter';\n\ntry {\n\tconst result = await pEvent(emitter, 'finish');\n\n\tif (result === 'unwanted result') {\n\t\tthrow new Error('Emitter finished with an error');\n\t}\n\n\t// `emitter` emitted a `finish` event with an acceptable value\n\tconsole.log(result);\n} catch (error) {\n\t// `emitter` emitted an `error` event or\n\t// emitted a `finish` with 'unwanted result'\n\tconsole.error(error);\n}\n```\n\n## Related\n\n- [pify](https://github.com/sindresorhus/pify) - Promisify a callback-style function\n- [p-map](https://github.com/sindresorhus/p-map) - Map over promises concurrently\n- [More…](https://github.com/sindresorhus/promise-fun)\n","_attachments":{},"homepage":"https://github.com/sindresorhus/p-event#readme","bugs":{"url":"https://github.com/sindresorhus/p-event/issues"},"license":"MIT"}