-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdanehansen-EventDispatcher.min.js
68 lines (64 loc) · 8.22 KB
/
danehansen-EventDispatcher.min.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/*
* ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
* This devtool is neither made for production nor for readable output files.
* It uses "eval()" calls to create a separate source file in the browser devtools.
* If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
* or disable the default devtool with "devtool: false".
* If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
*/
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory();
else if(typeof define === 'function' && define.amd)
define([], factory);
else if(typeof exports === 'object')
exports["danehansen"] = factory();
else
root["danehansen"] = root["danehansen"] || {}, root["danehansen"]["EventDispatcher"] = factory();
})(self, function() {
return /******/ (() => { // webpackBootstrap
/******/ var __webpack_modules__ = ({
/***/ "./src/EventDispatcher.js":
/*!********************************!*\
!*** ./src/EventDispatcher.js ***!
\********************************/
/***/ ((module) => {
eval("function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === \"undefined\" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\n\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\n\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\nvar CALLBACKS = {};\n\nfunction _addEventListener(callbackHolder, type, listener) {\n var callbacks = callbackHolder[type];\n\n if (!callbacks) {\n callbacks = [];\n callbackHolder[type] = callbacks;\n }\n\n if (callbacks.indexOf(listener) < 0) {\n callbacks.push(listener);\n }\n}\n\nfunction _removeEventListener(callbackHolder, type, listener) {\n var callbacks = callbackHolder[type];\n\n if (callbacks) {\n var index = callbacks.indexOf(listener);\n\n if (index >= 0) {\n callbacks.splice(index, 1);\n }\n }\n}\n\nvar EventDispatcher = /*#__PURE__*/function () {\n function EventDispatcher(target) {\n var _this = this;\n\n _classCallCheck(this, EventDispatcher);\n\n _defineProperty(this, \"addEventListener\", function (type, listener) {\n _addEventListener(_this._callbacks, type, listener);\n });\n\n _defineProperty(this, \"removeEventListener\", function (type, listener) {\n _removeEventListener(_this._callbacks, type, listener);\n });\n\n _defineProperty(this, \"clearEventListeners\", function () {\n _this._callbacks = {};\n });\n\n _defineProperty(this, \"dispatchEvent\", function (type) {\n var callbacks = _this._callbacks[type];\n\n if (callbacks) {\n var obj = {\n target: _this._target,\n type: type\n };\n\n for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {\n args[_key - 1] = arguments[_key];\n }\n\n var _iterator = _createForOfIteratorHelper(callbacks),\n _step;\n\n try {\n for (_iterator.s(); !(_step = _iterator.n()).done;) {\n var callback = _step.value;\n callback.apply(void 0, [obj].concat(args));\n }\n } catch (err) {\n _iterator.e(err);\n } finally {\n _iterator.f();\n }\n }\n });\n\n this._target = target || this;\n this.clearEventListeners();\n }\n\n _createClass(EventDispatcher, null, [{\n key: \"addEventListener\",\n value: function addEventListener(type, listener) {\n _addEventListener(CALLBACKS, type, listener);\n }\n }, {\n key: \"removeEventListener\",\n value: function removeEventListener(type, listener) {\n _removeEventListener(CALLBACKS, type, listener);\n }\n }, {\n key: \"dispatchEvent\",\n value: function dispatchEvent(type) {\n var callbacks = CALLBACKS[type];\n\n if (callbacks) {\n for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {\n args[_key2 - 1] = arguments[_key2];\n }\n\n var _iterator2 = _createForOfIteratorHelper(callbacks),\n _step2;\n\n try {\n for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {\n var callback = _step2.value;\n callback.apply(void 0, args);\n }\n } catch (err) {\n _iterator2.e(err);\n } finally {\n _iterator2.f();\n }\n }\n }\n }]);\n\n return EventDispatcher;\n}();\n\nmodule.exports = EventDispatcher;\n\n//# sourceURL=webpack://danehansen.EventDispatcher/./src/EventDispatcher.js?");
/***/ })
/******/ });
/************************************************************************/
/******/ // The module cache
/******/ var __webpack_module_cache__ = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
/******/ var cachedModule = __webpack_module_cache__[moduleId];
/******/ if (cachedModule !== undefined) {
/******/ return cachedModule.exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = __webpack_module_cache__[moduleId] = {
/******/ // no module.id needed
/******/ // no module.loaded needed
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/************************************************************************/
/******/
/******/ // startup
/******/ // Load entry module and return exports
/******/ // This entry module is referenced by other modules so it can't be inlined
/******/ var __webpack_exports__ = __webpack_require__("./src/EventDispatcher.js");
/******/
/******/ return __webpack_exports__;
/******/ })()
;
});