file.js (402B)
1 /** 2 * Reads the textual content of the given file. 3 * 4 * @param {File} file File. 5 * @return {Promise<string>} Content of the file. 6 */ 7 export function readTextFile( file ) { 8 const reader = new window.FileReader(); 9 return new Promise( ( resolve ) => { 10 reader.onload = function() { 11 resolve( reader.result ); 12 }; 13 reader.readAsText( file ); 14 } ); 15 }