Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return (dispatch, getState) => {
const filename = content.markdown;
if (!filename) {
return;
}
const contents = getState();
if (contents.markdownPages.get(filename)) {
// already loaded
return;
}
dispatch(loadContentStart(filename));
text(filename, (error, response) => {
dispatch(loadContentSuccess(filename, error ? error.target.response : response));
});
};
}
return (dispatch, getState) => {
const {contents} = getState();
if (filename in contents) {
// already loaded
return;
}
dispatch(loadContentStart(filename));
text(filename, (error, response) => {
dispatch(loadContentSuccess(filename, error ? error.target.response : response));
});
};
};
function load_the_file (t, file, callback, value) {
if (value) {
if (file) console.warn('File ' + file + ' overridden by value.')
callback.call(t, null, value)
return
}
if (!file) {
callback.call(t, 'No filename', null)
return
}
if (_ends_with(file, 'json')) {
d3_json(file, function(e, d) { callback.call(t, e, d) })
} else if (_ends_with(file, 'css')) {
d3_text(file, function(e, d) { callback.call(t, e, d) })
} else {
callback.call(t, 'Unrecognized file type', null)
}
return
}
function load_css(css_path, callback) {
var css = ""
if (css_path) {
d3_text(css_path, function(error, text) {
if (error) {
console.warn(error)
}
css = text
callback(css)
})
}
return false
}
return new Promise((resolve, reject) => {
request.text(url).get(null, (err, res) => {
if (err) {
reject(err);
} else if (!res) {
reject(new Error(`Empty response received for ${url}`));
} else {
resolve(res);
}
});
});
}