|
10 | 10 | /**
|
11 | 11 | * > Trying to guess is function asynchronous (callback) function or not.
|
12 | 12 | *
|
13 |
| - * @param {Function} `fn` |
14 |
| - * @param {Array} `ignores` |
15 |
| - * @param {Number} `max` |
| 13 | + * **Example** |
| 14 | + * |
| 15 | + * ```js |
| 16 | + * var fs = require('fs') |
| 17 | + * var isAsyncFn = require('is-async-function') |
| 18 | + * |
| 19 | + * console.log(isAsyncFunction(fs.readFile)) // => true |
| 20 | + * console.log(isAsyncFunction(fs.stat)) // => true |
| 21 | + * |
| 22 | + * console.log(isAsyncFunction(fs.readFileSync)) // => false |
| 23 | + * console.log(isAsyncFunction(fs.statSync)) // => false |
| 24 | + * |
| 25 | + * // or pass custom names to recognize as `async` |
| 26 | + * console.log(isAsyncFunction(fs.stat, ['cb'])) // => false |
| 27 | + * console.log(isAsyncFunction(fs.readFile, ['callback', 'next'])) |
| 28 | + * // => false, because fs.readFile uses `callback_` |
| 29 | + * ``` |
| 30 | + * |
| 31 | + * @param {Function} `fn` Is this `fn` a callback function. |
| 32 | + * @param {Array} `ignores` Arguments names, default are `['callback', 'callback_', 'done', 'next', 'cb']`. |
| 33 | + * @param {Number} `max` How many characters to cut from `fn`s toString, default `250`. Passed to [function-arguments][]. |
16 | 34 | * @return {Boolean}
|
17 | 35 | * @api public
|
18 | 36 | */
|
19 | 37 |
|
20 |
| -module.exports = function isAsyncFn (fn, ignores, max) { |
| 38 | +module.exports = function isAsyncFunction (fn, ignores, max) { |
21 | 39 | if (typeof fn !== 'function') {
|
22 | 40 | throw new TypeError('is-async-function expect a function')
|
23 | 41 | }
|
|
0 commit comments