Socket
Socket
Sign inDemoInstall

p-event

Package Overview
Dependencies
2
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.1.0 to 1.2.0

6

index.js
'use strict';
const pTimeout = require('p-timeout');
module.exports = (emitter, event, opts) => {

@@ -58,3 +60,7 @@ let cancel;

if (typeof opts.timeout === 'number') {
return pTimeout(ret, opts.timeout);
}
return ret;
};

5

package.json
{
"name": "p-event",
"version": "1.1.0",
"version": "1.2.0",
"description": "Promisify an event by waiting for it to be emitted",

@@ -44,2 +44,5 @@ "license": "MIT",

],
"dependencies": {
"p-timeout": "^1.1.1"
},
"devDependencies": {

@@ -46,0 +49,0 @@ "ava": "*",

17

readme.md

@@ -7,3 +7,5 @@ # p-event [![Build Status](https://travis-ci.org/sindresorhus/p-event.svg?branch=master)](https://travis-ci.org/sindresorhus/p-event)

If you want multiple individual events as they are emitted, this module is not for you, as a Promise is a single value. Instead, just continue using event callback or use [Observables](https://medium.com/@benlesh/learning-observable-by-building-observable-d5da57405d87).
## Install

@@ -82,3 +84,3 @@

By default, the promisified function will only return the first argument from the callback, which works fine for most APIs. This option can be useful for modules like `kue` that return multiple arguments. 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.
By 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.

@@ -88,8 +90,6 @@ Example:

```js
const kue = require('kue');
const pEvent = require('p-event');
const emitter = require('./some-event-emitter');
const queue = kue.createQueue();
pEvent(queue, 'job enqueue', {multiArgs: true}).then(result => {
pEvent(emitter, 'finish', {multiArgs: true}).then(result => {
const [id, type] = result;

@@ -99,3 +99,10 @@ });

##### timeout
Type: `Number`<br>
Default: `Infinity`
Time in milliseconds before timing out.
## Before and after

@@ -102,0 +109,0 @@

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