Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

add-evt-listener

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

add-evt-listener - npm Package Compare versions

Comparing version 0.0.5 to 0.1.0

9

package.json
{
"name": "add-evt-listener",
"version": "0.0.5",
"description": "convenient addEvtListener utility",
"version": "0.1.0",
"description": "convenient addEventListener utility",
"main": "index.cjs",
"repository": "https://github.com/tranvansang/add-evt-listener",
"author": "Tran Sang <t@sang.jp>",
"author": "Sang Tran <t@sang.jp>",
"license": "MIT",

@@ -21,5 +21,2 @@ "files": [

},
"scripts": {
"prepublish": "./compile.sh"
},
"devDependencies": {

@@ -26,0 +23,0 @@ "typescript": "^5.1.6"

# add-evt-listener
- Install: `yarn add add-evt-listener`.
- Exported functions:
- Usage
```typescript
import {addEvtListener, addEvtListenerOnce, addEvtListenerSelf, addEvtListenerSelfOnce} from 'add-evt-listener'
```
```javascript
import addEvtListener from 'add-evt-listener'
// or
const addEvtListener = require('add-evt-listener')
# API
- Parameter: `target`, `name` (event name), `handler`, `option`.
- Specs: call `target.addEventListener(name, handler, option)`.
- Return: a callback function that takes zero argument, used to remove the event listener via `target.removeEventListener`.
const removeEvtListener = addEvtListener(target, event, handler, option)
// equivalent to
target.addEventListener(event, handler, option)
`target.removeEventListener` is called at most once regardless of how many times the returned callback is called.
## Variant
- `Once`: remove the event listener after the first call.
- `Self`: only trigger the event listener when `evt.currentTarget === evt.target` (`evt` is the first parameter in `handler`).
removeEvtListener()
// equivalent to
target.removeEventListener(event, handler, option)
```

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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