Node.js Hash Digest Method

Mayank Agarwal
Updated on 18-Aug-2021 09:26:54

2K+ Views

The Hash class is one of the many utility classes that is used for creating the hash digests of data. The hash.digest() method calculates all the data that needs to be hashed passed inside the hash function and returns them. If an encoding is defined, a string will be returned, else a buffer is returned.Syntaxhash.digest([encoding])ParametersIt takes a single parameter −encoding − This input parameter takes input for the encoding to be applied while calculating the hash.Example 1Create a file with the name "hashDigest.js" and copy the following code snippet. After creating the file, use the command "node hashDigest.js" to run ... Read More

Node.js V8 getHeapStatistics Method

Mayank Agarwal
Updated on 18-Aug-2021 09:22:25

905 Views

The v8.getHeapStatistics() method returns the statistics about a heap. The getHeapStatistics() method is a part of the v8 module that returns the details about the heap and size of the v8. The getHeapSpaceStatistics() gives stats based upon the spaces in a system, whereas the getHeapStatistics() method gives stats about the whole system.Syntaxv8.getHeapStatistics()ParametersSince it returns the space details/statistics about V8, it does not require any special input parameters. However, the value returned contains the following properties −total_heap_size − This field will return the total heap space size.total_heap_size_executable − This field will return the total heap size that is available for execution.total_physical_size ... Read More

Set Font Color and Style of Console in Node.js

Mayank Agarwal
Updated on 18-Aug-2021 09:20:38

907 Views

You can use the chalk module to customize the statements printed on the console.By using it, one can change the text font-color to any color. One can also change the font-style to Bold, Italic or Underlined. Also, you can highlight the printed text.Syntaxnpm install chalkExample 1Create a file "color.js" and copy the following code snippet. After creating the file, use the command "node color.js" to run this code.// Giving color to console statments // Importing the chalk module const chalk = require('chalk'); // Printing the text in blue color console.log(chalk.blue('Welcome to Tutorials Point !')); // Printing the ... Read More

Determine User IP Address in Node.js

Mayank Agarwal
Updated on 18-Aug-2021 09:18:27

520 Views

Node.js is a completely open source technology that runs on JavaScript runtime environment. When the users want to access a website or link, they connect with the link using their system IP. We can use the dns.lookup() method in Node to find the IP address of the current user.Syntaxdns.lookup(hostname, [options], callback)ParametersThe parameters are described below −hostname − This input parameter consists of the web link which is valid or active.options − Default is 0. It takes input for the IP type, i.e., 4 for Ipv4 and 6 for Ipv6.callback − Handles any error if it occursExample 1Create a file with ... Read More

Node.js Util Types isUint16Array Method

Mayank Agarwal
Updated on 18-Aug-2021 09:05:45

91 Views

The util.types.isUint16Array() method checks whether the passed value is a builtin Uint16Array instance or not. If the above condition is satisfied, it returns True, else False.Syntaxutil.types.isUint16Array(value)ParametersIt takes a single parameter −value − This input value takes input for the required parameter and checks if it's a Uint16Array instance or not.It returns True or False based upon the input value passed.Example 1Create a file with the name "isUint16Array.js" and copy the following code snippet. After creating the file, use the command "node isUint16Array.js" to run this code.// util.types.isUint16Array() Demo Example // Importing the util module const util = require('util'); ... Read More

Node.js util.types isNativeError Method

Mayank Agarwal
Updated on 18-Aug-2021 09:03:01

155 Views

The util.types.isNativeError() method checks whether the passed value is a built-in error type or not. If the above condition is satisfied, it returns True, else False. The error can be of any type.Syntaxutil.types.isNativeError(value)ParametersIt takes a single parameter −value − This input value takes input for the required parameter and checks if it's an error type or not.It returns True or False based upon the input value passed.Example 1Create a file with the name "isNativeError.js" and copy the following code snippet. After creating the file, use the command "node isNativeError.js" to run this code.// util.types.isNativeError() Demo Example // Importing the ... Read More

Node.js Util Types isInt8Array Method

Mayank Agarwal
Updated on 18-Aug-2021 08:57:53

89 Views

The util.types.isInt8Array() method checks whether the passed value is a built-in Int8Array instance or not. If the above condition is satisfied, it returns True, else False.Syntaxutil.types.isInt8Array(value)ParametersIt takes a single parameter −value − This input value takes input for the required parameter and checks if it's an Int8Array instance or not.It returns True or False based upon the input value passed.Example 1Create a file with the name "isInt8Array.js" and copy the following code snippet. After creating the file, use the command "node isInt8Array.js" to run this code.// util.types.isInt8Array() Demo Example // Importing the util module const util = require('util'); ... Read More

Node.js isAnyArrayBuffer Method

Mayank Agarwal
Updated on 18-Aug-2021 08:54:57

113 Views

The util.types.isAnyArrayBuffer() checks whether the passed value is an ArrayBuffer or a SharedArrayBuffer instance. It returns True if the above condition holds, else False.Syntaxutil.types.isAnyArrayBuffer(value)ParametersIt takes a single parameter −value − This input parameter takes input for the required datatype and checks if it's an ArrayBuffer or SharedArrayBuffer instance.It returns True or False based upon the input value passed.Example 1Create a file with the name "isArrayBuffer.js" and copy the following code snippet. After creating the file, use the command "node isArrayBuffer.js" to run this code// util.types.isAnyArrayBuffer() Demo Example // Importing the util module const util = require('util'); // Printing ... Read More

Node.js Util Types isFloat32Array Method

Mayank Agarwal
Updated on 18-Aug-2021 08:51:07

102 Views

The util.types.isFloat32Array() method checks whether the passed value is a builtin Float32Array instance or not. If the above condition is satisfied, it returns True, else False.Syntaxutil.types.isFloat32Array(value)ParametersIt takes a single parameter −value − This input value takes input for the required parameter and checks if it's a Float32-Array instance or not.It returns True or False based upon the input value passed.Example 1Create a file with the name – "isFloat32Array.js" and copy the following code snippet. After creating the file, use the command "node isFloat32Array.js" to run this code.// util.types.isFloat32Array() Demo Example // Importing the util module const util = require('util'); ... Read More

Node.js Util Types IsDate Method

Mayank Agarwal
Updated on 18-Aug-2021 08:45:58

637 Views

The util.types.isDate() method checks whether the passed value is a built-in Date instance or not. If the above condition is satisfied, it returns True, else False.Syntaxutil.types.isDate(value)ParametersIt takes a single parameter −value − This input value takes input for the required parameter and checks if it's a Date instance or not.It returns True or False based upon the input value passed.Example 1Create a file with the name "isDate.js" and copy the following code snippet. After creating the file, use the command "node isDate.js" to run this code.// util.types.isDate() Demo Example // Importing the util module const util = require('util'); ... Read More

Advertisements