Created
July 7, 2019 15:00
-
-
Save nicolasmendonca/bdfb3f6febe265de6b76e9279b525539 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
// We declare our mapper function, context aware | |
function mapProductId(transactionsArray) { | |
return transactionsArray | |
.map(transaction => ({ | |
...transaction, | |
productId: this.getProductId(transaction.id) | |
})) | |
} | |
// And now, we can transform our data like so | |
const example3Context = { | |
// This function gets the product somehow | |
getProductId: function(transactionId) {} | |
} | |
responseMapper( | |
example3, | |
[ | |
mapProductName, | |
mapProductId.bind(example3Context) | |
] | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment