Mayank Agarwal has Published 380 Articles

crypto.privateDecrypt() Method in Node.js

Mayank Agarwal

Mayank Agarwal

Updated on 20-May-2021 13:36:53

1K+ Views

The crypto.privateDecrypt() is used for decrypting the given data content by using a private key passed in the parameter that was previously encrypted using the corresponding public key with crypto.publicEncrypt() method.Syntaxcrypto.privateDecrypt(privateKey, buffer)ParametersThe above parameters are described as below −key – It can contain the below 5 types of data of the ... Read More

Stream writable.writableObjectMode Property in Node.js

Mayank Agarwal

Mayank Agarwal

Updated on 20-May-2021 13:33:59

144 Views

The writable.writableObjectMode property is used for getting the objectMode property of the given writable Stream. The property will return 'true' if the object mode is set, else 'false' will be returned.Syntaxwriteable.writableObjectModeExampleCreate a file with name – writableObjectMode.js and copy the below code snippet. After creating file, use the following command ... Read More

Stream writable.writableLength Property in Node.js

Mayank Agarwal

Mayank Agarwal

Updated on 20-May-2021 13:33:30

155 Views

The writable.writableLength property is used for displaying the number of bytes or objects which are there in the queue that are ready to be written. This is used for inspecting the data as per the status from highWaterMark.Syntaxwriteable.writableLengthExample 1Create a file with name – writableLength.js and copy the below code ... Read More

Stream writable.cork() and uncork() Method in Node.js

Mayank Agarwal

Mayank Agarwal

Updated on 20-May-2021 13:30:16

474 Views

The writable.cork() method is used for forcing all the written data to be buffered inside a memory. This buffered data will only be removed from the buffer memory after stream.uncork() or stream.end() method have been called.Syntaxcork()writeable.cork()uncork()writeable.uncork()ParametersSince it buffers the written data. Only parameter that's needed will be the writable data.ExampleCreate ... Read More

urlObject.auth() Method in Node.js

Mayank Agarwal

Mayank Agarwal

Updated on 20-May-2021 13:29:12

75 Views

The auth() property defines the username and password portion of any URL, also called as userInfo. The string and username are separated by a colon ( : ).SyntaxurlOject.auth()ParametersSince it retuns only the username and password from a URL, it does not required any input parameters.ExampleCreate a file with name – ... Read More

send(), sendStatus() and json() method in Node.js

Mayank Agarwal

Mayank Agarwal

Updated on 20-May-2021 13:28:45

4K+ Views

The send() and json() functions are used for sending the response to the client directly from the server. The send() method will send the data in a string format, whereas the json() function will send the same in JSON format. The sendStatus() method is used for sending the HTTP request ... Read More

script.createCachedData() Method in Node.js

Mayank Agarwal

Mayank Agarwal

Updated on 20-May-2021 13:24:12

115 Views

The script.createCachedData() method is used for creating a code cache that will be used along with the cachedData option of the script constructor. This cachedData can be called multiple number of times without latency. This method is an inbuilt programming interface from the 'script' module.Syntaxscript.createCachedData()ParametersSince it only caches the data. ... Read More

Reading a text file into an Array in Node.js

Mayank Agarwal

Mayank Agarwal

Updated on 20-May-2021 13:23:16

5K+ Views

We can read a text file and return its content as an Array using node.js. We can use this array content to either process its lines or just for the sake of reading. We can use the 'fs' module to deal with the reading of file. The fs.readFile() and fs.readFileSync() ... Read More

process.env() Method in Node.js

Mayank Agarwal

Mayank Agarwal

Updated on 20-May-2021 13:22:48

345 Views

The process.argv() method is used for getting the user environment object. This object will contain all the information about the environment on which this command is being executed.Syntaxprocess.env()ParametersSince it returns an object for the user environment. It does not need any inputs from the user as such.ExampleCreate a file with ... Read More

process.cpuUsage() Method in Node.js

Mayank Agarwal

Mayank Agarwal

Updated on 20-May-2021 13:18:00

1K+ Views

The process.argv() method is used for getting the user and its cpu usage for the current running process. The data is returned in an object with the properties user and system. The values obtained are in microseconds, i.e.10^-6 seconds. The values returned may be greater than the actual elapsed time ... Read More

Advertisements