Skip to content

Instantly share code, notes, and snippets.

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