https://github.com/loklaan/is-async-func
Check if a value is an async function, from ES2017 specification. Supports babel.
https://github.com/loklaan/is-async-func
async-functions es2017 type-checking
Last synced: about 2 months ago
JSON representation
Check if a value is an async function, from ES2017 specification. Supports babel.
- Host: GitHub
- URL: https://github.com/loklaan/is-async-func
- Owner: loklaan
- Created: 2017-04-02T08:38:10.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2022-12-06T20:40:28.000Z (almost 3 years ago)
- Last Synced: 2025-08-16T15:58:28.548Z (about 2 months ago)
- Topics: async-functions, es2017, type-checking
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/is-async-func
- Size: 245 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 8
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# is-async-func


[](https://npmjs.com/package/is-async-func)
[](https://travis-ci.org/loklaan/is-async-func)
[](https://codecov.io/gh/loklaan/is-async-func)Check if a value is an async function, from ES2017 specification
Supports runtime implementations, as well as babel transpiled code.
```js
const isAsyncFunction = require('is-async-func');isAsyncFunction(async function () {})
// trueisAsyncFunction(async function foo () {})
// trueisAsyncFunction(async () => {})
// trueconst foo = { async bar () {} }
isAsyncFunction(foo.bar)
// trueconst foo = { bar: async function () {} }
isAsyncFunction(foo.bar)
// trueconst foo = { bar: async () => {} }
isAsyncFunction(foo.bar)
// trueclass Foo () {
async bar () {}
}
isAsyncFunction((new Foo()).bar)
// true
```## Install
```shell
npm install is-async-func
# yarn add is-async-func
```## Should I use this?
For runtimes that support async/await, yes!
For transpiled async/await, probably! :grimacing:
The transpilation tests cover many different combinations of async declarations and babel transform presets, but the transpiled detection generally takes a hacky approach. Probably-definitely don't use this in hot code.## License
Licensed under the MIT License, Copyright © 2017 Lochlan Bunn.