Created
May 12, 2018 08:56
-
-
Save fakiolinho/5ac0a233b72b7b47ba0488335f784e6d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default file => { | |
const fileReader = new FileReader(); | |
return new Promise((resolve, reject) => { | |
fileReader.onerror = () => { | |
fileReader.abort(); | |
reject(new Error('Problem parsing file')); | |
}; | |
fileReader.onload = () => { | |
resolve(fileReader.result); | |
}; | |
fileReader.readAsText(file); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment