
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 33676 Articles for Programming

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

158 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

117 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

104 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

671 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

746 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

107 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

198 Views
The dnsPromises.resolveAny() method uses the DNS protocol to resolve all records (this is also known as ANY or * query). The promise is resolved with an array containing various types of records.TypeProperties'A'IPv4 address'AAAA'IPv6 address'Any'Any RecordsMXMail Exchange RecordsNAPTRName authority pointer recordsNSName server recordsPTRPointer RecordsSOAStart of Authority RecordsSRVService RecordsTXTText RecordsCNAMECanonical Name RecordsSyntaxdnsPromises.resolveAny(hostname)Parametershostname - This parameter takes input for the hostname to be resolved.Example 1Create a file with the name "resolveAny.js" and copy the following code. After creating the file, use the command "node resolveAny.js" to run this code, as shown in the example below −// Node.js program to demonstrate the // dnsPromises.resolveAny() method ... Read More