Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for collection mapping #38

Open
kube opened this issue Oct 16, 2018 · 0 comments
Open

Add support for collection mapping #38

kube opened this issue Oct 16, 2018 · 0 comments
Assignees

Comments

@kube
Copy link
Owner

kube commented Oct 16, 2018

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 kube self-assigned this Oct 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant