-
v1, Beta 2 Pre-Release
released this
2024-07-29 20:50:13 +00:00 | 4 commits to main since this releaseBREAKING CHANGE
Option->is()has been renamedOption->contains()for consistency withResult(and any future collection implementation).FEATURES
BothOptionandResultnow support:bind: takes a callback that accepts the Some or OK value and returns anOptionorResult, respectively. If theOptionis None or theResultis Error, the callback will be skipped. This allows what is termed "railway-oriented programming" where every call is an opportunity to short-circuit the rest of the calls and return the Error result (or None).contains: takes a value and an optionalstrict:parameter; it returnstrueif the Some or OK value matches the value provided, orfalseotherwise.exists: takes a callback that accepts the Some or OK value and returnsbool; None or Error results always returnfalse.toArray: converts a SomeOptionand an OKResultto a one-item array, and converts a NoneOptionand an ErrorResultto an empty array.
Additionally,
Optionnow has agetOrThrowmethod that takes a callback that returns anException. If theOptionis Some, the value is returned; if it is None, the callback is called and the resultingExceptionis thrown.Downloads