mirror of
https://github.com/morris/vanilla-todo.git
synced 2025-08-24 06:33:54 +02:00
add data import/export (#11)
This commit is contained in:
@@ -84,3 +84,16 @@ export const MONTH_NAMES = [
|
||||
export function formatMonth(date) {
|
||||
return MONTH_NAMES[date.getMonth()];
|
||||
}
|
||||
|
||||
/**
|
||||
* https://developer.mozilla.org/en-US/docs/Glossary/Base64
|
||||
* @param {BlobPart} input
|
||||
*/
|
||||
export async function toDataURL(input, type) {
|
||||
return await new Promise((resolve, reject) => {
|
||||
const reader = new FileReader();
|
||||
reader.addEventListener('load', () => resolve(reader.result));
|
||||
reader.addEventListener('error', () => reject(reader.error));
|
||||
reader.readAsDataURL(new File([input], '', { type }));
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user