.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / call-me-maybe / README.md
1 # call-me-maybe [![Build Status](https://travis-ci.org/limulus/call-me-maybe.svg?branch=master)](https://travis-ci.org/limulus/call-me-maybe)
2
3 Let your JS API users either give you a callback or receive a promise.
4
5 ## Usage
6
7 ```javascript
8 var maybe = require("call-me-maybe")
9
10 module.exports = function asyncFunc (cb) {
11   return maybe(cb, new Promise(function(resolve, reject) {
12     // ...
13   }))
14 }
15 ```
16
17 ## API
18
19 ### maybe(cb, promise)
20
21 If the callback `cb` is truthy, returns `undefined` and will call `cb` when `promise` is settled. The parameters passed to `cb` are standard error-first:
22
23   - If `promise` is fulfilled, then it is called with the result of the promise: `cb(null, result)`
24   - If `promise` is rejected, then it is called with the rejection error: `cb(err)`
25
26 If `cb` is falsey, then `promise` is retuned.