T
T
toly192018-02-14 19:35:34
JavaScript
toly19, 2018-02-14 19:35:34

Is it possible to get rid of the direct access to the object?

There is a code:

const obj = {
  someProperty1: {
    data: 12
  },
  someProperty2: {
    data: 44
  }
}

R.assocPath(
  ["someProperty1", "data"],
  R.path(
    ["someProperty2", "data"],
    obj
  )
)(obj)

Is it possible to get rid of repeated access to the object (the second argument for R.path) ?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Petrov, 2018-02-14
@dzhiriki

Can. But why? The code above is easier to understand.
And if for academic purposes, then, for example, like this:

R.compose(
  R.apply(R.assocPath(["someProperty1", "data"])),
  R.juxt([
      R.path(["someProperty2", "data"]),
      R.identity,
  ])
)(obj)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question