UNPKG

ffc-pay-etl-framework

Version:

A framework for creating ETL pipelines in node

38 lines (37 loc) 1.11 kB
const { Writable } = require("node:stream"); /** * * @param {Object} options * @param {String} options.includeErrors * @returns Writable */ function ConsoleDestination(options) { const includeErrors = options.includeErrors; const writable = new Writable({ objectMode: true, write(chunk, _, callback) { var _a; if (chunk.errors.length === 0 || includeErrors) console.log(chunk); // @ts-ignore (_a = this.tasks) === null || _a === void 0 ? void 0 : _a.forEach(task => task.write(chunk)); callback(); } }); Object.assign(writable, { setConnection: function (connection) { this.connection = connection; }.bind(writable), getConnectionName: function () { var _a; return (_a = this.connection) === null || _a === void 0 ? void 0 : _a.name; }.bind(writable), setTasks: function (tasks) { this.tasks = tasks; }.bind(writable) }); return writable; } module.exports = { ConsoleDestination };