Skip to content

Commit e09ab8b

Browse files
author
tunnckoCore
committed
cleanup and update metadata
1 parent bc7d85e commit e09ab8b

File tree

3 files changed

+37
-16
lines changed

3 files changed

+37
-16
lines changed

README.md

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# [is-async-function][author-www-url] [![npmjs.com][npmjs-img]][npmjs-url] [![The MIT License][license-img]][license-url]
22

3-
> Is function really asynchronous (callback) function? Trying to guess that based on check if `callback`, `cb`, `done`, `next` exists as function arguments names or you can pass your custom.
3+
> Is function really asynchronous function? Trying to guess that based on check if [common-callback-names][] exists as function arguments names or you can pass your custom.
44
55
[![code climate][codeclimate-img]][codeclimate-url] [![standard code style][standard-img]][standard-url] [![travis build status][travis-img]][travis-url] [![coverage status][coveralls-img]][coveralls-url] [![dependency status][david-img]][david-url]
66

@@ -16,14 +16,13 @@ npm i is-async-function --save
1616
const isAsyncFunction = require('is-async-function')
1717
```
1818

19-
### [isAsyncFunction](index.js#L38)
19+
### [isAsyncFunction](index.js#L37)
2020
> Trying to guess is function asynchronous (callback) function or not.
2121
2222
**Params**
2323

2424
* `fn` **{Function}**: Is this `fn` a callback function.
25-
* `ignores` **{Array}**: Arguments names, default are `['callback', 'callback_', 'done', 'next', 'cb']`.
26-
* `max` **{Number}**: How many characters to cut from `fn`s toString, default `250`. Passed to [function-arguments][].
25+
* `names` **{Array}**: Arguments names, default are [common-callback-names][].
2726
* `returns` **{Boolean}**
2827

2928
**Example**
@@ -45,10 +44,13 @@ console.log(isAsyncFunction(fs.readFile, ['callback', 'next']))
4544
```
4645

4746
## Related
47+
* [common-callback-names](https://www.npmjs.com/package/common-callback-names): List of common callback names - callback, cb, callback_, next, done. | [homepage](https://github.com/tunnckocore/common-callback-names)
4848
* [fn-args](https://www.npmjs.com/package/fn-args): Get the arguments of a function | [homepage](https://github.com/sindresorhus/fn-args)
4949
* [fn-name](https://www.npmjs.com/package/fn-name): Get the name of a named function | [homepage](https://github.com/sindresorhus/fn-name)
5050
* [function-arguments](https://www.npmjs.com/package/function-arguments): Get arguments of a function, useful for and used in dependency injectors.… [more](https://www.npmjs.com/package/function-arguments) | [homepage](https://github.com/tunnckocore/function-arguments)
5151
* [get-fn-name](https://www.npmjs.com/package/get-fn-name): Get function name with strictness and correctness in mind. Also works for… [more](https://www.npmjs.com/package/get-fn-name) | [homepage](https://github.com/tunnckocore/get-fn-name)
52+
* [is-callback-function](https://www.npmjs.com/package/is-callback-function): Returns true if function is a callback. Checks its name is one… [more](https://www.npmjs.com/package/is-callback-function) | [homepage](https://github.com/tunnckocore/is-callback-function)
53+
* [parse-function](https://www.npmjs.com/package/parse-function): Parse a function, arrow function or string to object with name, args,… [more](https://www.npmjs.com/package/parse-function) | [homepage](https://github.com/tunnckocore/parse-function)
5254

5355
## Contributing
5456
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/tunnckoCore/is-async-function/issues/new).
@@ -58,9 +60,8 @@ But before doing anything, please read the [CONTRIBUTING.md](./CONTRIBUTING.md)
5860

5961
[![tunnckoCore.tk][author-www-img]][author-www-url] [![keybase tunnckoCore][keybase-img]][keybase-url] [![tunnckoCore npm][author-npm-img]][author-npm-url] [![tunnckoCore twitter][author-twitter-img]][author-twitter-url] [![tunnckoCore github][author-github-img]][author-github-url]
6062

61-
[arr-includes]: https://github.com/tunnckocore/arr-includes
6263
[function-arguments]: https://github.com/tunnckocore/function-arguments
63-
[isarray]: https://github.com/juliangruber/isarray
64+
[common-callback-names]: https://github.com/tunnckocore/common-callback-names
6465

6566
[npmjs-url]: https://www.npmjs.com/package/is-async-function
6667
[npmjs-img]: https://img.shields.io/npm/v/is-async-function.svg?label=is-async-function

index.js

+5-6
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,20 @@
2929
* ```
3030
*
3131
* @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][].
32+
* @param {Array} `names` Arguments names, default are [common-callback-names][].
3433
* @return {Boolean}
3534
* @api public
3635
*/
3736

38-
module.exports = function isAsyncFunction (fn, ignores, max) {
37+
module.exports = function isAsyncFunction (fn, names) {
3938
if (typeof fn !== 'function') {
4039
throw new TypeError('is-async-function expect a function')
4140
}
4241

4342
var defaults = ['callback', 'callback_', 'done', 'next', 'cb']
44-
var args = require('function-arguments')(fn, max || 250)
43+
var args = require('function-arguments')(fn)
4544

46-
ignores = require('isarray')(ignores) ? ignores : defaults
47-
return require('arr-includes')(args, ignores)
45+
names = require('isarray')(names) ? names : defaults
46+
return require('arr-includes')(args, names)
4847
}
4948

package.json

+25-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "is-async-function",
33
"version": "1.1.1",
4-
"description": "Is function really asynchronous (callback) function? Trying to guess that based on check if `callback`, `cb`, `done`, `next` exists as function arguments names or you can pass your custom.",
4+
"description": "Is function really asynchronous function? Trying to guess that based on check if [common-callback-names][] exists as function arguments names or you can pass your custom.",
55
"repository": "tunnckoCore/is-async-function",
66
"author": "Charlike Mike Reagent <@tunnckoCore> (http://www.tunnckocore.tk)",
77
"precommit.silent": true,
@@ -27,7 +27,24 @@
2727
"index.js"
2828
],
2929
"keywords": [
30-
"is-async-function"
30+
"assume",
31+
"async",
32+
"callback",
33+
"cb",
34+
"check",
35+
"common",
36+
"done",
37+
"exist",
38+
"fn",
39+
"func",
40+
"function",
41+
"is",
42+
"is-async-function",
43+
"names",
44+
"next",
45+
"really",
46+
"util",
47+
"validate"
3148
],
3249
"verb": {
3350
"run": true,
@@ -41,11 +58,15 @@
4158
"function-arguments",
4259
"fn-args",
4360
"get-fn-name",
44-
"fn-name"
61+
"fn-name",
62+
"parse-function",
63+
"is-callback-function",
64+
"common-callback-names"
4565
]
4666
},
4767
"reflinks": [
48-
"function-arguments"
68+
"function-arguments",
69+
"common-callback-names"
4970
],
5071
"lint": {
5172
"reflinks": true

0 commit comments

Comments
 (0)