Comparing version 0.9.11-0 to 0.9.11-1
50
API.md
@@ -1405,2 +1405,27 @@ #API Reference | ||
**Tip** | ||
If you yield an array then its elements are implicitly waited for. | ||
You can combine it with ES6 destructing for some neat syntax: | ||
```js | ||
var getData = Promise.coroutine(function* (urlA, urlB) { | ||
[resultA, resultB] = yield [http.getAsync(urlA), http.getAsync(urlB)]; | ||
//use resultA | ||
//use resultB | ||
}); | ||
``` | ||
You might wonder why not just do this? | ||
```js | ||
var getData = Promise.coroutine(function* (urlA, urlB) { | ||
var resultA = yield http.getAsync(urlA); | ||
var resultB = yield http.getAsync(urlB); | ||
}); | ||
``` | ||
The problem with the above is that the requests are not done in parallel. It will completely wait for request A to complete before even starting request B. In the array syntax both requests fire off at the same time in parallel. | ||
<hr> | ||
@@ -1454,2 +1479,27 @@ | ||
**Tip** | ||
If you yield an array then its elements are implicitly waited for. | ||
You can combine it with ES6 destructing for some neat syntax: | ||
```js | ||
var getData = Promise.coroutine(function* (urlA, urlB) { | ||
[resultA, resultB] = yield [http.getAsync(urlA), http.getAsync(urlB)]; | ||
//use resultA | ||
//use resultB | ||
}); | ||
``` | ||
You might wonder why not just do this? | ||
```js | ||
var getData = Promise.coroutine(function* (urlA, urlB) { | ||
var resultA = yield http.getAsync(urlA); | ||
var resultB = yield http.getAsync(urlB); | ||
}); | ||
``` | ||
The problem with the above is that the requests are not done in parallel. It will completely wait for request A to complete before even starting request B. In the array syntax both requests fire off at the same time in parallel. | ||
<hr> | ||
@@ -1456,0 +1506,0 @@ |
@@ -15,2 +15,3 @@ "use strict"; | ||
var browsers = { | ||
"internet explorer|Windows XP": ["7"], | ||
"internet explorer|Windows 7": ["8", "9", "10"], | ||
@@ -17,0 +18,0 @@ "internet explorer|Windows 8.1": ["11"], |
@@ -28,2 +28,3 @@ /** | ||
var util = require("./util.js"); | ||
var isArray = util.isArray; | ||
var errorObj = util.errorObj; | ||
@@ -65,6 +66,11 @@ var tryCatch1 = util.tryCatch1; | ||
if( !( maybePromise instanceof Promise ) ) { | ||
this._throw( new TypeError( | ||
"A value was yielded that could not be treated as a promise" | ||
) ); | ||
return; | ||
if( isArray( maybePromise ) ) { | ||
maybePromise = Promise.all( maybePromise ); | ||
} | ||
else { | ||
this._throw( new TypeError( | ||
"A value was yielded that could not be treated as a promise" | ||
) ); | ||
return; | ||
} | ||
} | ||
@@ -97,2 +103,2 @@ maybePromise._then( | ||
return PromiseSpawn; | ||
}; | ||
}; |
@@ -28,2 +28,3 @@ /** | ||
var util = require("./util.js"); | ||
var isArray = util.isArray; | ||
var errorObj = util.errorObj; | ||
@@ -65,6 +66,11 @@ var tryCatch1 = util.tryCatch1; | ||
if( !( maybePromise instanceof Promise ) ) { | ||
this._throw( new TypeError( | ||
"A value was yielded that could not be treated as a promise" | ||
) ); | ||
return; | ||
if( isArray( maybePromise ) ) { | ||
maybePromise = Promise.all( maybePromise ); | ||
} | ||
else { | ||
this._throw( new TypeError( | ||
"A value was yielded that could not be treated as a promise" | ||
) ); | ||
return; | ||
} | ||
} | ||
@@ -97,2 +103,2 @@ maybePromise._then( | ||
return PromiseSpawn; | ||
}; | ||
}; |
{ | ||
"name": "bluebird", | ||
"description": "Full featured Promises/A+ implementation with exceptionally good performance", | ||
"version": "0.9.11-0", | ||
"version": "0.9.11-1", | ||
"keywords": [ | ||
@@ -6,0 +6,0 @@ "promise", |
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
503406
89
9205