🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

global-event-handlers-map

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

global-event-handlers-map

GlobalEventHandlers mapped out completely cross browsers

1.0.1
Source
npm
Version published
Weekly downloads
2
Maintainers
1
Weekly downloads
 
Created
Source

global-event-handlers

GlobalEventHandlers mapped out completely - cross browsers

Using this powerful little tool will map out for you all Global Event Handlers in any browser you'd wish to execute it on.

installation

npm install global-event-handlers-map --save

usage

const getGlobalEventsHandlersMap = require('global-event-handlers-map');

const gehsMap = getGlobalEventsHandlersMap();

output

a map of all global event listeners in the browser in the following format:

{
    'OBJECT': [
        'onEVENT1',
        'onEVENT2',
        'onEVENT3'
    ]
}

example

const getGlobalEventsHandlersMap = require('global-event-handlers-map');

const gehsMap = getGlobalEventsHandlersMap('WebSocket');

(gehsMap == {
  "WebSocket": [
    "onopen",
    "onerror",
    "onclose",
    "onmessage"
  ]
});

options

  • filter (first optional argument)

allows you to pass a string that must exist within the object in order for it to make the final result map:

const getGlobalEventsHandlersMap = require('global-event-handlers-map');

const gehsMap = getGlobalEventsHandlersMap('*'); // will return a non-filtered map
const gehsMap = getGlobalEventsHandlersMap('HTML'); // will return a map that only contains objects that contain the string 'HTML' (such as 'HTMLBodyElement')
const gehsMap = getGlobalEventsHandlersMap('Doc'); // will return a map that only contains objects that contain the string 'Doc' (such as 'Document')

default value: '*'

  • hasOwnProperty (second optional argument)

allows you to pass a boolean that indicates whether iterated object must has iterated property as its own property or not:

const getGlobalEventsHandlersMap = require('global-event-handlers-map');

const gehsMap = getGlobalEventsHandlersMap('*', true); // will return a map with objects and global event handlers properties that are the object's own properties
const gehsMap = getGlobalEventsHandlersMap('*', false); // will return a map with objects and global event handlers properties - whether the properties are the object's own properties or not

default value: true

  • noEmptyArrays (third optional argument)

allows you to pass a boolean that indicates whether final result object should contain objects that have zero global event handlers or not:

const getGlobalEventsHandlersMap = require('global-event-handlers-map');

const gehsMap = getGlobalEventsHandlersMap('*', true, true); // will return a map with objects and global event handlers properties only if the object even has any global event handlers
const gehsMap = getGlobalEventsHandlersMap('*', true, false); // will return a map with objects and global event handlers properties whether the object has any global event handlers or not

default value: false

  • debug (fourth optional argument)

allows you to pass a boolean that indicates whether to run module in debug mode or not. debug mode just logs errors in case any are thrown:

const getGlobalEventsHandlersMap = require('global-event-handlers-map');

const gehsMap = getGlobalEventsHandlersMap('*', true, true, true); // will run in debug mode
const gehsMap = getGlobalEventsHandlersMap('*', true, false, false); // will not run in debug mode

default value: false

Keywords

global

FAQs

Package last updated on 06 Apr 2019

Did you know?

Socket

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