Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export async function toSyncedNotepad(notepad) {
// Setup access to our binary assets
const ASSET_STORAGE = localforage.createInstance({
name: 'MicroPad',
storeName: 'assets'
});
await ASSET_STORAGE.ready();
const assetHashes = {};
notepad = await Translators.Json.toNotepadFromNotepad(notepad);
const npAssets = Array.from(getUsedAssets(notepad.flatten()));
// Get assets from storage as base64
const base64Assets = await Promise.all((await Promise.all(npAssets.map(uuid => ASSET_STORAGE.getItem(uuid))))
.map((blob) => {
try {
return getAsBase64(blob);
} catch (e) {
return null;
}
}));
// Build up the asset list
base64Assets
.filter(base64 => !!base64 && base64.length > 0)
.map(base64 => md5(base64))