UNPKG

rx-debugger

Version:
28 lines 1.27 kB
import { loggerFactory } from './logger/logger-factory'; import { META_OPERATOR_NAME_KEY } from './common/interface'; import { serializerFactory } from './serializer/serializer-factory'; /** * Patches source observable in order to debug pipes. * Please note that no new observable is created, this function returns original instance patched. * If no config object is provided, the result will be written in console using a table. * @param source observable to patch. * @param config optional config object. */ export function rxDebugger(source, config) { const pipe = source.pipe; const serializer = serializerFactory(config === null || config === void 0 ? void 0 : config.serializer); const logger = loggerFactory(config === null || config === void 0 ? void 0 : config.logger, serializer); source.pipe = function (...operators) { const chain = []; chain.push(logger.start()); for (let operator of operators) { chain.push(operator); const name = operator[META_OPERATOR_NAME_KEY]; chain.push(logger.log(name)); } chain.push(logger.end()); return pipe.apply(this, chain); }; return source; } //# sourceMappingURL=rx-debugger.js.map