monolite icon indicating copy to clipboard operation
monolite copied to clipboard

Add support for collection mapping

Open kube opened this issue 6 years ago • 0 comments

Currently mapping a collection using set is quite verbose and ugly:

// Current
return set(
  response,
  _ => _.results,
  xs =>
    xs.map(result =>
      set(
        result,
        _ => _.poster_path,
        path => 'http://image.tmdb.org/t/p/w185' + path
      )
    )
)

Proposal

set should accept multiple accessor function before the value transformer. The first ones should only target arrays. This would result in a much cleaner syntax:

// With map support
return set(
  response,
  _ => _.results,
  _ => _.poster_path,
  path => 'http://image.tmdb.org/t/p/w185' + path
)

kube avatar Oct 16 '18 23:10 kube