Socket
Socket
Sign inDemoInstall

p-event

Package Overview
Dependencies
0
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.0 to 1.1.0

21

index.js

@@ -7,3 +7,4 @@ 'use strict';

opts = Object.assign({
rejectionEvents: ['error']
rejectionEvents: ['error'],
multiArgs: false
}, opts);

@@ -21,10 +22,20 @@

const resolveHandler = value => {
const resolveHandler = function (value) {
cancel();
resolve(value);
if (opts.multiArgs) {
resolve([].slice.apply(arguments));
} else {
resolve(value);
}
};
const rejectHandler = reason => {
const rejectHandler = function (reason) {
cancel();
reject(reason);
if (opts.multiArgs) {
reject([].slice.apply(arguments));
} else {
reject(reason);
}
};

@@ -31,0 +42,0 @@

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

@@ -5,0 +5,0 @@ "license": "MIT",

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

##### multiArgs
Type: `boolean`<br>
Default: `false`
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.
Example:
```js
const kue = require('kue');
const pEvent = require('p-event');
const queue = kue.createQueue();
pEvent(queue, 'job enqueue', {multiArgs: true}).then(result => {
const [id, type] = result;
});
```
## Before and after

@@ -79,0 +99,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