New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

add-promise-listener

Package Overview
Dependencies
Maintainers
0
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

add-promise-listener - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

13

index.js

@@ -9,2 +9,6 @@ const { get } = Reflect;

// avoid event.preventDefault throwing due illegal Proxy invocation
const bound = (e, value) => typeof value === 'function' ? value.bind(e) : value;
// traps the `event.currentTarget` to be sure it's available later on
class Handler {

@@ -18,6 +22,13 @@ #currentTarget;

// next tick, which is why this proxy handler needs to exist.
return name === 'currentTarget' ? this.#currentTarget : get(e, name);
return name === 'currentTarget' ? this.#currentTarget : bound(e, get(e, name));
}
}
/**
* Add a listener that result as a Promise, fulfilled when the event happens once or rejected if the optional provided signal is aborted.
* @param {Element} element
* @param {string} type
* @param {{ signal?:AbortSignal, capture?:boolean, passive?:boolean, preventDefault?:boolean, stopPropagation?:boolean, stopImmediatePropagation?:boolean }?} options
* @returns {Promise<Event,Event>}
*/
export default (element, type, options = null) => new Promise(

@@ -24,0 +35,0 @@ (resolve, reject) => {

2

package.json
{
"name": "add-promise-listener",
"version": "0.1.0",
"version": "0.1.1",
"main": "index.js",

@@ -5,0 +5,0 @@ "directories": {

@@ -14,6 +14,12 @@ # add-promise-listener

{
// optional: stopPropagation, stopImmediatePropagation or ...
// this is optionally needed to be sure the operation is performed
// when it's needed and not during the next tick:
// stopPropagation: true
// stopImmediatePropagation: true
preventDefault: true,
// optional signal to eventually catch rejections
signal: ac.signal
// other standard options are allowed as well
// capture: true
// passive: true
}

@@ -20,0 +26,0 @@ ).then(

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc