Last active
November 5, 2018 15:26
-
-
Save KanagawaMarcos/20e8cf0cfd2899a1138f5d984481999d to your computer and use it in GitHub Desktop.
My first functional programming code. While doing a Restful API project, I managed to be able to write a very simple functional piece of code by myself. It was a really good feeling for me, given the fact that I was struggling so much at understanding the basics functional programming.
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
const trimmed_file_names = data.filter((file_name)=>{ | |
return file_name.indexOf('.log') > -1 || ( include_compressed_logs && file_name.indexOf('.gz.b64') > -1); | |
}).map((file_name)=>{ | |
if(file_name.indexOf('.log') > -1){ | |
// Remove .log extension | |
return file_name.replace('.log',''); | |
} | |
// Add on the .gz files | |
if(file_name.indexOf('.gz.b64') > -1 && include_compressed_logs){ | |
return file_name.replace('.gz.b64','') | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment