one
Version:
One is a React framework for web, iOS, and Android apps.
23 lines (21 loc) • 814 B
JavaScript
function resolveDocumentPickerOptions(options = {}) {
const { type = "*/*", multiple = false } = options;
const list = Array.isArray(type) ? type : [type];
if (list.length === 0) {
throw new Error("DocumentPicker type must list at least one mime type");
}
for (const mimeType of list) {
if (typeof mimeType !== "string" || !/^[^\s/]+\/[^\s/]+$/.test(mimeType)) {
throw new Error(`DocumentPicker type must be a mime type like 'application/pdf' or 'image/*', got '${String(mimeType)}'`);
}
}
if (typeof multiple !== "boolean") {
throw new Error(`DocumentPicker multiple must be a boolean, got '${String(multiple)}'`);
}
return {
types: [...new Set(list.map((mimeType) => mimeType.toLowerCase()))],
multiple
};
}
export { resolveDocumentPickerOptions };
//# sourceMappingURL=options.mjs.map