Comparing version 0.5.4 to 0.5.5
@@ -159,2 +159,6 @@ /*global define*/ | ||
function check$promise(it){ | ||
if(!isFluture(it)) error$invalidContext('Future#promise', it); | ||
} | ||
function check$cache(m){ | ||
@@ -333,2 +337,10 @@ if(!isFluture(m)) error$invalidArgument('Future.cache', 0, 'be a Future', m); | ||
function Future$promise(){ | ||
check$promise(this); | ||
const _this = this; | ||
return new Promise(function Future$promise$do(resolve, reject){ | ||
_this.fork(reject, resolve); | ||
}); | ||
} | ||
//Give Future a prototype. | ||
@@ -352,3 +364,4 @@ FutureClass.prototype = Future.prototype = { | ||
fold: Future$fold, | ||
value: Future$value | ||
value: Future$value, | ||
promise: Future$promise | ||
}; | ||
@@ -481,8 +494,10 @@ | ||
return new FutureClass(function Future$encase$fork(rej, res){ | ||
let y; | ||
try{ | ||
res(f(x)); | ||
y = f(x); | ||
} | ||
catch(err){ | ||
rej(err); | ||
return void rej(err); | ||
} | ||
res(y); | ||
}); | ||
@@ -489,0 +504,0 @@ }; |
{ | ||
"name": "fluture", | ||
"version": "0.5.4", | ||
"version": "0.5.5", | ||
"description": "A complete Fantasy Land compatible Future library", | ||
@@ -5,0 +5,0 @@ "main": "fluture.js", |
@@ -7,3 +7,2 @@ # Fluture | ||
[![Code Coverage](https://codecov.io/github/Avaq/Fluture/coverage.svg?branch=develop)](https://codecov.io/github/Avaq/Fluture/fluture.js?branch=develop) | ||
[![Code Quality](https://www.bithound.io/github/Avaq/Fluture/badges/score.svg)](https://www.bithound.io/github/Avaq/Fluture) | ||
@@ -48,8 +47,8 @@ A complete [Fantasy Land][1] compatible Future library. | ||
I've always liked Promises, and I've come to like Futures even more. Existing | ||
implementations are a pain to debug though. I made this library in an effort to | ||
provide **great error messages** when something goes wrong. I didn't want these | ||
to come at the cost of performance though, so I made sure Fluture operates at | ||
**high performance**. Throughout my work with Future's, I've created a lot of | ||
**async control utilities** which I've decided to bundle with this library. | ||
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. The | ||
library also comes bundled with many **async control utilities**. To prevent | ||
these features from coming at the cost of performance, Fluture was optimized to | ||
operate at **high performance**. For an overview of differences between Fluture | ||
and other Future implementations, look at [this wiki article][15]. | ||
@@ -60,27 +59,16 @@ ## Documentation | ||
I'm using [Hindley-Milner] type signatures to document functions. A list of all | ||
types I'll use within these signatures follows. | ||
[Hindley-Milner][9] type signatures are used to document functions. A list of | ||
all types used within these signatures follows: | ||
#### Forkable | ||
- **Forkable** - Any Object with a `fork` method that takes at least two | ||
arguments. This includes instances of Fluture, instances of Task from | ||
[`data.task`][10] or instances of Future from [`ramda-fantasy`][11]. | ||
- **Future** - Instances of Future provided by Fluture. | ||
- **Functor** - Any object that has a `map` method which satisfies the | ||
[Fantasy Land Functor specification][12]. | ||
- **Chain** - Any object that has a `chain` method which satisfies the | ||
[Fantasy Land Chain specification][13]. | ||
- **Apply** - Any object that has an `ap` method which satisfies the | ||
[Fantasy Land Apply specification][14]. | ||
Any Object with a `fork` method that takes at least two arguments. This includes | ||
instances of Fluture, instances of Task from [`data.task`][10] or instances of | ||
Future from [`ramda-fantasy`][11]. | ||
#### Future | ||
Instances of Future provided by Fluture. | ||
#### Functor | ||
Any object that has a `map` method which satisfies the [Fantasy Land Functor specification][12]. | ||
#### Chain | ||
Any object that has a `chain` method which satisfies the [Fantasy Land Chain specification][13]. | ||
#### Apply | ||
Any object that has an `ap` method which satisfies the [Fantasy Land Apply specification][14]. | ||
### Constructors | ||
@@ -388,2 +376,8 @@ | ||
#### `promise :: Future a b ~> Promise b a` | ||
Cast the Future to a Promise. This will cause the Future to be eagerly forked. | ||
This is useful if some API wants you to give it a Promise. You shouldn't need | ||
this method for anything else. | ||
### Dispatcher API | ||
@@ -488,3 +482,3 @@ | ||
* [ ] Implement Future.predicate | ||
* [ ] Implement Future#promise | ||
* [x] Implement Future#promise | ||
* [x] Implement Future.cast | ||
@@ -533,1 +527,2 @@ * [x] Implement Future.encase | ||
[14]: https://github.com/fantasyland/fantasy-land#apply | ||
[15]: https://github.com/Avaq/Fluture/wiki/Comparison-of-Future-Implementations |
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
34808
6
492
523