Created
July 7, 2019 14:55
-
-
Save nicolasmendonca/a012159c004f0ece885f48b17a27508b to your computer and use it in GitHub Desktop.
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 responseMapper(response, mapperFunctions) { | |
return mapperFunctions.reduce( | |
(result, mapper) => mapper(result), | |
response | |
); | |
} | |
// And call it like this | |
const result1 = responseMapper(response1, [ | |
mapProductName, | |
]); | |
const result2 = responseMapper(response2, [ | |
mapProductName, | |
mapTransactionIdIntoId, | |
]) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment