{"id":15365661,"url":"https://github.com/tunnckocore/is-callback-function","last_synced_at":"2025-04-15T09:53:07.684Z","repository":{"id":57277005,"uuid":"54200972","full_name":"tunnckoCore/is-callback-function","owner":"tunnckoCore","description":"Returns true if function is a callback. Checks its name is one of common-callback-names - callback, cb, cb_, callback_, next, done, they can be customized, those are default.","archived":false,"fork":false,"pushed_at":"2016-11-01T02:45:19.000Z","size":17,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-08T07:42:53.989Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tunnckoCore.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-03-18T12:54:14.000Z","updated_at":"2022-09-13T09:42:49.000Z","dependencies_parsed_at":"2022-08-26T12:33:12.922Z","dependency_job_id":null,"html_url":"https://github.com/tunnckoCore/is-callback-function","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tunnckoCore%2Fis-callback-function","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tunnckoCore%2Fis-callback-function/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tunnckoCore%2Fis-callback-function/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tunnckoCore%2Fis-callback-function/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tunnckoCore","download_url":"https://codeload.github.com/tunnckoCore/is-callback-function/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249048713,"owners_count":21204306,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-01T13:15:27.548Z","updated_at":"2025-04-15T09:53:07.665Z","avatar_url":"https://github.com/tunnckoCore.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# [is-callback-function][author-www-url] [![npmjs.com][npmjs-img]][npmjs-url] [![The MIT License][license-img]][license-url] [![npm downloads][downloads-img]][downloads-url] \n\n\u003e Returns true if function is a callback. Checks its name is one of [common-callback-names][] - callback, cb, cb_, callback_, next, done, they can be customized, these are default.\n\n[![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]\n\n## Install\n```\nnpm i is-callback-function --save\n```\n\n## Usage\n\u003e For more use-cases see the [tests](./test.js)\n\n```js\nconst isCallbackFunction = require('is-callback-function')\n```\n\n### [isCallbackFunction](index.js#L52)\n\u003e Check if given `fn` is callback function or not. Notice that \"async\" functions are not `is-callback-function`, they are [is-async-function][] - it may be consfusing, but they are different.\n\n**Params**\n\n* `fn` **{Function}**    \n* `names` **{Array}**    \n* `returns` **{Boolean}**  \n\n**Example**\n\n```js\nvar fs = require('fs')\nvar isCallback = require('is-callback-function')\nvar isAsync = require('is-async-function')\n\nconsole.log(isCallback(fs.readFile)) // =\u003e false\nconsole.log(isAsync(fs.readFile)) // =\u003e true\n\nconsole.log(isCallback(function (foo, bar, cb) {})) // =\u003e false\nconsole.log(isAsync(function (foo, bar, cb) {})) // =\u003e true\n\nconsole.log(isCallback(function callback (foo, bar) {})) // =\u003e true\nconsole.log(isAsync(function callback (foo, bar) {})) // =\u003e false\n\nconsole.log(isCallback(function named (foo, cb) {})) // =\u003e false\nconsole.log(isAsync(function named (foo, cb) {})) // =\u003e true\n\nconsole.log(isCallback(function named (foo) {})) // =\u003e false\nconsole.log(isAsync(function named (foo) {})) // =\u003e false\n\nconsole.log(isCallback(function foo (bar) {}, ['baz', 'foo', 'qux'])) // =\u003e true\nconsole.log(isAsync(function foo (bar, qux) {}, ['baz', 'qux', 'aaa'])) // =\u003e true\nconsole.log(isAsync(function foo (bar, qux) {}, ['baz', 'aaa'])) // =\u003e false\n```\n\n## Whaaat?!\n\u003e Need clarification? Both signatures are equal.\n\n- `is-callback-function` - checks the name of given function\n- `is-async-function` - checks the arguments names of given function\n\n## Related\n* [arr-includes](https://www.npmjs.com/package/arr-includes): Return true if any of passed values exists in array. Using [in-array][]. | [homepage](https://github.com/tunnckocore/arr-includes)\n* [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)\n* [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)\n* [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)\n* [in-array](https://www.npmjs.com/package/in-array): Return true if a value exists in an array. Faster than using… [more](https://www.npmjs.com/package/in-array) | [homepage](https://github.com/jonschlinkert/in-array)\n* [is-async-function](https://www.npmjs.com/package/is-async-function): Is function really asynchronous function? Trying to guess that based on check… [more](https://www.npmjs.com/package/is-async-function) | [homepage](https://github.com/tunnckocore/is-async-function)\n\n## Contributing\nPull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/tunnckoCore/is-callback-function/issues/new).  \nBut before doing anything, please read the [CONTRIBUTING.md](./CONTRIBUTING.md) guidelines.\n\n## [Charlike Make Reagent](http://j.mp/1stW47C) [![new message to charlike][new-message-img]][new-message-url] [![freenode #charlike][freenode-img]][freenode-url]\n\n[![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]\n\n[common-callback-names]: https://github.com/tunnckocore/common-callback-names\n[in-array]: https://github.com/jonschlinkert/in-array\n[is-async-function]: https://github.com/tunnckocore/is-async-function\n\n[npmjs-url]: https://www.npmjs.com/package/is-callback-function\n[npmjs-img]: https://img.shields.io/npm/v/is-callback-function.svg?label=is-callback-function\n\n[license-url]: https://github.com/tunnckoCore/is-callback-function/blob/master/LICENSE\n[license-img]: https://img.shields.io/npm/l/is-callback-function.svg\n\n[downloads-url]: https://www.npmjs.com/package/is-callback-function\n[downloads-img]: https://img.shields.io/npm/dm/is-callback-function.svg\n\n[codeclimate-url]: https://codeclimate.com/github/tunnckoCore/is-callback-function\n[codeclimate-img]: https://img.shields.io/codeclimate/github/tunnckoCore/is-callback-function.svg\n\n[travis-url]: https://travis-ci.org/tunnckoCore/is-callback-function\n[travis-img]: https://img.shields.io/travis/tunnckoCore/is-callback-function/master.svg\n\n[coveralls-url]: https://coveralls.io/r/tunnckoCore/is-callback-function\n[coveralls-img]: https://img.shields.io/coveralls/tunnckoCore/is-callback-function.svg\n\n[david-url]: https://david-dm.org/tunnckoCore/is-callback-function\n[david-img]: https://img.shields.io/david/tunnckoCore/is-callback-function.svg\n\n[standard-url]: https://github.com/feross/standard\n[standard-img]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg\n\n[author-www-url]: http://www.tunnckocore.tk\n[author-www-img]: https://img.shields.io/badge/www-tunnckocore.tk-fe7d37.svg\n\n[keybase-url]: https://keybase.io/tunnckocore\n[keybase-img]: https://img.shields.io/badge/keybase-tunnckocore-8a7967.svg\n\n[author-npm-url]: https://www.npmjs.com/~tunnckocore\n[author-npm-img]: https://img.shields.io/badge/npm-~tunnckocore-cb3837.svg\n\n[author-twitter-url]: https://twitter.com/tunnckoCore\n[author-twitter-img]: https://img.shields.io/badge/twitter-@tunnckoCore-55acee.svg\n\n[author-github-url]: https://github.com/tunnckoCore\n[author-github-img]: https://img.shields.io/badge/github-@tunnckoCore-4183c4.svg\n\n[freenode-url]: http://webchat.freenode.net/?channels=charlike\n[freenode-img]: https://img.shields.io/badge/freenode-%23charlike-5654a4.svg\n\n[new-message-url]: https://github.com/tunnckoCore/ama\n[new-message-img]: https://img.shields.io/badge/ask%20me-anything-green.svg","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftunnckocore%2Fis-callback-function","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftunnckocore%2Fis-callback-function","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftunnckocore%2Fis-callback-function/lists"}