Skip to content

Instantly share code, notes, and snippets.

@nicolasmendonca
Created July 7, 2019 14:55
Show Gist options
  • Save nicolasmendonca/a012159c004f0ece885f48b17a27508b to your computer and use it in GitHub Desktop.
Save nicolasmendonca/a012159c004f0ece885f48b17a27508b to your computer and use it in GitHub Desktop.
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