Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
datasetHandler(ds) {
if (ds.vtkClass) {
return vtk(ds);
}
return ReaderFactory.downloadDataset(ds.name, ds.url)
.then((file) => ReaderFactory.loadFiles([file]))
.then((readers) => readers[0])
.then(({ dataset, reader }) => {
if (reader && reader.getOutputData) {
const newDS = reader.getOutputData();
newDS.set(ds, true); // Attach remote data origin
return newDS;
}
if (dataset && dataset.isA) {
dataset.set(ds, true); // Attach remote data origin
return dataset;
}
if (reader && reader.setProxyManager) {
reader.setProxyManager(state.proxyManager);
return null;
}
FETCH_REMOTE({ commit }, remotes) {
commit(Mutations.FILE_LOAD);
const progressCb = (index) => (progress) =>
commit(Mutations.FILE_UPDATE_PROGRESS, {
index,
progress: (100 * progress.loaded) / progress.total / remotes.length,
});
const promises = [];
for (let i = 0; i < remotes.length; ++i) {
promises.push(
ReaderFactory.downloadDataset(
remotes[i].name,
remotes[i].url,
progressCb(i)
)
);
}
return allWithErrors(promises);
},
LOAD_STATE({ dispatch }, stateFile) {