These are chat archives for ramda/ramda

1st
Oct 2016
Markus Pfundstein
@MarkusPfundstein
Oct 01 2016 13:59
This message was deleted
naive implementation ofc :-) but I think cool PoC
Jigar Gosar
@jigargosar
Oct 01 2016 14:01
_.compose(_.applySpec,_.merge({a:1}))({b:2})
Weird error "Uncaught TypeError: Cannot read property 'length' of undefined(…)"
Jigar Gosar
@jigargosar
Oct 01 2016 14:06
figure out, spec needs functions as values.
function applySpecWithProps(propNames, spec){
  function reducer(acc, propName)  {
    return _.merge(acc, _.objOf(propName, _.prop(propName)));
  };
  var spec = _.reduce(reducer, spec, propNames);
  return _.applySpec(spec);
}

function applySpecWithProps2(propNames, spec){  
  var propSpec = _.zipObj(propNames, _.map(_.prop, propNames));
  return _.applySpec(_.merge(propSpec, spec));
}

var applySpecWithProps3 = function(propNames, spec){  
  return _.converge(_.merge, [_.applySpec(spec), _.pick(propNames)]);
};
three version of same function. Any feedback? opinions?
working code can be found at http://codepen.io/jigargosar/pen/PGmkAz?editors=0010