├── .gitignore ├── coverage ├── lcov-report │ ├── sort-arrow-sprite.png │ ├── prettify.css │ ├── index.html │ ├── cjs │ │ ├── index.html │ │ ├── poorlyfills.js.html │ │ └── index.js.html │ ├── sorter.js │ ├── base.css │ └── prettify.js ├── lcov.info └── coverage.json ├── .travis.yml ├── test ├── esm.html ├── index.html ├── index.js └── test.js ├── .npmignore ├── esm ├── .eslintrc ├── poorlyfills.js └── index.js ├── rollup.config.js ├── babel-plugins.json ├── LICENSE.txt ├── cjs ├── poorlyfills.js └── index.js ├── min.js ├── README.md ├── package.json └── index.js /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules/ -------------------------------------------------------------------------------- /coverage/lcov-report/sort-arrow-sprite.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WebReflection/event-target/HEAD/coverage/lcov-report/sort-arrow-sprite.png -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - stable 4 | git: 5 | depth: 1 6 | branches: 7 | only: 8 | - master 9 | after_success: 10 | - "npm run coveralls" -------------------------------------------------------------------------------- /test/esm.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | coverage/* 2 | esm/.eslintrc 3 | node_modules/* 4 | test/* 5 | _config.yml 6 | .DS_Store 7 | .gitignore 8 | .travis.yml 9 | babel-plugins.json 10 | package-lock.json 11 | rollup.config.js -------------------------------------------------------------------------------- /esm/.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "eslint:recommended", 3 | "parserOptions": { 4 | "sourceType": "module" 5 | }, 6 | "rules": { 7 | "no-case-declarations": 0, 8 | "no-fallthrough": 0 9 | } 10 | } -------------------------------------------------------------------------------- /test/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /rollup.config.js: -------------------------------------------------------------------------------- 1 | import babel from 'rollup-plugin-babel'; 2 | 3 | export default { 4 | input: 'esm/index.js', 5 | plugins: [ 6 | babel({ 7 | plugins: require('./babel-plugins.json') 8 | }) 9 | ], 10 | output: { 11 | exports: 'named', 12 | file: 'index.js', 13 | format: 'iife', 14 | name: 'EventTarget' 15 | } 16 | }; 17 | -------------------------------------------------------------------------------- /babel-plugins.json: -------------------------------------------------------------------------------- 1 | [ 2 | "check-es2015-constants", 3 | "transform-es2015-arrow-functions", 4 | "transform-es2015-block-scoped-functions", 5 | "transform-es2015-block-scoping", 6 | "transform-es2015-computed-properties", 7 | "transform-es2015-destructuring", 8 | "transform-es2015-duplicate-keys", 9 | "transform-es2015-function-name", 10 | "transform-es2015-shorthand-properties" 11 | ] -------------------------------------------------------------------------------- /coverage/lcov-report/prettify.css: -------------------------------------------------------------------------------- 1 | .pln{color:#000}@media screen{.str{color:#080}.kwd{color:#008}.com{color:#800}.typ{color:#606}.lit{color:#066}.pun,.opn,.clo{color:#660}.tag{color:#008}.atn{color:#606}.atv{color:#080}.dec,.var{color:#606}.fun{color:red}}@media print,projection{.str{color:#060}.kwd{color:#006;font-weight:bold}.com{color:#600;font-style:italic}.typ{color:#404;font-weight:bold}.lit{color:#044}.pun,.opn,.clo{color:#440}.tag{color:#006;font-weight:bold}.atn{color:#404}.atv{color:#060}}pre.prettyprint{padding:2px;border:1px solid #888}ol.linenums{margin-top:0;margin-bottom:0}li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{list-style-type:none}li.L1,li.L3,li.L5,li.L7,li.L9{background:#eee} 2 | -------------------------------------------------------------------------------- /test/index.js: -------------------------------------------------------------------------------- 1 | var cjs = require.resolve('../cjs'); 2 | var base = require('path').dirname(cjs); 3 | 4 | global.tressa = require('tressa'); 5 | global.Event = require('basichtml').Event; 6 | 7 | global.Array.prototype.findIndex = null; 8 | global.WeakMap = null; 9 | 10 | global.EventTarget = require('../cjs').default; 11 | 12 | require('./test.js'); 13 | 14 | // this should cover the window case 15 | Object.keys(require.cache).forEach(key => { 16 | if (key.indexOf(base) === 0) { 17 | delete require.cache[key]; 18 | } 19 | }); 20 | var asked = 0; 21 | Object.defineProperty((global.window = global), 'global', { 22 | get: () => asked++ ? window : void 0 23 | }); 24 | require('../cjs'); 25 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | ISC License 2 | 3 | Copyright (c) 2013-2017, Andrea Giammarchi, @WebReflection 4 | 5 | Permission to use, copy, modify, and/or distribute this software for any 6 | purpose with or without fee is hereby granted, provided that the above 7 | copyright notice and this permission notice appear in all copies. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH 10 | REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 11 | AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, 12 | INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 13 | LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 14 | OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 15 | PERFORMANCE OF THIS SOFTWARE. 16 | -------------------------------------------------------------------------------- /esm/poorlyfills.js: -------------------------------------------------------------------------------- 1 | export const G = typeof global === typeof null ? global : self; 2 | 3 | export const findIndex = [].findIndex || function (callback, context) { 4 | let i = this.length; 5 | while (i--) if (callback.call(context, this[i])) return i; 6 | return i; 7 | }; 8 | 9 | export const defineProperty = Object.defineProperty; 10 | 11 | // even if not unique each time, the used WeakMap 12 | // is one and one only so it's not required to grant 13 | // uniqueness per each instance. This is enough. 14 | const UID = '__event-target__' + Math.random(); 15 | export const WeakMap = G.WeakMap || function WeakMap() { 16 | return { 17 | get(obj) { return obj[UID]; }, 18 | set(obj, value) { 19 | defineProperty(obj, UID, { 20 | configurable: true, 21 | value 22 | }); 23 | } 24 | }; 25 | }; 26 | -------------------------------------------------------------------------------- /cjs/poorlyfills.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | const G = typeof global === typeof null ? global : self; 3 | exports.G = G; 4 | 5 | const findIndex = [].findIndex || function (callback, context) { 6 | let i = this.length; 7 | while (i--) if (callback.call(context, this[i])) return i; 8 | return i; 9 | }; 10 | exports.findIndex = findIndex; 11 | 12 | const defineProperty = Object.defineProperty; 13 | exports.defineProperty = defineProperty; 14 | 15 | // even if not unique each time, the used WeakMap 16 | // is one and one only so it's not required to grant 17 | // uniqueness per each instance. This is enough. 18 | const UID = '__event-target__' + Math.random(); 19 | const WeakMap = G.WeakMap || function WeakMap() { 20 | return { 21 | get(obj) { return obj[UID]; }, 22 | set(obj, value) { 23 | defineProperty(obj, UID, { 24 | configurable: true, 25 | value 26 | }); 27 | } 28 | }; 29 | }; 30 | exports.WeakMap = WeakMap; 31 | -------------------------------------------------------------------------------- /test/test.js: -------------------------------------------------------------------------------- 1 | tressa.title('EventTarget Class'); 2 | 3 | var et = new EventTarget(); 4 | et.dispatchEvent(new Event('phone')); 5 | 6 | function noOp() { noOp.i++; } 7 | noOp.i = 0; 8 | 9 | et.addEventListener('phone', noOp); 10 | et.addEventListener('phone', noOp); 11 | et.addEventListener( 12 | 'phone', 13 | function (home) { 14 | tressa.assert(home.type === 'phone', 'expected event type'); 15 | tressa.assert(this === et, 'correct context'); 16 | tressa.assert(this === home.target, 'correct target'); 17 | tressa.assert(this === home.currentTarget, 'correct currentTarget'); 18 | }, 19 | {once: true} 20 | ); 21 | 22 | et.dispatchEvent(new Event('phone')); 23 | 24 | tressa.assert(noOp.i === 1, 'same listener is not added twice'); 25 | 26 | et.removeEventListener('phone', noOp); 27 | et.removeEventListener('phone', noOp); 28 | 29 | et.removeEventListener('nope', noOp); 30 | 31 | var listener = { 32 | handleEvent: function (e) { 33 | tressa.assert(this === listener, 'handleEvent is also supported'); 34 | } 35 | }; 36 | et.addEventListener('yep', listener, {once: true}); 37 | et.dispatchEvent(new Event('yep')); 38 | -------------------------------------------------------------------------------- /min.js: -------------------------------------------------------------------------------- 1 | /*! (c) 2017 Andrea Giammarchi (ISC) */ 2 | var EventTarget=function(){"use strict";var t="object"==typeof global?global:self,e=[].findIndex||function(t,e){for(var n=this.length;n--;)if(t.call(e,this[n]))return n;return n},n=Object.defineProperty,r="__event-target__"+Math.random(),i=t.WeakMap||function(){return{get:function(t){return t[r]},set:function(t,e){n(t,r,{configurable:!0,value:e})}}},a=t.EventTarget;try{new a}catch(o){a=function(){function t(){}function r(t){var e=t.options;e&&e.once&&u.call(t.target,this.type,t.listener,t.options),"function"==typeof t.listener?t.listener.call(t.target,this):t.listener.handleEvent(this)}function a(t){return this===t.listener}function o(t,n,r){var i=f(this),o=i[t]||(i[t]=[]);e.call(o,a,n)<0&&o.push({target:this,listener:n,options:r})}function c(t){var e=f(this),n=e[t.type];return n&&(h(t,{currentTarget:this,target:this}),n.forEach(r,t),delete t.currentTarget,delete t.target),!0}function u(t,n,r){var i=f(this),o=i[t];if(o){var c=e.call(o,a,n);-1( or `from 'event-target/esm'` ) 20 | 21 | ### Compatibility: 22 | 23 | Every. JavaScript. Engine. 24 | -------------------------------------------------------------------------------- /coverage/lcov.info: -------------------------------------------------------------------------------- 1 | TN: 2 | SF:/Users/agiammarchi/git/event-target/cjs/index.js 3 | FN:33,EventTarget 4 | FN:46,dispatch 5 | FN:62,registered 6 | FN:67,addEventListener 7 | FN:75,dispatchEvent 8 | FN:92,removeEventListener 9 | FN:102,Null 10 | FNF:7 11 | FNH:7 12 | FNDA:1,EventTarget 13 | FNDA:3,dispatch 14 | FNDA:5,registered 15 | FNDA:4,addEventListener 16 | FNDA:3,dispatchEvent 17 | FNDA:5,removeEventListener 18 | FNDA:1,Null 19 | DA:2,2 20 | DA:4,1 21 | DA:6,1 22 | DA:7,1 23 | DA:9,1 24 | DA:12,1 25 | DA:15,12 26 | DA:16,1 27 | DA:17,1 28 | DA:18,1 29 | DA:19,1 30 | DA:23,1 31 | DA:24,3 32 | DA:25,7 33 | DA:33,1 34 | DA:36,1 35 | DA:46,1 36 | DA:47,3 37 | DA:48,3 38 | DA:49,2 39 | DA:54,3 40 | DA:55,2 41 | DA:57,1 42 | DA:62,1 43 | DA:63,5 44 | DA:67,1 45 | DA:68,4 46 | DA:69,4 47 | DA:70,4 48 | DA:71,3 49 | DA:75,1 50 | DA:76,3 51 | DA:77,3 52 | DA:78,3 53 | DA:79,2 54 | DA:83,2 55 | DA:84,2 56 | DA:85,2 57 | DA:87,3 58 | DA:92,1 59 | DA:93,5 60 | DA:94,5 61 | DA:95,5 62 | DA:96,4 63 | DA:97,4 64 | DA:102,1 65 | DA:103,1 66 | DA:105,1 67 | DA:110,1 68 | LF:49 69 | LH:49 70 | BRDA:15,1,0,12 71 | BRDA:15,1,1,1 72 | BRDA:48,2,0,2 73 | BRDA:48,2,1,1 74 | BRDA:48,3,0,3 75 | BRDA:48,3,1,2 76 | BRDA:54,4,0,2 77 | BRDA:54,4,1,1 78 | BRDA:69,5,0,4 79 | BRDA:69,5,1,2 80 | BRDA:70,6,0,3 81 | BRDA:70,6,1,1 82 | BRDA:78,7,0,2 83 | BRDA:78,7,1,1 84 | BRDA:95,8,0,4 85 | BRDA:95,8,1,1 86 | BRDA:97,9,0,3 87 | BRDA:97,9,1,1 88 | BRF:18 89 | BRH:18 90 | end_of_record 91 | TN: 92 | SF:/Users/agiammarchi/git/event-target/cjs/poorlyfills.js 93 | FN:5,(anonymous_1) 94 | FN:19,WeakMap 95 | FN:21,(anonymous_3) 96 | FN:22,(anonymous_4) 97 | FNF:4 98 | FNH:4 99 | FNDA:8,(anonymous_1) 100 | FNDA:1,WeakMap 101 | FNDA:12,(anonymous_3) 102 | FNDA:1,(anonymous_4) 103 | DA:2,2 104 | DA:3,1 105 | DA:5,1 106 | DA:6,8 107 | DA:7,8 108 | DA:8,4 109 | DA:10,1 110 | DA:12,1 111 | DA:13,1 112 | DA:18,1 113 | DA:19,1 114 | DA:20,1 115 | DA:21,12 116 | DA:23,1 117 | DA:30,1 118 | LF:15 119 | LH:15 120 | BRDA:2,1,0,1 121 | BRDA:2,1,1,1 122 | BRDA:5,2,0,1 123 | BRDA:5,2,1,1 124 | BRDA:7,3,0,4 125 | BRDA:7,3,1,1 126 | BRDA:19,4,0,1 127 | BRDA:19,4,1,1 128 | BRF:8 129 | BRH:8 130 | end_of_record 131 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.2.3", 3 | "name": "event-target", 4 | "description": "The EventTarget Class Polyfill", 5 | "homepage": "https://github.com/WebReflection/event-target", 6 | "unpkg": "./min.js", 7 | "main": "./cjs/index.js", 8 | "module": "./esm/index.js", 9 | "scripts": { 10 | "bundle": "rollup --config rollup.config.js && npm run cleanup", 11 | "bundles": "echo '/*! (c) 2017 Andrea Giammarchi (ISC) */ var EventTarget = ' > index.js && asbundle esm/index.js | babel --plugins=$(node -e 'console.log(require(\"./babel-plugins.json\").join(\",\"))') >> index.js", 12 | "build": "npm run cjs && npm run bundle && npm run min && npm test && npm run size", 13 | "cleanup": "echo \"/*! (c) 2017 Andrea Giammarchi (ISC) */\n$(cat index.js | sed 's/}({}));/}());/' | sed 's/(exports)/()/' | sed 's/var EventTarget$1 = EventTarget;//' | sed 's/return exports;/return EventTarget;/' | sed -e 's/exports.*;//')\" > index.js", 14 | "cjs": "ascjs ./esm ./cjs", 15 | "coveralls": "cat ./coverage/lcov.info | coveralls", 16 | "min": "uglifyjs index.js --support-ie8 --comments=/^!/ -c -m -o min.js", 17 | "size": "cat index.js | wc -c;cat min.js | wc -c;gzip -c min.js | wc -c", 18 | "test": "istanbul cover test/index.js" 19 | }, 20 | "keywords": [ 21 | "EventTarget", 22 | "polyfill", 23 | "universal" 24 | ], 25 | "author": "Andrea Giammarchi", 26 | "devDependencies": { 27 | "ascjs": "^2.4.0", 28 | "babel-cli": "^6.26.0", 29 | "babel-plugin-check-es2015-constants": "^6.22.0", 30 | "babel-plugin-transform-es2015-arrow-functions": "^6.22.0", 31 | "babel-plugin-transform-es2015-block-scoped-functions": "^6.22.0", 32 | "babel-plugin-transform-es2015-block-scoping": "^6.26.0", 33 | "babel-plugin-transform-es2015-computed-properties": "^6.24.1", 34 | "babel-plugin-transform-es2015-destructuring": "^6.23.0", 35 | "babel-plugin-transform-es2015-duplicate-keys": "^6.24.1", 36 | "babel-plugin-transform-es2015-function-name": "^6.24.1", 37 | "babel-plugin-transform-es2015-shorthand-properties": "^6.24.1", 38 | "babel-plugin-transform-es2015-template-literals": "^6.22.0", 39 | "basichtml": "^0.10.5", 40 | "coveralls": "^2.13.1", 41 | "istanbul": "^0.4.5", 42 | "rollup": "^0.52.0", 43 | "rollup-plugin-babel": "^3.0.2", 44 | "tressa": "^0.3.1", 45 | "uglify-js": "^2.8.29" 46 | }, 47 | "repository": { 48 | "type": "git", 49 | "url": "git://github.com/WebReflection/event-target.git" 50 | }, 51 | "bugs": { 52 | "url": "https://github.com/WebReflection/event-target/issues" 53 | }, 54 | "directories": { 55 | "test": "test" 56 | }, 57 | "dependencies": {}, 58 | "license": "ISC" 59 | } 60 | -------------------------------------------------------------------------------- /esm/index.js: -------------------------------------------------------------------------------- 1 | import {defineProperty, findIndex, G, WeakMap} from './poorlyfills.js'; 2 | 3 | let EventTarget = G.EventTarget; 4 | 5 | try { 6 | new EventTarget; 7 | } catch(e) { 8 | EventTarget = (() => { 9 | 10 | // used to relate instances to listeners 11 | const wm = new WeakMap; 12 | 13 | // get listeners or relate them once to the instance 14 | const get = self => wm.get(self) || set(self); 15 | const set = self => { 16 | const dictionary = new Null; 17 | wm.set(self, dictionary); 18 | return dictionary; 19 | }; 20 | 21 | // define values as configurable 22 | const define = (where, what) => { 23 | for (const key in what) { 24 | defineProperty(where, key, { 25 | configurable: true, 26 | value: what[key] 27 | }); 28 | } 29 | }; 30 | 31 | // no need to transpile here, it's a very simple class 32 | function EventTarget() {} 33 | 34 | // EventTarget "class" definition 35 | define( 36 | EventTarget.prototype, 37 | { 38 | addEventListener, 39 | dispatchEvent, 40 | removeEventListener 41 | } 42 | ); 43 | 44 | // dispatch event for each listener 45 | function dispatch(info) { 46 | const options = info.options; 47 | if (options && options.once) { 48 | removeEventListener.call( 49 | info.target, 50 | this.type, info.listener, info.options 51 | ); 52 | } 53 | if (typeof info.listener === 'function') { 54 | info.listener.call(info.target, this); 55 | } else { 56 | info.listener.handleEvent(this); 57 | } 58 | } 59 | 60 | // search for a registered listener 61 | function registered(info) { 62 | return this === info.listener; 63 | } 64 | 65 | // public methods 66 | function addEventListener(type, listener, options) { 67 | const secret = get(this); 68 | const listeners = secret[type] || (secret[type] = []); 69 | if (findIndex.call(listeners, registered, listener) < 0) { 70 | listeners.push({target: this, listener, options}); 71 | } 72 | } 73 | 74 | function dispatchEvent(event) { 75 | const secret = get(this); 76 | const listeners = secret[event.type]; 77 | if (listeners) { 78 | define(event, { 79 | currentTarget: this, 80 | target: this 81 | }); 82 | listeners.forEach(dispatch, event); 83 | delete event.currentTarget; 84 | delete event.target; 85 | } 86 | return true; 87 | } 88 | 89 | // used both as public and private method, 90 | // to avoid method pollution/interception of private listeners 91 | function removeEventListener(type, listener, options) { 92 | const secret = get(this); 93 | const listeners = secret[type]; 94 | if (listeners) { 95 | const i = findIndex.call(listeners, registered, listener); 96 | if (-1 < i) listeners.splice(i, 1); 97 | } 98 | } 99 | 100 | // private "class" 101 | function Null() {} 102 | Null.prototype = Object.create(null); 103 | 104 | return EventTarget; 105 | 106 | })(); 107 | } 108 | 109 | export default EventTarget; 110 | -------------------------------------------------------------------------------- /cjs/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | const {defineProperty, findIndex, G, WeakMap} = require('./poorlyfills.js'); 3 | 4 | let EventTarget = G.EventTarget; 5 | 6 | try { 7 | new EventTarget; 8 | } catch(e) { 9 | EventTarget = (() => { 10 | 11 | // used to relate instances to listeners 12 | const wm = new WeakMap; 13 | 14 | // get listeners or relate them once to the instance 15 | const get = self => wm.get(self) || set(self); 16 | const set = self => { 17 | const dictionary = new Null; 18 | wm.set(self, dictionary); 19 | return dictionary; 20 | }; 21 | 22 | // define values as configurable 23 | const define = (where, what) => { 24 | for (const key in what) { 25 | defineProperty(where, key, { 26 | configurable: true, 27 | value: what[key] 28 | }); 29 | } 30 | }; 31 | 32 | // no need to transpile here, it's a very simple class 33 | function EventTarget() {} 34 | 35 | // EventTarget "class" definition 36 | define( 37 | EventTarget.prototype, 38 | { 39 | addEventListener, 40 | dispatchEvent, 41 | removeEventListener 42 | } 43 | ); 44 | 45 | // dispatch event for each listener 46 | function dispatch(info) { 47 | const options = info.options; 48 | if (options && options.once) { 49 | removeEventListener.call( 50 | info.target, 51 | this.type, info.listener, info.options 52 | ); 53 | } 54 | if (typeof info.listener === 'function') { 55 | info.listener.call(info.target, this); 56 | } else { 57 | info.listener.handleEvent(this); 58 | } 59 | } 60 | 61 | // search for a registered listener 62 | function registered(info) { 63 | return this === info.listener; 64 | } 65 | 66 | // public methods 67 | function addEventListener(type, listener, options) { 68 | const secret = get(this); 69 | const listeners = secret[type] || (secret[type] = []); 70 | if (findIndex.call(listeners, registered, listener) < 0) { 71 | listeners.push({target: this, listener, options}); 72 | } 73 | } 74 | 75 | function dispatchEvent(event) { 76 | const secret = get(this); 77 | const listeners = secret[event.type]; 78 | if (listeners) { 79 | define(event, { 80 | currentTarget: this, 81 | target: this 82 | }); 83 | listeners.forEach(dispatch, event); 84 | delete event.currentTarget; 85 | delete event.target; 86 | } 87 | return true; 88 | } 89 | 90 | // used both as public and private method, 91 | // to avoid method pollution/interception of private listeners 92 | function removeEventListener(type, listener, options) { 93 | const secret = get(this); 94 | const listeners = secret[type]; 95 | if (listeners) { 96 | const i = findIndex.call(listeners, registered, listener); 97 | if (-1 < i) listeners.splice(i, 1); 98 | } 99 | } 100 | 101 | // private "class" 102 | function Null() {} 103 | Null.prototype = Object.create(null); 104 | 105 | return EventTarget; 106 | 107 | })(); 108 | } 109 | 110 | Object.defineProperty(exports, '__esModule', {value: true}).default = EventTarget; 111 | -------------------------------------------------------------------------------- /coverage/lcov-report/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Code coverage report for All files 5 | 6 | 7 | 8 | 9 | 14 | 15 | 16 |
17 |
18 |

19 | / 20 |

21 |
22 |
23 | 100% 24 | Statements 25 | 68/68 26 |
27 |
28 | 100% 29 | Branches 30 | 26/26 31 |
32 |
33 | 100% 34 | Functions 35 | 11/11 36 |
37 |
38 | 100% 39 | Lines 40 | 64/64 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 | 69 | 70 | 71 | 72 | 73 | 74 | 75 |
FileStatementsBranchesFunctionsLines
cjs/
100%68/68100%26/26100%11/11100%64/64
76 |
77 |
78 | 82 | 83 | 84 | 91 | 92 | 93 | 94 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | /*! (c) 2017 Andrea Giammarchi (ISC) */ 2 | var EventTarget = (function () { 3 | 'use strict'; 4 | 5 | var G = typeof global === typeof null ? global : self; 6 | 7 | var findIndex = [].findIndex || function (callback, context) { 8 | var i = this.length; 9 | while (i--) { 10 | if (callback.call(context, this[i])) return i; 11 | }return i; 12 | }; 13 | 14 | var defineProperty = Object.defineProperty; 15 | 16 | // even if not unique each time, the used WeakMap 17 | // is one and one only so it's not required to grant 18 | // uniqueness per each instance. This is enough. 19 | var UID = '__event-target__' + Math.random(); 20 | var WeakMap = G.WeakMap || function WeakMap() { 21 | return { 22 | get: function get(obj) { 23 | return obj[UID]; 24 | }, 25 | set: function set(obj, value) { 26 | defineProperty(obj, UID, { 27 | configurable: true, 28 | value: value 29 | }); 30 | } 31 | }; 32 | }; 33 | 34 | var EventTarget = G.EventTarget; 35 | 36 | try { 37 | new EventTarget(); 38 | } catch (e) { 39 | EventTarget = function () { 40 | 41 | // used to relate instances to listeners 42 | var wm = new WeakMap(); 43 | 44 | // get listeners or relate them once to the instance 45 | var get = function get(self) { 46 | return wm.get(self) || set(self); 47 | }; 48 | var set = function set(self) { 49 | var dictionary = new Null(); 50 | wm.set(self, dictionary); 51 | return dictionary; 52 | }; 53 | 54 | // define values as configurable 55 | var define = function define(where, what) { 56 | for (var key in what) { 57 | defineProperty(where, key, { 58 | configurable: true, 59 | value: what[key] 60 | }); 61 | } 62 | }; 63 | 64 | // no need to transpile here, it's a very simple class 65 | function EventTarget() {} 66 | 67 | // EventTarget "class" definition 68 | define(EventTarget.prototype, { 69 | addEventListener: addEventListener, 70 | dispatchEvent: dispatchEvent, 71 | removeEventListener: removeEventListener 72 | }); 73 | 74 | // dispatch event for each listener 75 | function dispatch(info) { 76 | var options = info.options; 77 | if (options && options.once) { 78 | removeEventListener.call(info.target, this.type, info.listener, info.options); 79 | } 80 | if (typeof info.listener === 'function') { 81 | info.listener.call(info.target, this); 82 | } else { 83 | info.listener.handleEvent(this); 84 | } 85 | } 86 | 87 | // search for a registered listener 88 | function registered(info) { 89 | return this === info.listener; 90 | } 91 | 92 | // public methods 93 | function addEventListener(type, listener, options) { 94 | var secret = get(this); 95 | var listeners = secret[type] || (secret[type] = []); 96 | if (findIndex.call(listeners, registered, listener) < 0) { 97 | listeners.push({ target: this, listener: listener, options: options }); 98 | } 99 | } 100 | 101 | function dispatchEvent(event) { 102 | var secret = get(this); 103 | var listeners = secret[event.type]; 104 | if (listeners) { 105 | define(event, { 106 | currentTarget: this, 107 | target: this 108 | }); 109 | listeners.forEach(dispatch, event); 110 | delete event.currentTarget; 111 | delete event.target; 112 | } 113 | return true; 114 | } 115 | 116 | // used both as public and private method, 117 | // to avoid method pollution/interception of private listeners 118 | function removeEventListener(type, listener, options) { 119 | var secret = get(this); 120 | var listeners = secret[type]; 121 | if (listeners) { 122 | var i = findIndex.call(listeners, registered, listener); 123 | if (-1 < i) listeners.splice(i, 1); 124 | } 125 | } 126 | 127 | // private "class" 128 | function Null() {} 129 | Null.prototype = Object.create(null); 130 | 131 | return EventTarget; 132 | }(); 133 | } 134 | 135 | 136 | 137 | 138 | 139 | return EventTarget; 140 | 141 | }()); 142 | -------------------------------------------------------------------------------- /coverage/lcov-report/cjs/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Code coverage report for cjs/ 5 | 6 | 7 | 8 | 9 | 14 | 15 | 16 |
17 |
18 |

19 | all files cjs/ 20 |

21 |
22 |
23 | 100% 24 | Statements 25 | 68/68 26 |
27 |
28 | 100% 29 | Branches 30 | 26/26 31 |
32 |
33 | 100% 34 | Functions 35 | 11/11 36 |
37 |
38 | 100% 39 | Lines 40 | 64/64 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 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 |
FileStatementsBranchesFunctionsLines
index.js
100%51/51100%18/18100%7/7100%49/49
poorlyfills.js
100%17/17100%8/8100%4/4100%15/15
89 |
90 |
91 | 95 | 96 | 97 | 104 | 105 | 106 | 107 | -------------------------------------------------------------------------------- /coverage/lcov-report/cjs/poorlyfills.js.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Code coverage report for cjs/poorlyfills.js 5 | 6 | 7 | 8 | 9 | 14 | 15 | 16 |
17 |
18 |

19 | all files / cjs/ poorlyfills.js 20 |

21 |
22 |
23 | 100% 24 | Statements 25 | 17/17 26 |
27 |
28 | 100% 29 | Branches 30 | 8/8 31 |
32 |
33 | 100% 34 | Functions 35 | 4/4 36 |
37 |
38 | 100% 39 | Lines 40 | 15/15 41 |
42 |
43 |
44 |
45 |

 46 | 
137 | 
1 47 | 2 48 | 3 49 | 4 50 | 5 51 | 6 52 | 7 53 | 8 54 | 9 55 | 10 56 | 11 57 | 12 58 | 13 59 | 14 60 | 15 61 | 16 62 | 17 63 | 18 64 | 19 65 | 20 66 | 21 67 | 22 68 | 23 69 | 24 70 | 25 71 | 26 72 | 27 73 | 28 74 | 29 75 | 30 76 | 31  77 | 78 | 79 |   80 | 81 | 82 | 83 | 84 |   85 | 86 |   87 | 88 | 89 |   90 |   91 |   92 |   93 | 94 | 95 | 96 | 12× 97 |   98 | 99 |   100 |   101 |   102 |   103 |   104 |   105 | 106 |  
'use strict';
107 | const G = typeof global === typeof null ? global : self;
108 | exports.G = G;
109 |  
110 | const findIndex = [].findIndex || function (callback, context) {
111 |   let i = this.length;
112 |   while (i--) if (callback.call(context, this[i])) return i;
113 |   return i;
114 | };
115 | exports.findIndex = findIndex;
116 |  
117 | const defineProperty = Object.defineProperty;
118 | exports.defineProperty = defineProperty;
119 |  
120 | // even if not unique each time, the used WeakMap
121 | // is one and one only so it's not required to grant
122 | // uniqueness per each instance. This is enough.
123 | const UID = '__event-target__' + Math.random();
124 | const WeakMap = G.WeakMap || function WeakMap() {
125 |   return {
126 |     get(obj) { return obj[UID]; },
127 |     set(obj, value) {
128 |       defineProperty(obj, UID, {
129 |         configurable: true,
130 |         value
131 |       });
132 |     }
133 |   };
134 | };
135 | exports.WeakMap = WeakMap;
136 |  
138 |
139 |
140 | 144 | 145 | 146 | 153 | 154 | 155 | 156 | -------------------------------------------------------------------------------- /coverage/lcov-report/sorter.js: -------------------------------------------------------------------------------- 1 | var addSorting = (function () { 2 | "use strict"; 3 | var cols, 4 | currentSort = { 5 | index: 0, 6 | desc: false 7 | }; 8 | 9 | // returns the summary table element 10 | function getTable() { return document.querySelector('.coverage-summary'); } 11 | // returns the thead element of the summary table 12 | function getTableHeader() { return getTable().querySelector('thead tr'); } 13 | // returns the tbody element of the summary table 14 | function getTableBody() { return getTable().querySelector('tbody'); } 15 | // returns the th element for nth column 16 | function getNthColumn(n) { return getTableHeader().querySelectorAll('th')[n]; } 17 | 18 | // loads all columns 19 | function loadColumns() { 20 | var colNodes = getTableHeader().querySelectorAll('th'), 21 | colNode, 22 | cols = [], 23 | col, 24 | i; 25 | 26 | for (i = 0; i < colNodes.length; i += 1) { 27 | colNode = colNodes[i]; 28 | col = { 29 | key: colNode.getAttribute('data-col'), 30 | sortable: !colNode.getAttribute('data-nosort'), 31 | type: colNode.getAttribute('data-type') || 'string' 32 | }; 33 | cols.push(col); 34 | if (col.sortable) { 35 | col.defaultDescSort = col.type === 'number'; 36 | colNode.innerHTML = colNode.innerHTML + ''; 37 | } 38 | } 39 | return cols; 40 | } 41 | // attaches a data attribute to every tr element with an object 42 | // of data values keyed by column name 43 | function loadRowData(tableRow) { 44 | var tableCols = tableRow.querySelectorAll('td'), 45 | colNode, 46 | col, 47 | data = {}, 48 | i, 49 | val; 50 | for (i = 0; i < tableCols.length; i += 1) { 51 | colNode = tableCols[i]; 52 | col = cols[i]; 53 | val = colNode.getAttribute('data-value'); 54 | if (col.type === 'number') { 55 | val = Number(val); 56 | } 57 | data[col.key] = val; 58 | } 59 | return data; 60 | } 61 | // loads all row data 62 | function loadData() { 63 | var rows = getTableBody().querySelectorAll('tr'), 64 | i; 65 | 66 | for (i = 0; i < rows.length; i += 1) { 67 | rows[i].data = loadRowData(rows[i]); 68 | } 69 | } 70 | // sorts the table using the data for the ith column 71 | function sortByIndex(index, desc) { 72 | var key = cols[index].key, 73 | sorter = function (a, b) { 74 | a = a.data[key]; 75 | b = b.data[key]; 76 | return a < b ? -1 : a > b ? 1 : 0; 77 | }, 78 | finalSorter = sorter, 79 | tableBody = document.querySelector('.coverage-summary tbody'), 80 | rowNodes = tableBody.querySelectorAll('tr'), 81 | rows = [], 82 | i; 83 | 84 | if (desc) { 85 | finalSorter = function (a, b) { 86 | return -1 * sorter(a, b); 87 | }; 88 | } 89 | 90 | for (i = 0; i < rowNodes.length; i += 1) { 91 | rows.push(rowNodes[i]); 92 | tableBody.removeChild(rowNodes[i]); 93 | } 94 | 95 | rows.sort(finalSorter); 96 | 97 | for (i = 0; i < rows.length; i += 1) { 98 | tableBody.appendChild(rows[i]); 99 | } 100 | } 101 | // removes sort indicators for current column being sorted 102 | function removeSortIndicators() { 103 | var col = getNthColumn(currentSort.index), 104 | cls = col.className; 105 | 106 | cls = cls.replace(/ sorted$/, '').replace(/ sorted-desc$/, ''); 107 | col.className = cls; 108 | } 109 | // adds sort indicators for current column being sorted 110 | function addSortIndicators() { 111 | getNthColumn(currentSort.index).className += currentSort.desc ? ' sorted-desc' : ' sorted'; 112 | } 113 | // adds event listeners for all sorter widgets 114 | function enableUI() { 115 | var i, 116 | el, 117 | ithSorter = function ithSorter(i) { 118 | var col = cols[i]; 119 | 120 | return function () { 121 | var desc = col.defaultDescSort; 122 | 123 | if (currentSort.index === i) { 124 | desc = !currentSort.desc; 125 | } 126 | sortByIndex(i, desc); 127 | removeSortIndicators(); 128 | currentSort.index = i; 129 | currentSort.desc = desc; 130 | addSortIndicators(); 131 | }; 132 | }; 133 | for (i =0 ; i < cols.length; i += 1) { 134 | if (cols[i].sortable) { 135 | // add the click event handler on the th so users 136 | // dont have to click on those tiny arrows 137 | el = getNthColumn(i).querySelector('.sorter').parentElement; 138 | if (el.addEventListener) { 139 | el.addEventListener('click', ithSorter(i)); 140 | } else { 141 | el.attachEvent('onclick', ithSorter(i)); 142 | } 143 | } 144 | } 145 | } 146 | // adds sorting functionality to the UI 147 | return function () { 148 | if (!getTable()) { 149 | return; 150 | } 151 | cols = loadColumns(); 152 | loadData(cols); 153 | addSortIndicators(); 154 | enableUI(); 155 | }; 156 | })(); 157 | 158 | window.addEventListener('load', addSorting); 159 | -------------------------------------------------------------------------------- /coverage/lcov-report/base.css: -------------------------------------------------------------------------------- 1 | body, html { 2 | margin:0; padding: 0; 3 | height: 100%; 4 | } 5 | body { 6 | font-family: Helvetica Neue, Helvetica, Arial; 7 | font-size: 14px; 8 | color:#333; 9 | } 10 | .small { font-size: 12px; } 11 | *, *:after, *:before { 12 | -webkit-box-sizing:border-box; 13 | -moz-box-sizing:border-box; 14 | box-sizing:border-box; 15 | } 16 | h1 { font-size: 20px; margin: 0;} 17 | h2 { font-size: 14px; } 18 | pre { 19 | font: 12px/1.4 Consolas, "Liberation Mono", Menlo, Courier, monospace; 20 | margin: 0; 21 | padding: 0; 22 | -moz-tab-size: 2; 23 | -o-tab-size: 2; 24 | tab-size: 2; 25 | } 26 | a { color:#0074D9; text-decoration:none; } 27 | a:hover { text-decoration:underline; } 28 | .strong { font-weight: bold; } 29 | .space-top1 { padding: 10px 0 0 0; } 30 | .pad2y { padding: 20px 0; } 31 | .pad1y { padding: 10px 0; } 32 | .pad2x { padding: 0 20px; } 33 | .pad2 { padding: 20px; } 34 | .pad1 { padding: 10px; } 35 | .space-left2 { padding-left:55px; } 36 | .space-right2 { padding-right:20px; } 37 | .center { text-align:center; } 38 | .clearfix { display:block; } 39 | .clearfix:after { 40 | content:''; 41 | display:block; 42 | height:0; 43 | clear:both; 44 | visibility:hidden; 45 | } 46 | .fl { float: left; } 47 | @media only screen and (max-width:640px) { 48 | .col3 { width:100%; max-width:100%; } 49 | .hide-mobile { display:none!important; } 50 | } 51 | 52 | .quiet { 53 | color: #7f7f7f; 54 | color: rgba(0,0,0,0.5); 55 | } 56 | .quiet a { opacity: 0.7; } 57 | 58 | .fraction { 59 | font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; 60 | font-size: 10px; 61 | color: #555; 62 | background: #E8E8E8; 63 | padding: 4px 5px; 64 | border-radius: 3px; 65 | vertical-align: middle; 66 | } 67 | 68 | div.path a:link, div.path a:visited { color: #333; } 69 | table.coverage { 70 | border-collapse: collapse; 71 | margin: 10px 0 0 0; 72 | padding: 0; 73 | } 74 | 75 | table.coverage td { 76 | margin: 0; 77 | padding: 0; 78 | vertical-align: top; 79 | } 80 | table.coverage td.line-count { 81 | text-align: right; 82 | padding: 0 5px 0 20px; 83 | } 84 | table.coverage td.line-coverage { 85 | text-align: right; 86 | padding-right: 10px; 87 | min-width:20px; 88 | } 89 | 90 | table.coverage td span.cline-any { 91 | display: inline-block; 92 | padding: 0 5px; 93 | width: 100%; 94 | } 95 | .missing-if-branch { 96 | display: inline-block; 97 | margin-right: 5px; 98 | border-radius: 3px; 99 | position: relative; 100 | padding: 0 4px; 101 | background: #333; 102 | color: yellow; 103 | } 104 | 105 | .skip-if-branch { 106 | display: none; 107 | margin-right: 10px; 108 | position: relative; 109 | padding: 0 4px; 110 | background: #ccc; 111 | color: white; 112 | } 113 | .missing-if-branch .typ, .skip-if-branch .typ { 114 | color: inherit !important; 115 | } 116 | .coverage-summary { 117 | border-collapse: collapse; 118 | width: 100%; 119 | } 120 | .coverage-summary tr { border-bottom: 1px solid #bbb; } 121 | .keyline-all { border: 1px solid #ddd; } 122 | .coverage-summary td, .coverage-summary th { padding: 10px; } 123 | .coverage-summary tbody { border: 1px solid #bbb; } 124 | .coverage-summary td { border-right: 1px solid #bbb; } 125 | .coverage-summary td:last-child { border-right: none; } 126 | .coverage-summary th { 127 | text-align: left; 128 | font-weight: normal; 129 | white-space: nowrap; 130 | } 131 | .coverage-summary th.file { border-right: none !important; } 132 | .coverage-summary th.pct { } 133 | .coverage-summary th.pic, 134 | .coverage-summary th.abs, 135 | .coverage-summary td.pct, 136 | .coverage-summary td.abs { text-align: right; } 137 | .coverage-summary td.file { white-space: nowrap; } 138 | .coverage-summary td.pic { min-width: 120px !important; } 139 | .coverage-summary tfoot td { } 140 | 141 | .coverage-summary .sorter { 142 | height: 10px; 143 | width: 7px; 144 | display: inline-block; 145 | margin-left: 0.5em; 146 | background: url(sort-arrow-sprite.png) no-repeat scroll 0 0 transparent; 147 | } 148 | .coverage-summary .sorted .sorter { 149 | background-position: 0 -20px; 150 | } 151 | .coverage-summary .sorted-desc .sorter { 152 | background-position: 0 -10px; 153 | } 154 | .status-line { height: 10px; } 155 | /* dark red */ 156 | .red.solid, .status-line.low, .low .cover-fill { background:#C21F39 } 157 | .low .chart { border:1px solid #C21F39 } 158 | /* medium red */ 159 | .cstat-no, .fstat-no, .cbranch-no, .cbranch-no { background:#F6C6CE } 160 | /* light red */ 161 | .low, .cline-no { background:#FCE1E5 } 162 | /* light green */ 163 | .high, .cline-yes { background:rgb(230,245,208) } 164 | /* medium green */ 165 | .cstat-yes { background:rgb(161,215,106) } 166 | /* dark green */ 167 | .status-line.high, .high .cover-fill { background:rgb(77,146,33) } 168 | .high .chart { border:1px solid rgb(77,146,33) } 169 | /* dark yellow (gold) */ 170 | .medium .chart { border:1px solid #f9cd0b; } 171 | .status-line.medium, .medium .cover-fill { background: #f9cd0b; } 172 | /* light yellow */ 173 | .medium { background: #fff4c2; } 174 | /* light gray */ 175 | span.cline-neutral { background: #eaeaea; } 176 | 177 | .cbranch-no { background: yellow !important; color: #111; } 178 | 179 | .cstat-skip { background: #ddd; color: #111; } 180 | .fstat-skip { background: #ddd; color: #111 !important; } 181 | .cbranch-skip { background: #ddd !important; color: #111; } 182 | 183 | 184 | .cover-fill, .cover-empty { 185 | display:inline-block; 186 | height: 12px; 187 | } 188 | .chart { 189 | line-height: 0; 190 | } 191 | .cover-empty { 192 | background: white; 193 | } 194 | .cover-full { 195 | border-right: none !important; 196 | } 197 | pre.prettyprint { 198 | border: none !important; 199 | padding: 0 !important; 200 | margin: 0 !important; 201 | } 202 | .com { color: #999 !important; } 203 | .ignore-none { color: #999; font-weight: normal; } 204 | 205 | .wrapper { 206 | min-height: 100%; 207 | height: auto !important; 208 | height: 100%; 209 | margin: 0 auto -48px; 210 | } 211 | .footer, .push { 212 | height: 48px; 213 | } 214 | -------------------------------------------------------------------------------- /coverage/coverage.json: -------------------------------------------------------------------------------- 1 | {"/Users/agiammarchi/git/event-target/cjs/index.js":{"path":"/Users/agiammarchi/git/event-target/cjs/index.js","s":{"1":2,"2":1,"3":1,"4":1,"5":1,"6":1,"7":1,"8":12,"9":1,"10":1,"11":1,"12":1,"13":1,"14":3,"15":7,"16":1,"17":1,"18":1,"19":3,"20":3,"21":2,"22":3,"23":2,"24":1,"25":1,"26":5,"27":1,"28":4,"29":4,"30":4,"31":3,"32":1,"33":3,"34":3,"35":3,"36":2,"37":2,"38":2,"39":2,"40":3,"41":1,"42":5,"43":5,"44":5,"45":4,"46":4,"47":3,"48":1,"49":1,"50":1,"51":1},"b":{"1":[12,1],"2":[2,1],"3":[3,2],"4":[2,1],"5":[4,2],"6":[3,1],"7":[2,1],"8":[4,1],"9":[3,1]},"f":{"1":1,"2":3,"3":5,"4":4,"5":3,"6":5,"7":1},"fnMap":{"1":{"name":"EventTarget","line":33,"loc":{"start":{"line":33,"column":4},"end":{"line":33,"column":27}}},"2":{"name":"dispatch","line":46,"loc":{"start":{"line":46,"column":4},"end":{"line":46,"column":28}}},"3":{"name":"registered","line":62,"loc":{"start":{"line":62,"column":4},"end":{"line":62,"column":30}}},"4":{"name":"addEventListener","line":67,"loc":{"start":{"line":67,"column":4},"end":{"line":67,"column":55}}},"5":{"name":"dispatchEvent","line":75,"loc":{"start":{"line":75,"column":4},"end":{"line":75,"column":34}}},"6":{"name":"removeEventListener","line":92,"loc":{"start":{"line":92,"column":4},"end":{"line":92,"column":58}}},"7":{"name":"Null","line":102,"loc":{"start":{"line":102,"column":4},"end":{"line":102,"column":20}}}},"statementMap":{"1":{"start":{"line":2,"column":0},"end":{"line":2,"column":76}},"2":{"start":{"line":4,"column":0},"end":{"line":4,"column":32}},"3":{"start":{"line":6,"column":0},"end":{"line":108,"column":1}},"4":{"start":{"line":7,"column":2},"end":{"line":7,"column":18}},"5":{"start":{"line":9,"column":2},"end":{"line":107,"column":7}},"6":{"start":{"line":12,"column":4},"end":{"line":12,"column":27}},"7":{"start":{"line":15,"column":4},"end":{"line":15,"column":50}},"8":{"start":{"line":15,"column":24},"end":{"line":15,"column":49}},"9":{"start":{"line":16,"column":4},"end":{"line":20,"column":6}},"10":{"start":{"line":17,"column":6},"end":{"line":17,"column":34}},"11":{"start":{"line":18,"column":6},"end":{"line":18,"column":31}},"12":{"start":{"line":19,"column":6},"end":{"line":19,"column":24}},"13":{"start":{"line":23,"column":4},"end":{"line":30,"column":6}},"14":{"start":{"line":24,"column":6},"end":{"line":29,"column":7}},"15":{"start":{"line":25,"column":8},"end":{"line":28,"column":11}},"16":{"start":{"line":33,"column":4},"end":{"line":33,"column":29}},"17":{"start":{"line":36,"column":4},"end":{"line":43,"column":6}},"18":{"start":{"line":46,"column":4},"end":{"line":59,"column":5}},"19":{"start":{"line":47,"column":6},"end":{"line":47,"column":35}},"20":{"start":{"line":48,"column":6},"end":{"line":53,"column":7}},"21":{"start":{"line":49,"column":8},"end":{"line":52,"column":10}},"22":{"start":{"line":54,"column":6},"end":{"line":58,"column":7}},"23":{"start":{"line":55,"column":8},"end":{"line":55,"column":46}},"24":{"start":{"line":57,"column":8},"end":{"line":57,"column":40}},"25":{"start":{"line":62,"column":4},"end":{"line":64,"column":5}},"26":{"start":{"line":63,"column":6},"end":{"line":63,"column":36}},"27":{"start":{"line":67,"column":4},"end":{"line":73,"column":5}},"28":{"start":{"line":68,"column":6},"end":{"line":68,"column":31}},"29":{"start":{"line":69,"column":6},"end":{"line":69,"column":60}},"30":{"start":{"line":70,"column":6},"end":{"line":72,"column":7}},"31":{"start":{"line":71,"column":8},"end":{"line":71,"column":58}},"32":{"start":{"line":75,"column":4},"end":{"line":88,"column":5}},"33":{"start":{"line":76,"column":6},"end":{"line":76,"column":31}},"34":{"start":{"line":77,"column":6},"end":{"line":77,"column":43}},"35":{"start":{"line":78,"column":6},"end":{"line":86,"column":7}},"36":{"start":{"line":79,"column":8},"end":{"line":82,"column":11}},"37":{"start":{"line":83,"column":8},"end":{"line":83,"column":43}},"38":{"start":{"line":84,"column":8},"end":{"line":84,"column":35}},"39":{"start":{"line":85,"column":8},"end":{"line":85,"column":28}},"40":{"start":{"line":87,"column":6},"end":{"line":87,"column":18}},"41":{"start":{"line":92,"column":4},"end":{"line":99,"column":5}},"42":{"start":{"line":93,"column":6},"end":{"line":93,"column":31}},"43":{"start":{"line":94,"column":6},"end":{"line":94,"column":37}},"44":{"start":{"line":95,"column":6},"end":{"line":98,"column":7}},"45":{"start":{"line":96,"column":8},"end":{"line":96,"column":66}},"46":{"start":{"line":97,"column":8},"end":{"line":97,"column":43}},"47":{"start":{"line":97,"column":20},"end":{"line":97,"column":43}},"48":{"start":{"line":102,"column":4},"end":{"line":102,"column":22}},"49":{"start":{"line":103,"column":4},"end":{"line":103,"column":41}},"50":{"start":{"line":105,"column":4},"end":{"line":105,"column":23}},"51":{"start":{"line":110,"column":0},"end":{"line":110,"column":82}}},"branchMap":{"1":{"line":15,"type":"binary-expr","locations":[{"start":{"line":15,"column":24},"end":{"line":15,"column":36}},{"start":{"line":15,"column":40},"end":{"line":15,"column":49}}]},"2":{"line":48,"type":"if","locations":[{"start":{"line":48,"column":6},"end":{"line":48,"column":6}},{"start":{"line":48,"column":6},"end":{"line":48,"column":6}}]},"3":{"line":48,"type":"binary-expr","locations":[{"start":{"line":48,"column":10},"end":{"line":48,"column":17}},{"start":{"line":48,"column":21},"end":{"line":48,"column":33}}]},"4":{"line":54,"type":"if","locations":[{"start":{"line":54,"column":6},"end":{"line":54,"column":6}},{"start":{"line":54,"column":6},"end":{"line":54,"column":6}}]},"5":{"line":69,"type":"binary-expr","locations":[{"start":{"line":69,"column":24},"end":{"line":69,"column":36}},{"start":{"line":69,"column":41},"end":{"line":69,"column":58}}]},"6":{"line":70,"type":"if","locations":[{"start":{"line":70,"column":6},"end":{"line":70,"column":6}},{"start":{"line":70,"column":6},"end":{"line":70,"column":6}}]},"7":{"line":78,"type":"if","locations":[{"start":{"line":78,"column":6},"end":{"line":78,"column":6}},{"start":{"line":78,"column":6},"end":{"line":78,"column":6}}]},"8":{"line":95,"type":"if","locations":[{"start":{"line":95,"column":6},"end":{"line":95,"column":6}},{"start":{"line":95,"column":6},"end":{"line":95,"column":6}}]},"9":{"line":97,"type":"if","locations":[{"start":{"line":97,"column":8},"end":{"line":97,"column":8}},{"start":{"line":97,"column":8},"end":{"line":97,"column":8}}]}}},"/Users/agiammarchi/git/event-target/cjs/poorlyfills.js":{"path":"/Users/agiammarchi/git/event-target/cjs/poorlyfills.js","s":{"1":2,"2":1,"3":1,"4":8,"5":8,"6":5,"7":4,"8":4,"9":1,"10":1,"11":1,"12":1,"13":1,"14":1,"15":12,"16":1,"17":1},"b":{"1":[1,1],"2":[1,1],"3":[4,1],"4":[1,1]},"f":{"1":8,"2":1,"3":12,"4":1},"fnMap":{"1":{"name":"(anonymous_1)","line":5,"loc":{"start":{"line":5,"column":34},"end":{"line":5,"column":63}}},"2":{"name":"WeakMap","line":19,"loc":{"start":{"line":19,"column":29},"end":{"line":19,"column":48}}},"3":{"name":"(anonymous_3)","line":21,"loc":{"start":{"line":21,"column":7},"end":{"line":21,"column":13}}},"4":{"name":"(anonymous_4)","line":22,"loc":{"start":{"line":22,"column":7},"end":{"line":22,"column":20}}}},"statementMap":{"1":{"start":{"line":2,"column":0},"end":{"line":2,"column":56}},"2":{"start":{"line":3,"column":0},"end":{"line":3,"column":14}},"3":{"start":{"line":5,"column":0},"end":{"line":9,"column":2}},"4":{"start":{"line":6,"column":2},"end":{"line":6,"column":22}},"5":{"start":{"line":7,"column":2},"end":{"line":7,"column":60}},"6":{"start":{"line":7,"column":14},"end":{"line":7,"column":60}},"7":{"start":{"line":7,"column":51},"end":{"line":7,"column":60}},"8":{"start":{"line":8,"column":2},"end":{"line":8,"column":11}},"9":{"start":{"line":10,"column":0},"end":{"line":10,"column":30}},"10":{"start":{"line":12,"column":0},"end":{"line":12,"column":45}},"11":{"start":{"line":13,"column":0},"end":{"line":13,"column":40}},"12":{"start":{"line":18,"column":0},"end":{"line":18,"column":47}},"13":{"start":{"line":19,"column":0},"end":{"line":29,"column":2}},"14":{"start":{"line":20,"column":2},"end":{"line":28,"column":4}},"15":{"start":{"line":21,"column":15},"end":{"line":21,"column":31}},"16":{"start":{"line":23,"column":6},"end":{"line":26,"column":9}},"17":{"start":{"line":30,"column":0},"end":{"line":30,"column":26}}},"branchMap":{"1":{"line":2,"type":"cond-expr","locations":[{"start":{"line":2,"column":42},"end":{"line":2,"column":48}},{"start":{"line":2,"column":51},"end":{"line":2,"column":55}}]},"2":{"line":5,"type":"binary-expr","locations":[{"start":{"line":5,"column":18},"end":{"line":5,"column":30}},{"start":{"line":5,"column":34},"end":{"line":9,"column":1}}]},"3":{"line":7,"type":"if","locations":[{"start":{"line":7,"column":14},"end":{"line":7,"column":14}},{"start":{"line":7,"column":14},"end":{"line":7,"column":14}}]},"4":{"line":19,"type":"binary-expr","locations":[{"start":{"line":19,"column":16},"end":{"line":19,"column":25}},{"start":{"line":19,"column":29},"end":{"line":29,"column":1}}]}}}} -------------------------------------------------------------------------------- /coverage/lcov-report/cjs/index.js.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Code coverage report for cjs/index.js 5 | 6 | 7 | 8 | 9 | 14 | 15 | 16 |
17 |
18 |

19 | all files / cjs/ index.js 20 |

21 |
22 |
23 | 100% 24 | Statements 25 | 51/51 26 |
27 |
28 | 100% 29 | Branches 30 | 18/18 31 |
32 |
33 | 100% 34 | Functions 35 | 7/7 36 |
37 |
38 | 100% 39 | Lines 40 | 49/49 41 |
42 |
43 |
44 |
45 |

 46 | 
377 | 
1 47 | 2 48 | 3 49 | 4 50 | 5 51 | 6 52 | 7 53 | 8 54 | 9 55 | 10 56 | 11 57 | 12 58 | 13 59 | 14 60 | 15 61 | 16 62 | 17 63 | 18 64 | 19 65 | 20 66 | 21 67 | 22 68 | 23 69 | 24 70 | 25 71 | 26 72 | 27 73 | 28 74 | 29 75 | 30 76 | 31 77 | 32 78 | 33 79 | 34 80 | 35 81 | 36 82 | 37 83 | 38 84 | 39 85 | 40 86 | 41 87 | 42 88 | 43 89 | 44 90 | 45 91 | 46 92 | 47 93 | 48 94 | 49 95 | 50 96 | 51 97 | 52 98 | 53 99 | 54 100 | 55 101 | 56 102 | 57 103 | 58 104 | 59 105 | 60 106 | 61 107 | 62 108 | 63 109 | 64 110 | 65 111 | 66 112 | 67 113 | 68 114 | 69 115 | 70 116 | 71 117 | 72 118 | 73 119 | 74 120 | 75 121 | 76 122 | 77 123 | 78 124 | 79 125 | 80 126 | 81 127 | 82 128 | 83 129 | 84 130 | 85 131 | 86 132 | 87 133 | 88 134 | 89 135 | 90 136 | 91 137 | 92 138 | 93 139 | 94 140 | 95 141 | 96 142 | 97 143 | 98 144 | 99 145 | 100 146 | 101 147 | 102 148 | 103 149 | 104 150 | 105 151 | 106 152 | 107 153 | 108 154 | 109 155 | 110 156 | 111  157 | 158 |   159 | 160 |   161 | 162 | 163 |   164 | 165 |   166 |   167 | 168 |   169 |   170 | 12× 171 | 172 | 173 | 174 | 175 |   176 |   177 |   178 | 179 | 180 | 181 |   182 |   183 |   184 |   185 |   186 |   187 |   188 | 189 |   190 |   191 | 192 |   193 |   194 |   195 |   196 |   197 |   198 |   199 |   200 |   201 | 202 | 203 | 204 | 205 |   206 |   207 |   208 |   209 | 210 | 211 |   212 | 213 |   214 |   215 |   216 |   217 | 218 | 219 |   220 |   221 |   222 | 223 | 224 | 225 | 226 | 227 |   228 |   229 |   230 | 231 | 232 | 233 | 234 | 235 |   236 |   237 |   238 | 239 | 240 | 241 |   242 | 243 |   244 |   245 |   246 |   247 | 248 | 249 | 250 | 251 | 252 | 253 |   254 |   255 |   256 |   257 | 258 | 259 |   260 | 261 |   262 |   263 |   264 |   265 | 266 |  
'use strict';
267 | const {defineProperty, findIndex, G, WeakMap} = require('./poorlyfills.js');
268 |  
269 | let EventTarget = G.EventTarget;
270 |  
271 | try {
272 |   new EventTarget;
273 | } catch(e) {
274 |   EventTarget = (() => {
275 |  
276 |     // used to relate instances to listeners
277 |     const wm = new WeakMap;
278 |  
279 |     // get listeners or relate them once to the instance
280 |     const get = self => wm.get(self) || set(self);
281 |     const set = self => {
282 |       const dictionary = new Null;
283 |       wm.set(self, dictionary);
284 |       return dictionary;
285 |     };
286 |  
287 |     // define values as configurable
288 |     const define = (where, what) => {
289 |       for (const key in what) {
290 |         defineProperty(where, key, {
291 |           configurable: true,
292 |           value: what[key]
293 |         });
294 |       }
295 |     };
296 |  
297 |     // no need to transpile here, it's a very simple class
298 |     function EventTarget() {}
299 |  
300 |     // EventTarget "class" definition
301 |     define(
302 |       EventTarget.prototype,
303 |       {
304 |         addEventListener,
305 |         dispatchEvent,
306 |         removeEventListener
307 |       }
308 |     );
309 |  
310 |     // dispatch event for each listener
311 |     function dispatch(info) {
312 |       const options = info.options;
313 |       if (options && options.once) {
314 |         removeEventListener.call(
315 |           info.target,
316 |           this.type, info.listener, info.options
317 |         );
318 |       }
319 |       if (typeof info.listener === 'function') {
320 |         info.listener.call(info.target, this);
321 |       } else {
322 |         info.listener.handleEvent(this);
323 |       }
324 |     }
325 |  
326 |     // search for a registered listener
327 |     function registered(info) {
328 |       return this === info.listener;
329 |     }
330 |  
331 |     // public methods
332 |     function addEventListener(type, listener, options) {
333 |       const secret = get(this);
334 |       const listeners = secret[type] || (secret[type] = []);
335 |       if (findIndex.call(listeners, registered, listener) < 0) {
336 |         listeners.push({target: this, listener, options});
337 |       }
338 |     }
339 |  
340 |     function dispatchEvent(event) {
341 |       const secret = get(this);
342 |       const listeners = secret[event.type];
343 |       if (listeners) {
344 |         define(event, {
345 |           currentTarget: this,
346 |           target: this
347 |         });
348 |         listeners.forEach(dispatch, event);
349 |         delete event.currentTarget;
350 |         delete event.target;
351 |       }
352 |       return true;
353 |     }
354 |  
355 |     // used both as public and private method,
356 |     // to avoid method pollution/interception of private listeners
357 |     function removeEventListener(type, listener, options) {
358 |       const secret = get(this);
359 |       const listeners = secret[type];
360 |       if (listeners) {
361 |         const i = findIndex.call(listeners, registered, listener);
362 |         if (-1 < i) listeners.splice(i, 1);
363 |       }
364 |     }
365 |  
366 |     // private "class"
367 |     function Null() {}
368 |     Null.prototype = Object.create(null);
369 |  
370 |     return EventTarget;
371 |  
372 |   })();
373 | }
374 |  
375 | Object.defineProperty(exports, '__esModule', {value: true}).default = EventTarget;
376 |  
378 |
379 |
380 | 384 | 385 | 386 | 393 | 394 | 395 | 396 | -------------------------------------------------------------------------------- /coverage/lcov-report/prettify.js: -------------------------------------------------------------------------------- 1 | window.PR_SHOULD_USE_CONTINUATION=true;(function(){var h=["break,continue,do,else,for,if,return,while"];var u=[h,"auto,case,char,const,default,double,enum,extern,float,goto,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"];var p=[u,"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"];var l=[p,"alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,dynamic_cast,explicit,export,friend,inline,late_check,mutable,namespace,nullptr,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"];var x=[p,"abstract,boolean,byte,extends,final,finally,implements,import,instanceof,null,native,package,strictfp,super,synchronized,throws,transient"];var R=[x,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,interface,internal,into,is,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var"];var r="all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,true,try,unless,until,when,while,yes";var w=[p,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"];var s="caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END";var I=[h,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"];var f=[h,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"];var H=[h,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"];var A=[l,R,w,s+I,f,H];var e=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)/;var C="str";var z="kwd";var j="com";var O="typ";var G="lit";var L="pun";var F="pln";var m="tag";var E="dec";var J="src";var P="atn";var n="atv";var N="nocode";var M="(?:^^\\.?|[+-]|\\!|\\!=|\\!==|\\#|\\%|\\%=|&|&&|&&=|&=|\\(|\\*|\\*=|\\+=|\\,|\\-=|\\->|\\/|\\/=|:|::|\\;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|\\?|\\@|\\[|\\^|\\^=|\\^\\^|\\^\\^=|\\{|\\||\\|=|\\|\\||\\|\\|=|\\~|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*";function k(Z){var ad=0;var S=false;var ac=false;for(var V=0,U=Z.length;V122)){if(!(al<65||ag>90)){af.push([Math.max(65,ag)|32,Math.min(al,90)|32])}if(!(al<97||ag>122)){af.push([Math.max(97,ag)&~32,Math.min(al,122)&~32])}}}}af.sort(function(av,au){return(av[0]-au[0])||(au[1]-av[1])});var ai=[];var ap=[NaN,NaN];for(var ar=0;arat[0]){if(at[1]+1>at[0]){an.push("-")}an.push(T(at[1]))}}an.push("]");return an.join("")}function W(al){var aj=al.source.match(new RegExp("(?:\\[(?:[^\\x5C\\x5D]|\\\\[\\s\\S])*\\]|\\\\u[A-Fa-f0-9]{4}|\\\\x[A-Fa-f0-9]{2}|\\\\[0-9]+|\\\\[^ux0-9]|\\(\\?[:!=]|[\\(\\)\\^]|[^\\x5B\\x5C\\(\\)\\^]+)","g"));var ah=aj.length;var an=[];for(var ak=0,am=0;ak=2&&ai==="["){aj[ak]=X(ag)}else{if(ai!=="\\"){aj[ak]=ag.replace(/[a-zA-Z]/g,function(ao){var ap=ao.charCodeAt(0);return"["+String.fromCharCode(ap&~32,ap|32)+"]"})}}}}return aj.join("")}var aa=[];for(var V=0,U=Z.length;V=0;){S[ac.charAt(ae)]=Y}}var af=Y[1];var aa=""+af;if(!ag.hasOwnProperty(aa)){ah.push(af);ag[aa]=null}}ah.push(/[\0-\uffff]/);V=k(ah)})();var X=T.length;var W=function(ah){var Z=ah.sourceCode,Y=ah.basePos;var ad=[Y,F];var af=0;var an=Z.match(V)||[];var aj={};for(var ae=0,aq=an.length;ae=5&&"lang-"===ap.substring(0,5);if(am&&!(ai&&typeof ai[1]==="string")){am=false;ap=J}if(!am){aj[ag]=ap}}var ab=af;af+=ag.length;if(!am){ad.push(Y+ab,ap)}else{var al=ai[1];var ak=ag.indexOf(al);var ac=ak+al.length;if(ai[2]){ac=ag.length-ai[2].length;ak=ac-al.length}var ar=ap.substring(5);B(Y+ab,ag.substring(0,ak),W,ad);B(Y+ab+ak,al,q(ar,al),ad);B(Y+ab+ac,ag.substring(ac),W,ad)}}ah.decorations=ad};return W}function i(T){var W=[],S=[];if(T.tripleQuotedStrings){W.push([C,/^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/,null,"'\""])}else{if(T.multiLineStrings){W.push([C,/^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/,null,"'\"`"])}else{W.push([C,/^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,null,"\"'"])}}if(T.verbatimStrings){S.push([C,/^@\"(?:[^\"]|\"\")*(?:\"|$)/,null])}var Y=T.hashComments;if(Y){if(T.cStyleComments){if(Y>1){W.push([j,/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,null,"#"])}else{W.push([j,/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\r\n]*)/,null,"#"])}S.push([C,/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,null])}else{W.push([j,/^#[^\r\n]*/,null,"#"])}}if(T.cStyleComments){S.push([j,/^\/\/[^\r\n]*/,null]);S.push([j,/^\/\*[\s\S]*?(?:\*\/|$)/,null])}if(T.regexLiterals){var X=("/(?=[^/*])(?:[^/\\x5B\\x5C]|\\x5C[\\s\\S]|\\x5B(?:[^\\x5C\\x5D]|\\x5C[\\s\\S])*(?:\\x5D|$))+/");S.push(["lang-regex",new RegExp("^"+M+"("+X+")")])}var V=T.types;if(V){S.push([O,V])}var U=(""+T.keywords).replace(/^ | $/g,"");if(U.length){S.push([z,new RegExp("^(?:"+U.replace(/[\s,]+/g,"|")+")\\b"),null])}W.push([F,/^\s+/,null," \r\n\t\xA0"]);S.push([G,/^@[a-z_$][a-z_$@0-9]*/i,null],[O,/^(?:[@_]?[A-Z]+[a-z][A-Za-z_$@0-9]*|\w+_t\b)/,null],[F,/^[a-z_$][a-z_$@0-9]*/i,null],[G,new RegExp("^(?:0x[a-f0-9]+|(?:\\d(?:_\\d+)*\\d*(?:\\.\\d*)?|\\.\\d\\+)(?:e[+\\-]?\\d+)?)[a-z]*","i"),null,"0123456789"],[F,/^\\[\s\S]?/,null],[L,/^.[^\s\w\.$@\'\"\`\/\#\\]*/,null]);return g(W,S)}var K=i({keywords:A,hashComments:true,cStyleComments:true,multiLineStrings:true,regexLiterals:true});function Q(V,ag){var U=/(?:^|\s)nocode(?:\s|$)/;var ab=/\r\n?|\n/;var ac=V.ownerDocument;var S;if(V.currentStyle){S=V.currentStyle.whiteSpace}else{if(window.getComputedStyle){S=ac.defaultView.getComputedStyle(V,null).getPropertyValue("white-space")}}var Z=S&&"pre"===S.substring(0,3);var af=ac.createElement("LI");while(V.firstChild){af.appendChild(V.firstChild)}var W=[af];function ae(al){switch(al.nodeType){case 1:if(U.test(al.className)){break}if("BR"===al.nodeName){ad(al);if(al.parentNode){al.parentNode.removeChild(al)}}else{for(var an=al.firstChild;an;an=an.nextSibling){ae(an)}}break;case 3:case 4:if(Z){var am=al.nodeValue;var aj=am.match(ab);if(aj){var ai=am.substring(0,aj.index);al.nodeValue=ai;var ah=am.substring(aj.index+aj[0].length);if(ah){var ak=al.parentNode;ak.insertBefore(ac.createTextNode(ah),al.nextSibling)}ad(al);if(!ai){al.parentNode.removeChild(al)}}}break}}function ad(ak){while(!ak.nextSibling){ak=ak.parentNode;if(!ak){return}}function ai(al,ar){var aq=ar?al.cloneNode(false):al;var ao=al.parentNode;if(ao){var ap=ai(ao,1);var an=al.nextSibling;ap.appendChild(aq);for(var am=an;am;am=an){an=am.nextSibling;ap.appendChild(am)}}return aq}var ah=ai(ak.nextSibling,0);for(var aj;(aj=ah.parentNode)&&aj.nodeType===1;){ah=aj}W.push(ah)}for(var Y=0;Y=S){ah+=2}if(V>=ap){Z+=2}}}var t={};function c(U,V){for(var S=V.length;--S>=0;){var T=V[S];if(!t.hasOwnProperty(T)){t[T]=U}else{if(window.console){console.warn("cannot override language handler %s",T)}}}}function q(T,S){if(!(T&&t.hasOwnProperty(T))){T=/^\s*]*(?:>|$)/],[j,/^<\!--[\s\S]*?(?:-\->|$)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],[L,/^(?:<[%?]|[%?]>)/],["lang-",/^]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-js",/^]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]),["default-markup","htm","html","mxml","xhtml","xml","xsl"]);c(g([[F,/^[\s]+/,null," \t\r\n"],[n,/^(?:\"[^\"]*\"?|\'[^\']*\'?)/,null,"\"'"]],[[m,/^^<\/?[a-z](?:[\w.:-]*\w)?|\/?>$/i],[P,/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^>\'\"\s]*(?:[^>\'\"\s\/]|\/(?=\s)))/],[L,/^[=<>\/]+/],["lang-js",/^on\w+\s*=\s*\"([^\"]+)\"/i],["lang-js",/^on\w+\s*=\s*\'([^\']+)\'/i],["lang-js",/^on\w+\s*=\s*([^\"\'>\s]+)/i],["lang-css",/^style\s*=\s*\"([^\"]+)\"/i],["lang-css",/^style\s*=\s*\'([^\']+)\'/i],["lang-css",/^style\s*=\s*([^\"\'>\s]+)/i]]),["in.tag"]);c(g([],[[n,/^[\s\S]+/]]),["uq.val"]);c(i({keywords:l,hashComments:true,cStyleComments:true,types:e}),["c","cc","cpp","cxx","cyc","m"]);c(i({keywords:"null,true,false"}),["json"]);c(i({keywords:R,hashComments:true,cStyleComments:true,verbatimStrings:true,types:e}),["cs"]);c(i({keywords:x,cStyleComments:true}),["java"]);c(i({keywords:H,hashComments:true,multiLineStrings:true}),["bsh","csh","sh"]);c(i({keywords:I,hashComments:true,multiLineStrings:true,tripleQuotedStrings:true}),["cv","py"]);c(i({keywords:s,hashComments:true,multiLineStrings:true,regexLiterals:true}),["perl","pl","pm"]);c(i({keywords:f,hashComments:true,multiLineStrings:true,regexLiterals:true}),["rb"]);c(i({keywords:w,cStyleComments:true,regexLiterals:true}),["js"]);c(i({keywords:r,hashComments:3,cStyleComments:true,multilineStrings:true,tripleQuotedStrings:true,regexLiterals:true}),["coffee"]);c(g([],[[C,/^[\s\S]+/]]),["regex"]);function d(V){var U=V.langExtension;try{var S=a(V.sourceNode);var T=S.sourceCode;V.sourceCode=T;V.spans=S.spans;V.basePos=0;q(U,T)(V);D(V)}catch(W){if("console" in window){console.log(W&&W.stack?W.stack:W)}}}function y(W,V,U){var S=document.createElement("PRE");S.innerHTML=W;if(U){Q(S,U)}var T={langExtension:V,numberLines:U,sourceNode:S};d(T);return S.innerHTML}function b(ad){function Y(af){return document.getElementsByTagName(af)}var ac=[Y("pre"),Y("code"),Y("xmp")];var T=[];for(var aa=0;aa=0){var ah=ai.match(ab);var am;if(!ah&&(am=o(aj))&&"CODE"===am.tagName){ah=am.className.match(ab)}if(ah){ah=ah[1]}var al=false;for(var ak=aj.parentNode;ak;ak=ak.parentNode){if((ak.tagName==="pre"||ak.tagName==="code"||ak.tagName==="xmp")&&ak.className&&ak.className.indexOf("prettyprint")>=0){al=true;break}}if(!al){var af=aj.className.match(/\blinenums\b(?::(\d+))?/);af=af?af[1]&&af[1].length?+af[1]:true:false;if(af){Q(aj,af)}S={langExtension:ah,sourceNode:aj,numberLines:af};d(S)}}}if(X]*(?:>|$)/],[PR.PR_COMMENT,/^<\!--[\s\S]*?(?:-\->|$)/],[PR.PR_PUNCTUATION,/^(?:<[%?]|[%?]>)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],["lang-",/^]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-handlebars",/^]*type\s*=\s*['"]?text\/x-handlebars-template['"]?\b[^>]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-js",/^]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i],[PR.PR_DECLARATION,/^{{[#^>/]?\s*[\w.][^}]*}}/],[PR.PR_DECLARATION,/^{{&?\s*[\w.][^}]*}}/],[PR.PR_DECLARATION,/^{{{>?\s*[\w.][^}]*}}}/],[PR.PR_COMMENT,/^{{![^}]*}}/]]),["handlebars","hbs"]);PR.registerLangHandler(PR.createSimpleLexer([[PR.PR_PLAIN,/^[ \t\r\n\f]+/,null," \t\r\n\f"]],[[PR.PR_STRING,/^\"(?:[^\n\r\f\\\"]|\\(?:\r\n?|\n|\f)|\\[\s\S])*\"/,null],[PR.PR_STRING,/^\'(?:[^\n\r\f\\\']|\\(?:\r\n?|\n|\f)|\\[\s\S])*\'/,null],["lang-css-str",/^url\(([^\)\"\']*)\)/i],[PR.PR_KEYWORD,/^(?:url|rgb|\!important|@import|@page|@media|@charset|inherit)(?=[^\-\w]|$)/i,null],["lang-css-kw",/^(-?(?:[_a-z]|(?:\\[0-9a-f]+ ?))(?:[_a-z0-9\-]|\\(?:\\[0-9a-f]+ ?))*)\s*:/i],[PR.PR_COMMENT,/^\/\*[^*]*\*+(?:[^\/*][^*]*\*+)*\//],[PR.PR_COMMENT,/^(?:)/],[PR.PR_LITERAL,/^(?:\d+|\d*\.\d+)(?:%|[a-z]+)?/i],[PR.PR_LITERAL,/^#(?:[0-9a-f]{3}){1,2}/i],[PR.PR_PLAIN,/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i],[PR.PR_PUNCTUATION,/^[^\s\w\'\"]+/]]),["css"]);PR.registerLangHandler(PR.createSimpleLexer([],[[PR.PR_KEYWORD,/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i]]),["css-kw"]);PR.registerLangHandler(PR.createSimpleLexer([],[[PR.PR_STRING,/^[^\)\"\']+/]]),["css-str"]); 2 | --------------------------------------------------------------------------------