cachaito
8/19/2015 - 7:37 AM

Currying with lodash

var _ = require('lodash');
var dragons = [
  {name: 'XXX', size: 'L'},
  {name: 'YYY', size: 'L'},
  {name: 'OOO', size: 'M'},
  {name: 'ZZZ', size: 'S'}
];

var hasRightSize = _.curry(function(size, dragon) {
  return dragon.size === size;
});

var bigDragons = dragons.filter(hasRightSize('L'));

console.log(bigDragons);