
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 266 Articles for Node.js

139 Views
The stringDecoder.end() method will return any remaining input that is left in the internal buffer as a string. Bytes that are left incomplete and represent UTF-8 and UTF-16 characters are replaced with the substitution characters appropriate for character encoding.StringDecoder.write() method is called before returning the remaining input if any buffer argument is provided. The stringDecoder can be reused for taking new inputs once the end() method is called.SyntaxstringDecoder.end( [buffer] )Parametersbuffer - This parameter takes input for the bytes to decode. It can take buffer, TypedArray or DataView as the input parameters.Example 1Create a file with the name "end.js" and copy ... Read More

3K+ Views
The retry_strategy is a function that receives objects as parameters including the retry attempt, total_retry_time that indicates the time passed after it was connected the last time, the error due to which the connection was lost, and the number of times_connected in total.If a number is returned from this function, the next retry will take place after that time only in milliseconds and if you send a non-number, no further retry will take place.Syntaxretry_strategy: funciton(options)Example 1Create a file with the name "retryStrategy.js" and copy the following code. After creating the file, use the command "node retryStrategy.js" to run this code ... Read More

152 Views
This process.noDeprecation() method states whether the --no- Deprecation flag is set or not on the current Node.js project. This Boolean flag controls whether the deprecation warning messages are printed to stderr or not. Setting this flag as True will silence all the deprecation warnings.Syntaxprocess.noDeprecation( )Example 1Create a file with the name "noDeprecation.js" and copy the following code. After creating the file, use the command "node noDeprecation.js" to run this code as shown in the example below// process.noDeprecation() Demo Example // Importing the process module const process = require('process'); // Printing noDeprecation default value console.log(process.noDeprecation);Output 1undefined Output 2trueExample 2Let's ... Read More

114 Views
The dns.resolvePtr() method uses the DNS protocol to resolve the pointer records (PTR Records) for the hostname. The addresses argument passed to the callback function will contain the reply records as an array of strings.Syntaxdns.resolvePtr(hostname, callback)Parametershostname - This parameter takes the input for the hostname to be resolved.callback - This function will catch errors, if any.records − Returns PTR records for the hostname.Example 1Create a file with the name "resolvePtr.js" and copy the following code. After creating the file, use the command "node resolvePtr.js" to run this code as shown in the example below// dns.resolvePtr() Demo Example // Importing ... Read More

101 Views
The dnsPromises.resolveSoa() method uses the DNS protocol to resolve the Start of Authority records (SOA Records) for the hostname. On success, the promise is resolved with the following propertiesnsnamehostmasterserialrefreshretryexpireminttlSyntaxdnsPromises.resolveSoa( hostname )Parametershostname - This parameter takes the input for the hostname to be resolved.Example 1Create a file with the name "resolveSoa.js" and copy the following code. After creating the file, use the command "node resolveSoa.js" to run this code as shown in the example below// dns.resolveSoa() Demo Example // Importing the dns module const dns = require('dns'); const dnsPromises = dns.promises; // Passing IP to find the hostname TXT ... Read More

2K+ Views
The client.end(flush) method forcibly closes all the connection to the Redis server without waiting until all the replies have been parsed. This method just closes all the connection and ongoing streaming between the Node and Redis server. If you want to exit cleanly, you should use client.quit() method.Syntaxclient.end(flush)Parametersflush - This input parameter will hold a Boolean value that will indicate whether to close a connection or not.Example 1Create a file with the name "clientEnd.js" and copy the following code. After creating the file, use the command "node clientEnd.js" to run this code as shown in the example below −// client.end() ... Read More

668 Views
Node.js Redis offers certain properties which can be used as per your usecase. One such property is detect_buffers.If this property is set to True, then the replies that are sent to the callbacks are sent as buffers.This option lets you switch between the buffer and strings based upon this single command basis.This property does not work with pub-sub mode.SyntaxdetectBuffers: trueExample 1Create a file with the name "detectBuffers.js" and copy the following code. After creating the file, use the command "node detectBuffers.js" to run this code, as shown in the example below:// detect_buffers Property Demo Example // Importing the redis ... Read More

2K+ Views
The chalk module is a third-party library that can be used for styling of texts. It allows the users to create their own themes in a Node.js project.This module helps the users to customize the response messages with different colors as per the preferences.It also improves the readability by providing colors and makes it easier to detect warnings and errors.Installationnpm install chalkExample 1Create a file with the name "chalk.js" and copy the following code. After creating the file, use the command "node chalk.js" to run this code as shown in the example below −// Importing the chalk module const chalk=require("chalk"); ... Read More

734 Views
The 'beforeExit' event is called when Node.js empties its event loop and has no other work to schedule. The Node.js process exits normally when there is no work scheduled but a listener registered on the 'before exit' event can make async calls and thereby cause the Node.js process to continue.Example 1Create a file with the name "beforeExit.js" and copy the following code. After creating the file, use the command "node beforeExit.js" to run this code as shown in the example below −// process 'beforeExit' Demo Example // Importing the process module const process = require('process'); // Calling the ... Read More

106 Views
The diffieHellman.getGenerator() method returns the Diffie-Hellman generator in the specified encoding. A string is returned in case an encoding is passed, else a buffer is returned.SyntaxdiffieHellman.getGenerator([encoding])Parametersencoding - This parameter specifies the encoding of the return value.Example 1Create a file with the name "generator.js" and copy the following code. After creating the file, use the command "node generator.js" to run this code as shown in the example below:// diffieHellman.getPrime() Demo Example // Importing cryptoDiffieHellman from the crypto module const { createDiffieHellman } = require('crypto'); // Initializing the diffieHellman object const dh = createDiffieHellman(512); // Generate DiffieHellman's Generator ... Read More