UNPKG

node-djiparsetxt

Version:

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

74 lines 3.28 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 __()); }; })(); var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.CacheTransformService = void 0; var ServiceManager_1 = require("../common/ServiceManager"); var BaseService_1 = __importDefault(require("./BaseService")); var RecordTypes_1 = require("./RecordTypes"); var CacheTransformService = /** @class */ (function (_super) { __extends(CacheTransformService, _super); function CacheTransformService() { return _super !== null && _super.apply(this, arguments) || this; } CacheTransformService.prototype.unscramble = function (recordsCache) { var scrambleTableService = this.serviceMan.get_service(ServiceManager_1.ServiceTypes.ScrambleTable); recordsCache.records = recordsCache.records.map(function (rec) { return scrambleTableService.unscramble_record(rec); }); }; CacheTransformService.prototype.cache_as_rows = function (recordsCache) { var parserService = this.serviceMan.get_service(ServiceManager_1.ServiceTypes.Parsers); var rows = []; var records = recordsCache.records; var consumed = 0; var row = []; while (consumed < records.length) { var record = records[consumed]; // ignore the records for which we don't know the format if (parserService.parser_record_mapping(record.type) === null) { consumed++; continue; } // we create a row for each OSD record type if (record.type !== RecordTypes_1.RecordTypes.OSD) { row.push(record); consumed++; continue; } if (row.length > 0) { rows.push(row); } row = [record]; consumed++; } return rows; }; CacheTransformService.prototype.rows_to_json = function (rows) { var fileParsingService = this.serviceMan.get_service(ServiceManager_1.ServiceTypes.FileParsing); var row2json = function (row) { var newRow = {}; for (var _i = 0, row_1 = row; _i < row_1.length; _i++) { var record = row_1[_i]; newRow[RecordTypes_1.RecordTypes[record.type]] = fileParsingService.parse_record_by_type(record, record.type); } return newRow; }; return rows.map(row2json); }; return CacheTransformService; }(BaseService_1.default)); exports.CacheTransformService = CacheTransformService; //# sourceMappingURL=CacheTransformService.js.map