Last active
April 14, 2016 09:19
-
-
Save nicoespeon/f3843b426305b60c2512671e8f7df602 to your computer and use it in GitHub Desktop.
Blog - Achieving point-free JavaScript - lodash refactored
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 {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