capacitor-plugin-scanbot-sdk
Version:
Scanbot Document and Barcode Scanner SDK for Capacitor
42 lines • 981 B
JavaScript
import { ImageRef } from '../core';
import { createSBError } from './errors';
/**
* @internal
* @hidden
*/
export function mapRTUUIResult(result, LClass) {
if (result.status === 'OK') {
return Object.assign(Object.assign({}, result), { data: new LClass(result.data) });
}
else {
return result;
}
}
export function handleImageInput(image) {
const handleInput = (input) => {
if (input instanceof ImageRef) {
return input.uniqueId
? { uniqueId: input.uniqueId }
: { buffer: input.buffer };
}
else {
return { imageFileUri: input };
}
};
return Array.isArray(image)
? image.map(handleInput)
: handleInput(image);
}
/**
* @internal
* @hidden
*/
export async function withSBErrorHandling(fn) {
try {
return await fn();
}
catch (error) {
throw createSBError(error);
}
}
//# sourceMappingURL=utils.js.map