UNPKG

covid-green-dcc-file-decoder

Version:

<img alttext="COVID Green Logo" src="https://raw.githubusercontent.com/lfph/artwork/master/projects/covidgreen/stacked/color/covidgreen-stacked-color.png" width="300" />

37 lines (36 loc) 1.74 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.extractQRCodes = void 0; const decode_1 = require("./decode"); var scaleOptions; (function (scaleOptions) { scaleOptions[scaleOptions["standard"] = 2] = "standard"; scaleOptions[scaleOptions["fallback"] = 1.4] = "fallback"; })(scaleOptions || (scaleOptions = {})); const findQRData = (source) => __awaiter(void 0, void 0, void 0, function* () { let qrSources = []; if (source.image) { qrSources = yield decode_1.extractQRFromImage(source.image); } else if (source.pdf) { qrSources = yield decode_1.extractQRFromPDF(source.pdf, scaleOptions.standard); if (qrSources.length === 0) { qrSources = yield decode_1.extractQRFromPDF(source.pdf, scaleOptions.fallback); } } return qrSources; }); const extractQRCodes = (inputs) => __awaiter(void 0, void 0, void 0, function* () { const qrSources = yield findQRData(inputs.source); return qrSources; }); exports.extractQRCodes = extractQRCodes;