Skip to content

Instantly share code, notes, and snippets.

@vastus
Last active October 28, 2018 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vastus/c194bf59ac5619d8902885336f86563a to your computer and use it in GitHub Desktop.
Save vastus/c194bf59ac5619d8902885336f86563a to your computer and use it in GitHub Desktop.
Composition in TypeScript with Ramda
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