Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
switchMap((action: Action) => {
try {
Parser.parse(action.payload, ['asciimath']);
} catch (err) {
alert(`Error reading file`);
console.error(err);
throw err;
}
return fromPromise(new Promise(resolve => {
const notepad: INotepad = Parser.notepad;
// Sort out assets
Parser.parseAssets(action.payload, async (assets: IAssets) => {
const notepadAssets = new Set((notepad.notepadAssets || []));
for (let i = 0; i < assets.assets.length; i++) {
if (!notepadAssets.has(assets.assets[i].uuid)) notepadAssets.add(assets.assets[i].uuid);
await ASSET_STORAGE.setItem(assets.assets[i].uuid, assets.assets[i].data);
}