🦋 Fantasy Land compliant (monadic) alternative to Promises
:sparkles: New features
alt
function to use with Alt
types such as ConcurrentFuture
.of
, ap
, map
, alt
and zero
functions to Par
, making the ConcurrentFuture
type Static Land -compliant.:sparkles: Improvements
ap
and map
are now overloaded to work on ConcurrentFuture
instances as well as Future
instances.extractLeft
and extractRight
methods.:warning: Breaking changes
chainRec
named export has been removed in favor of regular recursion.:sparkles: New features
:sparkles: Improvements
Future.parallel
has been made stack-safe.Future.parallel
now guarantees execution order.:spiral_notepad: Note
6.3.x
futures will not be compatible with 6.2.x
Futures, so when upgrading, make sure to upgrade all producers of Future instances.
To avoid having to do this with future releases, I recommend setting Fluture as a peerDependency if you are maintaining a library which exposes Future instances to its users.
:bug: Bug fixes since 6.2.6
Future.both
was being executed twice under some circumstances.Future.parallel
with Future.hook
in a certain way led to fork()
throwing an exception.:sparkles: New features
Future.done()
and Future#done()
: an easy way to fork using a Nodeback.:bug: Bug fixes and improvements
chain
s interoperability of different compatible versions of FlutureFuture#both()
cancel the other when the one rejects.:warning: Breaking changes
fluture/es5
to fluture
.Future#hook
method (but not the function) has been removed.Future#cache
method (but not the function) has been removed.Object.create
, Object.assign
and Array.isArray
.ap
-method have been flipped back.and
and or
no longer run the two Futures in parallel.fromPromise
has been renamed to encaseP
.chainRec
is no longer curried and direct use is now discouraged.:sparkles: New features
chain
, are now stack safe!isNever
.tryP
, the nullary version of encaseP
.:bug: Bug fixes and improvements
tryP
or encaseP
no longer get caught (and silenced) by the Promise.Future.hook
no longer cancels the acquire Future after it has settled.Future.hook
now always cancels running Futures appropriately.attempt = try
, go = do
, lastly = finally
.encase
and encaseP
.:warning: Breaking changes
Future.or()
has been flippedFuture.isForkable()
has been removedFuture.fromForkable()
has been removedFuture.cast()
has been removedS.is(Future, Future.of(1))
now returns true
rather than false
:sparkles: New features
:bug: Bug fixes and improvements
Future
s from other versions of Fluture as valid FuturesFuture.finally()
now runs finally
computation when cancelled:warning: Breaking changes (see upgrading below)
Future.recur
has been removed in favor of Future.chainRec
.Future.ap
is no longer parallel. Instead one might use Future.and
or Future.both
.of
and fantasy-land/chainRec
are no longer available on the prototype.:sparkles: New features
Future.rejectAfter
has been added as a counterpart to Future.after
.Future.and
has been added as a counterpart to Future.or
.Future.both
has been added as an alias to Future.parallel(2, [a, b])
.ap
, map
, bimap
and chain
functions can now handle native
algebraic data types, courtesy of sanctuary-type-classes.:bug: Bug fixes and improvements
:rocket: Performance
Future.race
has trippled.Future.cache
has doubled.Future.chainRec
has improved by 50%.Future.parallel
has improved by 30%.:arrow_up: Upgrading
Refactor code using Future.recur
into code using Future.chainRec
const repeat = (x) => Future.after(10, x).map(add(1)).recur(repeat);
repeat(1).fork(...)
Future.chainRec((next, done, x) => Future.after(10, x).map(add(1)).map(next), 1)
.fork(...)
Use Future.both
over Future.ap
for parallelism
Future.of(1).ap(Future.of(add(1)))
Future.of(1).both(Future.of(add(1))).map(([x, f]) => f(x))
Use Future.parallel(Infinity)
over sequence(Future.of)
sequence(Future.of, [m1, m2, m3])
Future.parallel(Infinity, [m1, m2, m3])
Access of
via constructor
property
const empty = m => m.of()
const empty = m => m.constructor.of()
The argument order of the ap
method has been flipped in order to comply to the FantasyLand 1.0 spec.
Ensures cancel
functions of settled Futures are never called.