How to use the upad-parse.Translators.Json function in upad-parse

To help you get started, we’ve selected a few upad-parse examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github MicroPad / Web / app / src / react-web / SyncWorker.js View on Github external
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))