@pujansrt/data-genie
Version:
High performant ETL engine written in TypeScript
31 lines (30 loc) • 934 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.TransformingReader = void 0;
const transformers_1 = require("./transformers");
class TransformingReader extends transformers_1.DataTransformer {
constructor(reader) {
super(reader);
this.transformations = [];
this.condition = () => true; // Default to always true
}
add(transformation) {
this.transformations.push(transformation);
return this;
}
setCondition(condition) {
this.condition = condition;
return this;
}
async *read() {
for await (let record of this.reader.read()) {
if (this.condition(record)) {
for (const transform of this.transformations) {
record = transform(record);
}
}
yield record;
}
}
}
exports.TransformingReader = TransformingReader;