tweak-tools
Version:
Tweak your React projects until awesomeness
26 lines (25 loc) • 746 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.normalize = exports.schema = exports.sanitize = void 0;
const sanitize = (v) => {
if (v === undefined)
return undefined;
if (v instanceof File) {
try {
return URL.createObjectURL(v);
}
catch (e) {
return undefined;
}
}
if (typeof v === 'string' && v.indexOf('blob:') === 0)
return v;
throw Error(`Invalid image format [undefined | blob | File].`);
};
exports.sanitize = sanitize;
const schema = (_o, s) => typeof s === 'object' && 'image' in s;
exports.schema = schema;
const normalize = ({ image }) => {
return { value: image };
};
exports.normalize = normalize;