Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function downloadNotebook(notebook: nbformat.INotebookContent, filename: string) {
let element = document.createElement('a');
element.setAttribute(
'href', 'data:text/plain;charset=utf-8,' +
encodeURIComponent(stringify(notebook)));
element.setAttribute('download', filename);
element.style.display = 'none';
document.body.appendChild(element);
try {
element.click();
} finally {
document.body.removeChild(element);
}
}