Git Product home page Git Product logo

map-events's Introduction

map-events

Events mapped out completely - cross browsers

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

installation

npm install px-map-events --save

usage

const getEventsMap = require('map-events');

const EventsMap = getEventsMap();

output

a map of all events in the browser in the following format:

{
    'OBJECT': [
        'EVENT1',
        'EVENT2',
        'EVENT3'
    ]
}

example

const getEventsMap = require('map-events');

const webSocketEventsMap = getEventsMap('WebSocket');

(webSocketEventsMap == {
  "WebSocket": [
    "open",
    "error",
    "close",
    "message"
  ] // results in true
});

here's an example of how to register with your own listener to every event that exists on window!

const windowEventsMap = getEventsMap('window')['window'];

for (let i = 0; i < windowEventsMap.length; i++) {
  const event = windowEventsMap[i];
  window[event] = (event) => { console.log(event) });
}

options

  1. filter (first optional argument)

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

const getEventsMap = require('map-events');

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

default value: '*'

  1. 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 getEventsMap = require('map-events');

const EventsMap = getEventsMap('*', true); // will return a map with objects and  events properties that are the object's own properties
const EventsMap = getEventsMap('*', false); // will return a map with objects and  events properties - whether the properties are the object's own properties or not

default value: true

  1. noEmptyArrays (third optional argument)

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

const getEventsMap = require('map-events');

const EventsMap = getEventsMap('*', true, true); // will return a map with objects and events properties only if the object even has any events
const EventsMap = getEventsMap('*', true, false); // will return a map with objects and events properties whether the object has any events or not

default value: false

  1. 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 getEventsMap = require('map-events');

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

default value: false

contribution

in addition to this project there is a website that should show the events map of every (os + browser) combination that ever existed. in reality however, it shows most of the existing combinations, but not all of them. the maps were extracted using every existing combination in browserstack, but even in browserstack many automatic combinations have failed. also, the extraction script is not automatic and does not run every time there's a new browser/os. contributing to the JSON could help a lot with maintaining the map and keeping it as updated and as accurate as possible. highly appreciated!

map-events's People

Contributors

galpx avatar weizman avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.