Comparing version 1.2.0 to 1.2.1
@@ -602,2 +602,3 @@ //// ____ _ _ | ||
mapRej: Future$mapRej, | ||
[FL.bimap]: Future$bimap, | ||
bimap: Future$bimap, | ||
@@ -604,0 +605,0 @@ [FL.ap]: Future$ap, |
{ | ||
"name": "fluture", | ||
"version": "1.2.0", | ||
"description": "A mathematically correct alternative to Promises for asynchronous control flow", | ||
"version": "1.2.1", | ||
"description": "FantasyLand compliant (monadic) alternative to Promises", | ||
"main": "fluture.js", | ||
@@ -33,2 +33,3 @@ "repository": "https://github.com/Avaq/fluture.git", | ||
"keywords": [ | ||
"algebraic", | ||
"async", | ||
@@ -45,2 +46,3 @@ "asynchronous", | ||
"monad", | ||
"monadic", | ||
"node", | ||
@@ -52,3 +54,3 @@ "parallel", | ||
"dependencies": { | ||
"fantasy-land": "^0.2.1", | ||
"fantasy-land": "^0.3.0", | ||
"inspect-f": "^1.1.0" | ||
@@ -66,6 +68,6 @@ }, | ||
"markdown-toc": "^0.12.6", | ||
"mocha": "^2.3.3", | ||
"mocha": "^3.0.2", | ||
"nsp": "^2.2.0", | ||
"pacta": "^0.9.0", | ||
"ramda": "^0.21.0", | ||
"ramda": "^0.22.1", | ||
"ramda-fantasy": "^0.6.0", | ||
@@ -72,0 +74,0 @@ "rimraf": "^2.4.3", |
# Fluture | ||
[<img src="https://raw.github.com/fantasyland/fantasy-land/master/logo.png" align="right" width="116" height="116" alt="Fantasy Land" />][1] | ||
[<img src="https://raw.github.com/fantasyland/fantasy-land/master/logo.png" align="right" width="196" height="196" alt="Fantasy Land" />][1] | ||
@@ -10,12 +10,28 @@ [![NPM Version](https://badge.fury.io/js/fluture.svg)](https://www.npmjs.com/package/fluture) | ||
Futures are containers which represent some eventual value as a result of an | ||
asynchronous computation, much like Promises. Unlike Promises, however, Futures | ||
are *lazy* and *logical* by design. They have a predictable API governed by the | ||
[Fantasy Land][1] algebraic JavaScript specification. | ||
Fluture offers a control structure similar to Promises, Tasks, Deferreds, and | ||
what-have-you. Let's call them Futures. | ||
> `npm install --save fluture` <sup>Requires a node 4.0.0 compatible environment | ||
like modern browsers, transpilers or Node 4+</sup> | ||
Much like Promises, Futures represent the value arising from the success or | ||
failure of an asynchronous operation (I/O). Though unlike Promises Futures are | ||
*lazy* and *monadic* by design. They conform to the [Fantasy Land][1] algebraic | ||
JavaScript specification. | ||
Fluture boasts the following features: | ||
* Fine-grained control over asynchronous flow through generic monadic | ||
transformations and an array of control utilities. | ||
* Plays nicely with functional libraries such as [Ramda][20] and [Sanctuary][21]. | ||
* Provides a pleasant debugging experience through informative error messages. | ||
* Considerable performance benefits over Promises and the likes. | ||
For more information: | ||
* [Wiki: Compare Futures to Promises][22] | ||
* [Wiki: Compare Fluture to similar libraries][15] | ||
* [Video: Monad a Day by @DrBoolean - Futures][23] | ||
## Usage | ||
> `npm install --save fluture` <sup>Requires a node 4.0.0 compatible environment</sup> | ||
```js | ||
@@ -36,3 +52,3 @@ const Future = require('fluture'); | ||
- [Motivation and Features](#motivation-and-features) | ||
- [Usage](#usage) | ||
- [Documentation](#documentation) | ||
@@ -80,14 +96,2 @@ 1. [Type signatures](#type-signatures) | ||
## Motivation and Features | ||
Existing implementations of Future are a pain to debug. This library was made in | ||
an effort to provide **great error messages** when something goes wrong. Other | ||
features include: | ||
* Plenty of async control utilites like [Future.parallel](#parallel) and [Future#race](#race). | ||
* High performance. | ||
To learn more about the differences between Fluture and other Future | ||
implementations, take a look at [this wiki page][15]. | ||
## Documentation | ||
@@ -107,9 +111,7 @@ | ||
- **Future** - Instances of Future provided by Fluture. | ||
- **Functor** - Any object with a `map` method which satisfies the | ||
[Fantasy Land Functor specification][12]. | ||
- **Chain** - Any object with a `chain` method which satisfies the | ||
[Fantasy Land Chain specification][13]. | ||
- **Apply** - Any object with an `ap` method which satisfies the | ||
[Fantasy Land Apply specification][14]. | ||
- **Iterator** - Any object which conforms to the [Iterator protocol][18]. | ||
- **Functor** - Values which conform to the [Fantasy Land Functor specification][12]. | ||
- **Bifunctor** - Values which conform to the [Fantasy Land Bifunctor specification][24]. | ||
- **Chain** - Values which conform to the [Fantasy Land Chain specification][13]. | ||
- **Apply** - Values which conform to the [Fantasy Land Apply specification][14]. | ||
- **Iterator** - Values which conform to the [Iterator protocol][18]. | ||
@@ -119,10 +121,10 @@ ### Creating Futures | ||
#### Future | ||
##### `Future :: ((a -> Void), (b -> Void) -> Void) -> Future a b` | ||
##### `Future :: ((a -> ()), (b -> ()) -> ()) -> Future a b` | ||
The Future constructor. Creates a new instance of Future by taking a single | ||
parameter `fork`: A function which takes two callbacks. Both are continuations | ||
for an asynchronous computation. The first is `reject`, commonly abbreviated to | ||
for an asynchronous operation. The first is `reject`, commonly abbreviated to | ||
`rej`. The second `resolve`, which abbreviates to `res`. The `fork` function is | ||
expected to call `rej` once an error occurs, or `res` with the result of the | ||
asynchronous computation. | ||
asynchronous operation. | ||
@@ -142,3 +144,3 @@ ```js | ||
#### Guarded | ||
##### `.Guarded :: ((a -> Void), (b -> Void) -> Void) -> Future a b` | ||
##### `.Guarded :: ((a -> ()), (b -> ()) -> ()) -> Future a b` | ||
@@ -204,3 +206,3 @@ A slight variation to the Future constructor. It guarantees that neither of the | ||
#### try | ||
##### `.try :: (Void -> !a | b) -> Future a b` | ||
##### `.try :: (() -> !a | b) -> Future a b` | ||
@@ -230,3 +232,3 @@ Creates a Future which resolves with the result of calling the given function, | ||
const parseJson = Future.encase(JSON.parse); | ||
parseJson('a').fork(console.error, console.log) | ||
parseJson(data).fork(console.error, console.log) | ||
//> [SyntaxError: Unexpected token =] | ||
@@ -236,3 +238,3 @@ ``` | ||
#### node | ||
##### `.node :: ((a, b -> Void) -> Void) -> Future a b` | ||
##### `.node :: ((a, b -> ()) -> ()) -> Future a b` | ||
@@ -261,3 +263,3 @@ Creates a Future which rejects with the first argument given to the function, | ||
that it's lazy, so the transformation will not be applied before the Future is | ||
forked. The transformation is only applied to the resolution branch. So if the | ||
forked. The transformation is only applied to the resolution branch: If the | ||
Future is rejected, the transformation is ignored. To learn more about the exact | ||
@@ -299,3 +301,3 @@ behaviour of `map`, check out its [spec][12]. | ||
new Future will not be created until the other one is forked. The function is | ||
only ever applied to the resolution value, so is ignored when the Future was | ||
only ever applied to the resolution value; it's ignored when the Future was | ||
rejected. To learn more about the exact behaviour of `chain`, check out its [spec][13]. | ||
@@ -410,3 +412,3 @@ | ||
Much like [`chain`](#chain), but takes a "cleanup" computation first, which runs | ||
Much like [`chain`](#chain), but takes a "cleanup" operation first, which runs | ||
*after* the second settles (successfully or unsuccessfully). This allows for | ||
@@ -428,3 +430,3 @@ acquired resources to be disposed, connections to be closed, etc. | ||
Take care when using this in combination with [`cache`](#cache). Hooking relies | ||
on the first computation providing a fresh resource every time it's forked. | ||
on the first operation providing a fresh resource every time it's forked. | ||
@@ -464,4 +466,4 @@ #### finally | ||
#### fork | ||
##### `#fork :: Future a b ~> (a -> Void), (b -> Void) -> Void` | ||
##### `.fork :: (a -> Void) -> (b -> Void) -> Future a b -> Void` | ||
##### `#fork :: Future a b ~> (a -> ()), (b -> ()) -> ()` | ||
##### `.fork :: (a -> ()) -> (b -> ()) -> Future a b -> ()` | ||
@@ -492,4 +494,4 @@ Execute the Future by calling the `fork` function that was passed to it at | ||
#### value | ||
##### `#value :: Future a b ~> (b -> Void) -> Void` | ||
##### `.value :: (b -> Void) -> Future a b -> Void` | ||
##### `#value :: Future a b ~> (b -> ()) -> ()` | ||
##### `.value :: (b -> ()) -> Future a b -> ()` | ||
@@ -773,1 +775,6 @@ Extracts the value from a resolved Future by forking it. Only use this function | ||
[19]: https://github.com/russellmcc/fantasydo | ||
[20]: http://ramdajs.com/ | ||
[21]: http://sanctuary.js.org/ | ||
[22]: https://github.com/Avaq/Fluture/wiki/Comparison-to-Promises | ||
[23]: https://vimeo.com/106008027 | ||
[24]: https://github.com/fantasyland/fantasy-land#bifunctor |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
52303
738
765
+ Addedfantasy-land@0.3.0(transitive)
- Removedfantasy-land@0.2.1(transitive)
Updatedfantasy-land@^0.3.0