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.

I got here from your medium article. I’m a long time javascript ninja and am a fan of cleanliness and efficiency. I’ve built a lot of applications, apis, and libraries. But I still don’t really see the point.

This isn’t a criticism of “maybe” itself (yet). On the contrary, I’m intrigued… (enough to write an issue instead of hitting the back button). I just feel like your examples in the readme are a bit basic and on the surface the only thing I see is that they result in more characters, and inevitably slower execution time than the “problem code”.

And with any optional parameter, at some point you’re going to want it to interact with the rest of your logic in a way that is dependant on what the parameter is. So at the end of the day, you’re going to write if ( val.isJust() ){ ... } instead of if ( val != null || val !== undefined ){ ... } or even if ( !_.isEmpty( val ) ){ ... }

So… I’m not understanding something. Can you provide more concrete use-cases to demonstrate what problem this solves?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:12 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
alexanderjarviscommented, Mar 25, 2017

Then you could do this:

function calculatePrice(item: CartItem, coupon?: Coupon): number {
  const price = maybe(item.salePrice).map(salePrice =>
      maybe(item.expiryDate)
        .flatMap(e => e > Date.now() ? nothing : just(item.price))
        .orJust(salePrice)
    )
    .orJust(item.price)

  return maybe(coupon).map(c => price * (1 - c.discount)).orJust(price)
}

But I would suggest splitting into two functions, one for getting the price and another for applying the coupon.

1reaction
wellcaffeinatedcommented, Mar 27, 2017

Also, it would be great if there were a dist/ folder with a built and minified version so people have something to use for testing on things like jsperf or jsfiddle or codepen

Read more comments on GitHub >

github_iconTop Results From Across the Web

1 unclear purpose - Why People Fail: The 16 Obstacles to ...
The reality is that most people are really quite unclear about their desires for life. Sure, they want to be successful, sometimes very...
Read more >
Why Projects Fail: How to Handle Unclear Objectives and ...
According to a Forbes article, a goal is a broad primary outcome, or the “destination.” An objective, on the other hand, is a...
Read more >
unclear purpose? | English examples in context
High quality example sentences with “unclear purpose?” in context from reliable sources - Ludwig is the linguistic search engine that helps you to...
Read more >
Why Projects Fail: How to Handle Unclear ... - Kintone Blog
Why Projects Fail: How to Handle Unclear Objectives and Goals · Understand the difference between goals and objectives · Ask the right questions....
Read more >
Four Effects of Unclear Objectives
Unclear objectives lead to unclear methods of operation. The absence of a goal justifies almost any activity espoused by an individual under the...
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