import { readFile } from "fs" ; import { callback } from "awaiting" ; export async function jupyter_strip_notebook ( ipynb_path ) { const contents = ( await callback ( readFile , ipynb_path ) ) . toString ( ) ; const obj = JSON . parse ( contents ) ; if ( obj != null && obj . cells != null ) { for ( const cell of obj . cells ) { if ( cell . outputs != null ) { cell . outputs = [ ] ; } if ( cell . attachments != null ) { delete cell . attachments ; } } } return JSON . stringify ( obj ) ; }