MCPcopy Create free account
hub / github.com/microsoft/SandDance / handleRawText

Function handleRawText

docs/app/js/sanddance-app.js:16031–16051  ·  view source on GitHub ↗
(text)

Source from the content-addressed store, hash-verified

16029 const vega = (0, _sanddanceReact.SandDance).VegaDeckGl.base.vega;
16030 const loader = vega.loader();
16031 function handleRawText(text) {
16032 let data;
16033 try {
16034 data = vega.read(text, {
16035 type: dataFile.type,
16036 parse: {}
16037 });
16038 } catch (e) {
16039 reject(e);
16040 }
16041 if (data) loadDataArray(data, dataFile.type).then((dc)=>{
16042 if (dataFile.snapshotsUrl) fetch(dataFile.snapshotsUrl).then((response)=>response.json()).then((snapshots)=>{
16043 dc.snapshots = snapshots;
16044 resolve(dc);
16045 }).catch(reject);
16046 else if (dataFile.snapshots) {
16047 dc.snapshots = dataFile.snapshots;
16048 resolve(dc);
16049 } else resolve(dc);
16050 }).catch(reject);
16051 }
16052 if (dataFile.dataUrl) loader.load(dataFile.dataUrl).then(handleRawText).catch(reject);
16053 else if (dataFile.rawText) handleRawText(dataFile.rawText);
16054 else reject("dataFile object must have either dataUrl or rawText property set.");

Callers 1

loadDataFileFunction · 0.70

Calls 3

rejectFunction · 0.85
loadDataArrayFunction · 0.70
resolveFunction · 0.70

Tested by

no test coverage detected