.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / htmlparser2 / lib / ProxyHandler.js
1 module.exports = ProxyHandler;
2
3 function ProxyHandler(cbs) {
4     this._cbs = cbs || {};
5 }
6
7 var EVENTS = require("./").EVENTS;
8 Object.keys(EVENTS).forEach(function(name) {
9     if (EVENTS[name] === 0) {
10         name = "on" + name;
11         ProxyHandler.prototype[name] = function() {
12             if (this._cbs[name]) this._cbs[name]();
13         };
14     } else if (EVENTS[name] === 1) {
15         name = "on" + name;
16         ProxyHandler.prototype[name] = function(a) {
17             if (this._cbs[name]) this._cbs[name](a);
18         };
19     } else if (EVENTS[name] === 2) {
20         name = "on" + name;
21         ProxyHandler.prototype[name] = function(a, b) {
22             if (this._cbs[name]) this._cbs[name](a, b);
23         };
24     } else {
25         throw Error("wrong number of arguments");
26     }
27 });