2020-08-20 02:05:34 +02:00
|
|
|
"use strict";
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
|
exports.fetchImage = void 0;
|
|
|
|
const bufferToImage_1 = require("./bufferToImage");
|
|
|
|
const fetchOrThrow_1 = require("./fetchOrThrow");
|
|
|
|
async function fetchImage(uri) {
|
|
|
|
const res = await fetchOrThrow_1.fetchOrThrow(uri);
|
2020-08-18 14:04:33 +02:00
|
|
|
const blob = await (res).blob();
|
|
|
|
if (!blob.type.startsWith('image/')) {
|
|
|
|
throw new Error(`fetchImage - expected blob type to be of type image/*, instead have: ${blob.type}, for url: ${res.url}`);
|
|
|
|
}
|
2020-08-20 02:05:34 +02:00
|
|
|
return bufferToImage_1.bufferToImage(blob);
|
2020-08-18 14:04:33 +02:00
|
|
|
}
|
2020-08-20 02:05:34 +02:00
|
|
|
exports.fetchImage = fetchImage;
|
2020-08-18 14:04:33 +02:00
|
|
|
//# sourceMappingURL=fetchImage.js.map
|