Socket
Socket
Sign inDemoInstall

events

Package Overview
Dependencies
0
Maintainers
3
Versions
17
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.1.0 to 3.2.0

tests/events-once.js

30

events.js

@@ -57,2 +57,3 @@ // Copyright Joyent, Inc. and other Node contributors.

module.exports = EventEmitter;
module.exports.once = once;

@@ -448,1 +449,30 @@ // Backwards-compat with node 0.10.x

}
function once(emitter, name) {
return new Promise(function (resolve, reject) {
function eventListener() {
if (errorListener !== undefined) {
emitter.removeListener('error', errorListener);
}
resolve([].slice.call(arguments));
};
var errorListener;
// Adding an error listener is not optional because
// if an error is thrown on an event emitter we cannot
// guarantee that the actual event we are waiting will
// be fired. The result could be a silent way to create
// memory or file descriptor leaks, which is something
// we should avoid.
if (name !== 'error') {
errorListener = function errorListener(err) {
emitter.removeListener(name, eventListener);
reject(err);
};
emitter.once('error', errorListener);
}
emitter.once(name, eventListener);
});
}

@@ -0,1 +1,7 @@

# 3.2.0
- Add `events.once` from Node.js 11.13.0.
To use this function, Promises must be supported in the environment. Use a polyfill like `es6-promise` if you support older browsers.
# 3.1.0 (2020-01-08)

@@ -2,0 +8,0 @@

9

package.json
{
"name": "events",
"id": "events",
"version": "3.1.0",
"version": "3.2.0",
"description": "Node's event emitter for all engines.",

@@ -27,4 +26,6 @@ "keywords": [

"airtap": "^1.0.0",
"isarray": "^2.0.2",
"tape": "^4.8.0"
"functions-have-names": "^1.2.1",
"has-symbols": "^1.0.1",
"isarray": "^2.0.5",
"tape": "^5.0.0"
},

@@ -31,0 +32,0 @@ "scripts": {

@@ -5,5 +5,5 @@ # events [![Build Status](https://travis-ci.org/Gozala/events.png?branch=master)](https://travis-ci.org/Gozala/events)

This implements the Node.js [`events`](http://nodejs.org/api/events.html) module for environments that do not have it, like browsers.
This implements the Node.js [`events`][node.js docs] module for environments that do not have it, like browsers.
> `events` currently matches the **Node.js 11.12.0** API.
> `events` currently matches the **Node.js 11.13.0** API.

@@ -38,3 +38,3 @@ Note that the `events` module uses ES5 features. If you need to support very old browsers like IE8, use a shim like [`es5-shim`](https://www.npmjs.com/package/es5-shim). You need both the shim and the sham versions of `es5-shim`.

See the [Node.js EventEmitter docs](http://nodejs.org/api/events.html). `events` currently matches the Node.js 11.12.0 API.
See the [Node.js EventEmitter docs][node.js docs]. `events` currently matches the Node.js 11.13.0 API.

@@ -51,1 +51,2 @@ ## Contributing

[MIT](./LICENSE)
[node.js docs]: https://nodejs.org/dist/v11.13.0/docs/api/events.html
var test = require('tape');
var functionsHaveNames = require('functions-have-names');
var hasSymbols = require('has-symbols');

@@ -24,2 +26,8 @@ require('./legacy-compat');

require('./events-list.js');
if (typeof Promise === 'function') {
require('./events-once.js');
} else {
// Promise support is not available.
test('./events-once.js', { skip: true }, function () {});
}
require('./listener-count.js');

@@ -29,3 +37,3 @@ require('./listeners-side-effects.js');

require('./max-listeners.js');
if ((function A () {}).name === 'A') {
if (functionsHaveNames()) {
require('./method-names.js');

@@ -43,3 +51,3 @@ } else {

require('./subclass.js');
if (typeof Symbol === 'function') {
if (hasSymbols()) {
require('./symbols.js');

@@ -46,0 +54,0 @@ } else {

Sorry, the diff of this file is not supported yet

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