UNPKG

dbmaster-cli

Version:

Tool for converting tables between Fifa Soccer Games

27 lines (26 loc) 862 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ApplyPlayernamesTransform = void 0; const stream_1 = require("stream"); // only works with the table players class ApplyPlayernamesTransform extends stream_1.Transform { constructor(opts) { super(opts); this.opts = opts; } _transform(chunk, encoding, callback) { let object = JSON.parse(chunk.toString()); for (const col of this.opts.foreignKeyColumns) { object = { ...object, [col]: this.opts.reindexMap.find((i) => i.value[this.opts.foreingKeyPrimaryColumn] === object[col]).key }; } this.push(JSON.stringify(object)); callback(); } _flush(callback) { callback(); } } exports.ApplyPlayernamesTransform = ApplyPlayernamesTransform;