Skip to content

Instantly share code, notes, and snippets.

@nicoespeon
Last active April 14, 2016 09:19
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 nicoespeon/f3843b426305b60c2512671e8f7df602 to your computer and use it in GitHub Desktop.
Save nicoespeon/f3843b426305b60c2512671e8f7df602 to your computer and use it in GitHub Desktop.
Blog - Achieving point-free JavaScript - lodash refactored
import {pipe, pluck, over, head, last, spread} from 'lodash/fp';
import {daysSpent} from './utils/dates';
// leadTime : [{date: Date}] -> Number
const leadTime = pipe(
pluck( 'date' ), // first convert input into [Date]
over( [ head, last ] ), // then turns them to our arguments array [ FirstDate, LastDate ]
spread( daysSpent ) // finally spread arguments to the function
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment