Socket
Socket
Sign inDemoInstall

is-async-function

Package Overview
Dependencies
2
Maintainers
2
Versions
15
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    is-async-function

Determine if a function is a native async function.


Version published
Weekly downloads
9.9M
increased by0.24%
Maintainers
2
Install size
49.8 kB
Created
Weekly downloads
 

Package description

What is is-async-function?

The is-async-function npm package is designed to help developers determine if a given function is an asynchronous function. This can be particularly useful in scenarios where the behavior of code needs to be altered based on whether a function is asynchronous or not, such as in dynamic function execution, middleware handling, or in libraries that need to support both synchronous and asynchronous operations.

What are is-async-function's main functionalities?

Checking if a function is asynchronous

This feature allows you to check if a given function is an async function. The package exports a single function that takes one argument (the function to check) and returns a boolean indicating whether the function is asynchronous. This is useful for dynamically handling functions based on their nature.

const isAsyncFunction = require('is-async-function');

async function foo() {};
console.log(isAsyncFunction(foo)); // true

function bar() {};
console.log(isAsyncFunction(bar)); // false

Other packages similar to is-async-function

Changelog

Source

v2.0.0 - 2022-04-11

Commits

  • [Breaking] v2 implementation and tests d79a37e
  • Initial commit 456defc
  • npm init d35b611
  • Only apps should have lockfiles 5920874

Readme

Source

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

Keywords

FAQs

Last updated on 12 Apr 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc