UNPKG

dbmaster-cli

Version:

Tool for converting tables between Fifa Soccer Games

27 lines (26 loc) 827 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ReindexTransform = void 0; const stream_1 = require("stream"); class ReindexTransform extends stream_1.Transform { constructor(opts) { super(opts); this.currentPos = 0; this.opts = opts; this.initStartingPosition(); } _transform(chunk, encoding, callback) { const object = JSON.parse(chunk.toString()); this.push(JSON.stringify({ key: this.currentPos, value: object })); this.currentPos++; callback(); } _flush(callback) { this.initStartingPosition(); callback(); } initStartingPosition() { this.currentPos = this.opts && this.opts.startingPos ? this.opts.startingPos : 0; } } exports.ReindexTransform = ReindexTransform;