Created
December 5, 2018 22:12
-
-
Save jrsinclair/40d2f6ea38fe62b6e0d5afcb407415f7 to your computer and use it in GitHub Desktop.
Elegant Error Handling Code Samples
This file contains 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
function csvToMessages(csvData) { | |
const csvRows = splitCSVToRows(csvData); | |
const headerFields = csvRows.map(_.head).map(splitFields); | |
const dataRows = csvRows.map(_.tail); | |
const funcInEither = headerFields.map(processRows); | |
const messagesArr = dataRows.ap(funcInEither); | |
return either(showError, showMessages, messagesArr); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment