UNPKG

mindee

Version:

Mindee Client Library for Node.js

28 lines (27 loc) 926 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.BytesInput = void 0; const inputSource_1 = require("./inputSource"); const localInputSource_1 = require("./localInputSource"); const logger_1 = require("../../logger"); class BytesInput extends localInputSource_1.LocalInputSource { constructor({ inputBytes, filename }) { super({ inputType: inputSource_1.INPUT_TYPE_BYTES, }); this.fileObject = Buffer.alloc(0); this.filename = filename; this.inputBytes = inputBytes; } async init() { if (this.initialized) { return; } logger_1.logger.debug("Loading from bytes"); this.fileObject = Buffer.from(this.inputBytes); this.mimeType = await this.checkMimetype(); this.inputBytes = new Uint8Array(0); this.initialized = true; } } exports.BytesInput = BytesInput;