* @param {!Object} classType
(classType)
| 165 | * @param {!Object} classType |
| 166 | */ |
| 167 | static tracePublicAPI(classType) { |
| 168 | const className = classType.prototype.constructor.name.toLowerCase(); |
| 169 | const debugClass = debug(`hccrawler:${className}`); |
| 170 | Reflect.ownKeys(classType.prototype).forEach(methodName => { |
| 171 | if (methodName === 'constructor' || !isString(methodName) || startsWith(methodName, '_')) return; |
| 172 | const method = Reflect.get(classType.prototype, methodName); |
| 173 | if (!isFunction(method)) return; |
| 174 | Reflect.set(classType.prototype, methodName, function (...args) { |
| 175 | const argsText = args.map(Helper.stringifyArgument).join(', '); |
| 176 | debugClass(`${methodName}(${argsText})`); |
| 177 | return method.call(this, ...args); |
| 178 | }); |
| 179 | }); |
| 180 | if (classType.Events) { |
| 181 | const method = Reflect.get(classType.prototype, 'emit'); |
| 182 | Reflect.set(classType.prototype, 'emit', function (event, ...args) { |
| 183 | const argsText = [JSON.stringify(event)].concat(args.map(Helper.stringifyArgument)).join(', '); |
| 184 | debugClass(`emit(${argsText})`); |
| 185 | return method.call(this, event, ...args); |
| 186 | }); |
| 187 | } |
| 188 | } |
| 189 | |
| 190 | /** |
| 191 | * @param {!Object} arg |