Andrew C.
Andrew C.

Reputation: 461

Pass additional parameters to functions within lodash's flow()

If I want to change the delimiter of join() to something other than the default, how do I pass that to that specific function within this chain?

const evens = (x) => _.filter(x, y => y % 2 === 0)

console.log(
  _.flow(
    evens,
    _.join,
  )([1, 2, 3, 4, 5, 6])
) 
// expected output: ('2+4+6')
// actual output: ('2,4,6')

Upvotes: 0

Views: 204

Answers (1)

awquadros
awquadros

Reputation: 529

This works

const evens = (x) => _.filter(x, y => y % 2 === 0)

console.log(
  _.flow(
    evens,
    (a) => _.join(a, '+'),
  )([1, 2, 3, 4, 5, 6])
) 
<script src="https://cdn.jsdelivr.net/npm/[email protected]/lodash.min.js"></script>

Upvotes: 1

Related Questions