Robert Brax Robert Brax - 4 months ago 9
Javascript Question

Parametrize a function

Is there any way to parametrize whereEq, so i can remove 'complete: true' and pass this information when calling the function in console log example below ?

let incomplete = R.filter( R.whereEq( { complete: false } ) )

console.log( incomplete( data ))

Answer

R.wrap could be helpful here.

let incomplete = R.wrap(R.filter, function(filter, array, isComplete) {
  return filter( R.whereEq( { complete: isComplete }), array )
})

incomplete(data, false);
Comments