UNPKG

node-djiparsetxt

Version:

command-line application that reads a DJI '.txt' file and outputs a json.

44 lines 2.04 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); exports.Records2CsvCommand = void 0; var ServiceManager_1 = require("../common/ServiceManager"); var Command_1 = require("./Command"); /** * Prints a csv representation of a IRecordCache object. */ var Records2CsvCommand = /** @class */ (function (_super) { __extends(Records2CsvCommand, _super); function Records2CsvCommand() { return _super !== null && _super.apply(this, arguments) || this; } Records2CsvCommand.prototype.exec = function (options) { var serviceMan = this.serviceMan; var cacheTransService = serviceMan.get_service(ServiceManager_1.ServiceTypes.CacheTransform); var csvService = serviceMan.get_service(ServiceManager_1.ServiceTypes.CsvService); var recordsCache = options.records; cacheTransService.unscramble(recordsCache); var unscrambledRows = cacheTransService.cache_as_rows(recordsCache); var parsedRows = cacheTransService.rows_to_json(unscrambledRows); // print json object to csv representation var headerDef = csvService.getRowHeaders(parsedRows); this.log(csvService.createHeader(headerDef)); this.log(csvService.printRowValues(parsedRows, headerDef)); return this.getLog(); }; return Records2CsvCommand; }(Command_1.Command)); exports.Records2CsvCommand = Records2CsvCommand; //# sourceMappingURL=Records2CsvCommand.js.map