Mayank Agarwal has Published 373 Articles

Node.js – forEach() Method

Mayank Agarwal

Mayank Agarwal

Updated on 17-Aug-2021 12:18:55

5K+ Views

The forEach() method in Node.js is used for iterating over a set of given array items. One can iterate over all the values of the array one-by-one using the forEach array loop.SyntaxarrayName.forEach(function)Parametersfunction − The function takes input for the method that will be executed.arrayName − Array that will be iterated.Example 1Create a ... Read More

Node.js – hmac.update() Method

Mayank Agarwal

Mayank Agarwal

Updated on 17-Aug-2021 12:18:14

695 Views

The Hmac class is one of the many utility classes that is used for creating the cryptographic HMAC digests. The Hmac.update() method is used for updating the Hmac content with the data passed. If encoding is not provided and the data is in string format, then the default encoding 'utf8' ... Read More

Node.js – util.deprecate() method

Mayank Agarwal

Mayank Agarwal

Updated on 17-Aug-2021 12:12:43

380 Views

The util.deprecate() method wraps fn (that may be a function or class) in such a way that it is marketed as a deprecated method. The util.deprecate() method returns a function that emits a DeprecationWarning. This warning is printed to the stderr when the function is called the first time. The ... Read More

Node.js – util.types.isBoxedPrimitive() Method

Mayank Agarwal

Mayank Agarwal

Updated on 17-Aug-2021 11:42:45

106 Views

The util.types.isBoxedPrimitive() method checks whether the passed value is a built-in Primitive object or not. If the above condition is satisfied, it returns True, else False. Primitive object includes new Boolean(), new String() or Object(Symbol()).Syntaxutil.types.isBoxedPrimitive(value)Parametersvalue − This input value takes input for the required parameter and checks if it's a Float32-Array ... Read More

Node.js – Base64 Encoding & Decoding

Mayank Agarwal

Mayank Agarwal

Updated on 16-Aug-2021 12:18:20

7K+ Views

The buffer object can be encoded and decoded into Base64 string. The buffer class can be used to encode a string into a series of bytes. The Buffer.from() method takes a string as an input and converts it into Base64.The converted bytes can be changed again into String. The toString() ... Read More

Node.js – util.format() method

Mayank Agarwal

Mayank Agarwal

Updated on 16-Aug-2021 12:14:39

2K+ Views

The util.format() method returns a formatted string that will use the first argument as a printf like format string. This format can also contain zero or more format specifiers. These specifiers can be replaced with the converted value from the corresponding argument.Following are some of the formatted specifiers:%s − String will ... Read More

Node.js – util.callbackify() Method

Mayank Agarwal

Mayank Agarwal

Updated on 16-Aug-2021 12:12:32

594 Views

The util.callbackify() method takes an async function as a parameter (or a function with Promise) and returns a function with the callback style. The callback will hold the rejection reason as the first parameter (or null in case of Promise) and the resolved value as the second parameter.Syntaxutil.callbackify(function)Parametersfunction − The input ... Read More

Node.js – hmac.digest() Method

Mayank Agarwal

Mayank Agarwal

Updated on 16-Aug-2021 12:10:41

1K+ Views

The Hmac class is one of the many utility classes that is used for creating the cryptographic HMAC digests. The Hmac.digest() method is used for calculating all the data that is updated using the Hmac.update() method. If encoding is provided, a string will be returned, else a buffer is returned.Syntaxhmac.digest( ... Read More

Node.js – hash.copy() Method

Mayank Agarwal

Mayank Agarwal

Updated on 16-Aug-2021 12:08:01

303 Views

The Hash class is one of the many utility classes that is used for creating the hash digests of data. The hash.copy() method creates a new Hash object that will contain a deep copy of the internal state of the current hash object.Syntaxhash.copy([options])Parametersoptions −This input parameter takes input to control ... Read More

Node.js – util.inherits() Method

Mayank Agarwal

Mayank Agarwal

Updated on 16-Aug-2021 12:04:46

556 Views

The util.inherits() method basically inherits the methods from one construct to another. This prototype will be set to a new object to that from the superConstructor.By doing this, we can mainly add some validations to the top of Object.setPrototypeOf(constructor.prototype, superConstructor.prototype).Syntaxutil.inherits(constructor, superConstructor)ParametersThe parameters are described below -constructor − This is a function ... Read More

Advertisements