package
Bring back Fluture's fluent method API
npm install fluentureGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Tagged topics.
Estimated unpacked size across 1 packages.
27.1 kB
Includes dependencies.
Brings back Fluture's fluent method API, for the nostalgic developer.
$ npm install --save fluentureOn Node 12 and up, this module can be loaded directly with import or
require. On Node versions below 12, require or the esm-loader can
be used.
You can load the EcmaScript module from various content delivery networks:
There's a UMD file included in the NPM package, also available via jsDelivr: https://cdn.jsdelivr.net/npm/fluenture@3.1.0/dist/umd.js
This file adds fluenture to the global scope, or use CommonJS/AMD
when available.
import {resolve, reject} from 'fluture';
import {fluent} from 'fluenture';
fluent (resolve (42))
.map (x => x / 2)
.chain (x => reject (x + 21))
.swap ()
.fork (console.error, console.log)We're using the Fluenture a b type here to denote instances of Future
that were enhanced with a fluent method API. One can think of the
Fluenture type as a subtype of Future: any instances of it are also
instances of Future.
fluent :: Future a b -> Fluenture a bEnhance a Future with the fluent method API.
This function is idempotent.
functional :: Future a b -> Future a bStrip a fluent Future (or "Fluenture") from its method API.
This function is idempotent.
pipe :: (Future a b -> c) -> cThis function is equivalent to Fluture's built-in pipe function, with
once exception; If a Future is returned from the given function, it is
automatically wrapped using fluent, so as to keep the fluent
method chain intact.
Fluent pipe.
alt :: Fluenture a b ~> Future a b -> Fluenture a bFluent alt.
and :: Fluenture a b ~> Future a b -> Fluenture a bFluent and.
ap :: Fluenture a b ~> Future a (b -> c) -> Fluenture a cFluent ap.
bichain :: Fluenture a b ~> (a -> Fluenture a c, b -> Fluenture a c) -> Fluenture a cFluent bichain.
bimap :: Fluenture a b ~> (a -> c, b -> d) -> Fluenture c dFluent bimap.
both :: Fluenture a b ~> Future a c -> Fluenture a (Pair b c)Fluent both.
cache :: Fluenture a b ~> () -> Fluenture a bFluent cache.
chain :: Fluenture a b ~> (b -> Fluenture a c) -> Fluenture a cFluent chain.
chainRej :: Fluenture a b ~> (a -> Fluenture c b) -> Fluenture c bFluent chainRej.
coalesce :: Fluenture a b ~> (a -> c, b -> c) -> Fluenture d cFluent coalesce.
lastly :: Fluenture a b ~> Future a c -> Fluenture a bFluent lastly.
map :: Fluenture a b ~> (b -> c) -> Fluenture a cFluent map.
mapRej :: Fluenture a b ~> (a -> c) -> Fluenture c bFluent mapRej.
pap :: Fluenture a b ~> Fluenture a (b -> c) -> Fluenture a cFluent pap.
race :: Fluenture a b ~> Future a b -> Fluenture a bFluent race.
swap :: Fluenture a b ~> () -> Fluenture b aFluent swap.
done :: Fluenture a b ~> (b -> c) -> CancelFluent done.
fork :: Fluenture a b ~> (a -> c, b -> d) -> CancelFluent fork.
forkCatch :: Fluenture a b ~> (Error -> c, a -> d, b -> e) -> CancelFluent forkCatch.
promise :: Fluenture Error a ~> () -> Promise Error aFluent promise.
value :: Fluenture a b ~> ((Nullable a, b) -> c) -> CancelFluent value.
dicearr
diego@ceresuela.es