1 | {"version":3,"file":"debug.js","names":["_events","require","util","_interopRequireWildcard","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","Debug","EventEmitter","constructor","data","payload","packet","token","options","indent","direction","haveListeners","log","headerToString","dataToString","generatePayloadText","inspect","showHidden","depth","colors","listeners","length","text","emit","_default","exports","module"],"sources":["../src/debug.ts"],"sourcesContent":["import { EventEmitter } from 'events';\nimport * as util from 'util';\nimport { Packet } from './packet';\n\nclass Debug extends EventEmitter {\n declare options: {\n data: boolean;\n payload: boolean;\n packet: boolean;\n token: boolean;\n };\n\n declare indent: string;\n\n /*\n @options Which debug details should be sent.\n data - dump of packet data\n payload - details of decoded payload\n */\n constructor({ data = false, payload = false, packet = false, token = false } = {}) {\n super();\n\n this.options = { data, payload, packet, token };\n this.indent = ' ';\n }\n\n packet(direction: 'Received' | 'Sent', packet: Packet) {\n if (this.haveListeners() && this.options.packet) {\n this.log('');\n this.log(direction);\n this.log(packet.headerToString(this.indent));\n }\n }\n\n data(packet: Packet) {\n if (this.haveListeners() && this.options.data) {\n this.log(packet.dataToString(this.indent));\n }\n }\n\n payload(generatePayloadText: () => string) {\n if (this.haveListeners() && this.options.payload) {\n this.log(generatePayloadText());\n }\n }\n\n token(token: any) {\n if (this.haveListeners() && this.options.token) {\n this.log(util.inspect(token, { showHidden: false, depth: 5, colors: true }));\n }\n }\n\n haveListeners() {\n return this.listeners('debug').length > 0;\n }\n\n log(text: string) {\n this.emit('debug', text);\n }\n}\n\nexport default Debug;\nmodule.exports = Debug;\n"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,IAAA,GAAAC,uBAAA,CAAAF,OAAA;AAA6B,SAAAG,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CA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