is-async-function

Determine if a function is a native async function.

  • Types
  • ESM
  • CJS
License
MIT
Install Size
23.3 kB(348.8 kB)
Vulns
0
Published

Get started

$npm install is-async-function
$pnpm add is-async-function
$yarn add is-async-function
$bun add is-async-function
$deno add npm:is-async-function
$vlt install is-async-function
$vp add is-async-function

You might not need this dependency.

You can use typeof and Object.prototype.toString.call to check if it's an async function

Example:
const isAsyncFunction = (obj) => typeof obj === "function" && Object.prototype.toString.call(obj) === "[object AsyncFunction]"

Readme

is-async-function Version Badge

github actions coverage dependency status dev dependency status License Downloads

npm badge

Is this a native async function?

Example

var isAsyncFunction = require('is-async-function');
assert(!isAsyncFunction(function () {}));
assert(!isAsyncFunction(null));
assert(!isAsyncFunction(function* () { yield 42; return Infinity; }));
assert(isAsyncFunction(async function () {}));

Tests

Simply clone the repo, npm install, and run npm test