Last active
October 28, 2018 14:02
-
-
Save vastus/c194bf59ac5619d8902885336f86563a to your computer and use it in GitHub Desktop.
Composition in TypeScript with Ramda
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
import R from 'ramda'; | |
type Invoice = { | |
invoiceDate: Date; | |
}; | |
// latestInvoice :: Invoice[] -> Invoice | |
const latestInvoice = R.compose<Invoice[], Invoice[], Invoice[], Invoice>( | |
R.head, | |
R.sort(R.descend(R.prop('invoiceDate'))), | |
R.filter<Invoice>(R.has('invoiceDate')), | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment