/** * Web worker handling message API. * Return a message of the request. */ onmessage = async(e) => { const url = e.data.url; const state = e.data.state; const request = { ApplicationState: state }; const dataParsed = JSON.stringify(request, GetCircularReplacerKeepDataStructure()); fetch(url, { method: 'POST', headers: new Headers({ // eslint-disable-next-line @typescript-eslint/naming-convention 'Content-Type': 'application/json' }), body: dataParsed }) .then((response) => response.json() ) .then(async(json) => { postMessage(json.messages) }); }; function GetCircularReplacerKeepDataStructure() { return (key, value) => { if (key === 'parent') { return; } if (key === 'containers') { return [...value.entries()].map((keyPair) => { return { Key: keyPair[0], Value: keyPair[1] }; }); } if (key === 'symbols') { return [...value.entries()].map((keyPair) => { return { Key: keyPair[0], Value: keyPair[1] }; }); } if (key === 'linkedContainers') { return Array.from(value); } }; }