Socket
Socket
Sign inDemoInstall

oj-event

Package Overview
Dependencies
0
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    oj-event

Makes namespaced eventlisteners possible on any DOM element. (on('click.nmsp', () => {}); off('click.nmsp');


Version published
Maintainers
1
Install size
10.6 kB
Created

Readme

Source

Event

Adds on, once, off and has methods to the Window, Document and Element prototypes.

Usage

import

import "oj-event"

on

on(event: string | string[], cb: Function, opts?: IOptions): this

  • adds the namespaced callback as an eventListener
  • this will override any previous events with the same namespace
  • if event is an array will recursively call on with each event
window.on("click.namespace", e => { ... })

off

off(event: string | string[]): this

  • removes the namespaced event
  • if event is an array will recursively call off with each event
window.off("click.namespace")

has

has(event: string | string[]): boolean

  • returns true if the event or all events are subscribed
window.has("click.namespace")

Types

IOptions

{ 
  preventDefault?: boolean
  stopPropagation?: boolean
  capture?: boolean
  passive?: boolean 
 }

Keywords

FAQs

Last updated on 05 Jan 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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