Alexander Jarvis

Results 19 comments of Alexander Jarvis

Unfortunately the syntax isn't too great: ```js maybe(valueX) .flatMap(x => maybe(valueY).map(y => ({x, y}))) .foreach({x, y} => { // use x and y }) ``` you can make it a...

You use `map` when you transform the value inside the maybe to another value. `flatMap` is when you need to return a `Maybe` instead and is most useful unwrapping more...

It would be possible to make another type of `Maybe` that takes an array and only lets you `map` / `forEach` when they're all non empty values. For example: ```js...

Also in response to your last comment: you could do it like that. But I wouldn't.. as you're creating a dependency that might break if someone updates it. It's also...

Why would `truncate` `false` set `numberOfLines` to `null`? Should it be the other way around?

You need to use flatmap and return nothing. map doesn't allow you to return a nil value and doesn't implicitly convert null to nothing. It's expected behaviour - I thought...

Would this work? `maybe(props.truncate).filter(t => t).map(t => 1).orJust()` I think you can return `undefined` for `numberOfLines`. This lets you: 1. optionally provide `truncate` 1. if `truncate` is true then it...

Hi @Leeds-eBooks thanks for your contribution. I've given this some thought and am not clear on a concrete use case for this addition. I think if you want to have...

Interestingly however, this is the default behaviour for Scala which turns the value into a closure in the function argument (thus making it lazy). https://github.com/scala/scala/blob/2.13.x/src/library/scala/Option.scala#L133 I'm not sure how to...

It would be possible to create a lazy version of `maybe` if you could specify the predicate function as suggested here: https://github.com/alexanderjarvis/maybe/issues/4 Then you could provide a closure the the...