UNPKG

node-djiparsetxt

Version:

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

50 lines 2.16 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.JpegExtractCommand = void 0; var fs_1 = __importDefault(require("fs")); var RecordTypes_1 = require("../services/RecordTypes"); var Command_1 = require("./Command"); var JpegExtractCommand = /** @class */ (function (_super) { __extends(JpegExtractCommand, _super); function JpegExtractCommand() { return _super !== null && _super.apply(this, arguments) || this; } JpegExtractCommand.prototype.exec = function (options) { var recordsCache = options.records; for (var _i = 0, _a = recordsCache.records; _i < _a.length; _i++) { var record = _a[_i]; if (record.type === RecordTypes_1.RecordTypes.JPEG) { var index = 0; for (var _b = 0, _c = record.data; _b < _c.length; _b++) { var buf = _c[_b]; // ignore zero length jpeg records if (buf.length === 0) continue; var path = "jpeg_" + index + ".jpeg"; fs_1.default.writeFileSync(path, buf); console.log("Wrote " + path + " to disk"); index += 1; } } } }; return JpegExtractCommand; }(Command_1.Command)); exports.JpegExtractCommand = JpegExtractCommand; //# sourceMappingURL=JpegExtractCommand.js.map