Fix bluebird formatting

This commit is contained in:
Rico Sta. Cruz 2015-04-18 02:58:04 +08:00
parent 8fcd337179
commit 844a802897
1 changed files with 11 additions and 17 deletions

View File

@ -3,29 +3,28 @@ title: bluebird.js
layout: default layout: default
--- ---
See [promise](promise.html). Also see the [promise cheatsheet](promise.html).
{:.center.brief-intro}
### Consuming promises
```js ```js
promise promise
.then(okFn, errFn) .then(okFn, errFn)
.spread(okFn, errFn) #* .spread(okFn, errFn) //*
.catch(errFn) .catch(errFn)
.catch(TypeError, errFn) #* .catch(TypeError, errFn) //*
.finally(fn) #* .finally(fn) //*
.map(function (e) { ... }) .map(function (e) { ... })
.each(function (e) { ... }); .each(function (e) { ... })
``` ```
### Handling simultaneous promises ### Simultaneous promises (array)
```js ```js
Promise.any(promises) // succeeds if one succeeds first Promise.any(promises) // succeeds if one succeeds first
.then(...) .then(...)
``` ```
or Objects ### Simultaneous promises (object)
```js ```js
Promise.props({ Promise.props({
@ -38,12 +37,6 @@ Promise.props({
}) })
``` ```
### Consuming arrays
```js
getFiles()
```
### Chain of promises ### Chain of promises
```js ```js
@ -51,6 +44,7 @@ Promise.try(function () {
if (err) throw new Error("boo"); if (err) throw new Error("boo");
return result; return result;
}); });
```
### Working with node-style functions ### Working with node-style functions
@ -59,6 +53,6 @@ var readFile = Promise.promisify(fs.readFile);
var fs = Promise.promisifyAll(require('fs')); var fs = Promise.promisifyAll(require('fs'));
``` ```
### References ## References
* https://github.com/petkaantonov/bluebird/blob/master/API.md * [Bluebird API](https://github.com/petkaantonov/bluebird/blob/master/API.md) (github.com)