node-djiparsetxt
Version:
command-line application that reads a DJI '.txt' file and outputs a json.
49 lines • 2.27 kB
JavaScript
;
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.ShowTypeCommand = void 0;
var ServiceManager_1 = require("../common/ServiceManager");
var RecordTypes_1 = require("../services/RecordTypes");
var Command_1 = require("./Command");
var ShowTypeCommand = /** @class */ (function (_super) {
__extends(ShowTypeCommand, _super);
function ShowTypeCommand() {
return _super !== null && _super.apply(this, arguments) || this;
}
ShowTypeCommand.prototype.exec = function (options) {
var _this = this;
var serviceMan = this.serviceMan;
var fileParsingService = serviceMan.get_service(ServiceManager_1.ServiceTypes.FileParsing);
var scrambleTableService = serviceMan.get_service(ServiceManager_1.ServiceTypes.ScrambleTable);
var records = options.records;
var type = options.type;
var recordsOfType = fileParsingService.filter_records(records, type);
var file = options.file;
var typeName = RecordTypes_1.RecordTypes[type];
if (typeName) {
this.log("file '" + file + "' and type = " + typeName + ":");
recordsOfType.forEach(function (record) {
var unscrambledRec = scrambleTableService.unscramble_record(record);
var subParsed = fileParsingService.parse_record_by_type(unscrambledRec, type);
_this.log(subParsed);
});
return this.getLog();
}
throw new Error("type '" + type + "' not recognized");
};
return ShowTypeCommand;
}(Command_1.Command));
exports.ShowTypeCommand = ShowTypeCommand;
//# sourceMappingURL=ShowTypeCommand.js.map