Hi!
I'm currently adding Option to a project of mine and am surprised there is no Option.from(value | null | undefined).
A concrete use case would be
const array = [ 1, 2, 3 ];
const found = Option.from(array.find(4));
I'm aware of Option.from(() => array.find(4)), but that seems a little verbose for such simple conversions.
This feature is API-incompatible with the current from(), consider
function thirdParty(): undefined | () => number;
function getFn(): Option<() => number> {
return Option.from(thirdParty()); // from() can't know if it is supposed to call the function or not
}
Hi!
I'm currently adding
Optionto a project of mine and am surprised there is noOption.from(value | null | undefined).A concrete use case would be
I'm aware of
Option.from(() => array.find(4)), but that seems a little verbose for such simple conversions.This feature is API-incompatible with the current
from(), consider