question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

RA.overWhen / RA.overUnless

See original GitHub issue

Sometimes, I add a helper like this to my codebase :

const R = require('ramda');
const overNonNil = curry((lens, f, state) => {
  if (RA.isNotNil(R.view(lens, state))) {
    return R.over(lens, f, state);
  }
  return state;
})

need opinions about this function.

According to #348, should we add RA.overNonNilProp, RA.overNonNilPathand RA.overNonNilIndex ?

Edit

(according to @Undistraction advices)

Implement a more generic RA.overWhen instead of RA.overNonNil

RA.overWhen

const overWhen = R.curry((predicate, lens, f, state) => {
  if (predicate(R.view(lens, state))) {
    return R.over(lens, f, state);
  }
  return state;
})

and add RA.overPropWhen, RA.overPathWhenand RA.overIndexWhen. (according to implementation below)

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:18 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
char0ncommented, Feb 10, 2018

overWhen is legitimate. Regarding the other derived functions…let’s hold until we clear it out in #348

1reaction
crvougacommented, Jun 3, 2019

Why invent new constructs?

R.over(lens, R.when(predicate, transformation), x)
Read more comments on GitHub >

github_iconTop Results From Across the Web

Why use output buffering in PHP? - Stack Overflow
In some cases, you may want control over when the web-server flushes its buffer, based on some criteria which your application knows best....
Read more >
Internal Revenue Bulletin: 2004-7
It makes clear that a nonresident partner is subject to U.S. income tax on his share of income from the partnership to the...
Read more >
CADASTRAL SURVEY TRAINING STAFF - BLM
gummy, but are seldom completely healed over. When dead and fallen they decay slowly. The recovery rate is reported to ... In the...
Read more >
zcx.tl
Defy Let Ibearectotsface overIF R.a Afunction f WV. IF denoted fumes 14,44andsatisfies it tumblr.IT ii. Lau v. 2h44 iii lutv w. Luw t...
Read more >
Universities to fear | Academic Jobs Wiki - Fandom
University of Iowa College of Education Erasmus University Rotterdam (EUR) Media and Communication Acadia University Arts Monash University Arts
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found