- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Node.js β util.types.isAsyncFunction() Method
The util.types.isAsyncFunction() checks whether the passed value is an async function or not. If the above condition holds, it returns True, else False.
Syntax
util.types.isAsyncFunction(value)
Parameters
It takes only one parameter −
value − This input value takes input for the required parameter and checks if it is an async function or not.
It returns True or False based upon the input value passed.
Example 1
Create a file with the name "isAsyncFunction.js" and copy the following code snippet. After creating the file, use the command "node isAsyncFunction.js" to run this code.
// util.types.isArgumentsObject() Demo Example // Importing the util module const util = require('util'); // Passing empty function to check if its async console.log("1. " + util.types.isAsyncFunction(function f() {})); // Passing empty async function to check console.log("2. " + util.types.isAsyncFunction(async function f1() {}));
Output
C:\home
ode>> node isAsyncFunction.js 1. false 2. true
Example 2
// util.types.isArgumentsObject() Demo Example // Importing the util module const util = require('util'); // An async function async function myFunction() { console.log("Async function - Welcome to TutorialsPoint"); } // An async/await function async function fun1() { const result = await 1; console.log("Await function"); } // Passing async function to check if its async console.log("1. " + util.types.isAsyncFunction(myFunction())) // Passing async + await function console.log("2. " + util.types.isAsyncFunction(fun1()))
Output
C:\home
ode>> node isAsyncFunction.js Async function - Welcome to TutorialsPoint 1. false 2. false Await function
Advertisements