Category: Node js

  • Node.js Buffers

    Node.js provides Buffer class to store raw data similar to an array of integers but corresponds to a raw memory allocation outside the V8 heap. Buffer class is used because pure JavaScript is not nice to binary data. So, when dealing with TCP streams or the file system, it’s necessary to handle octet streams. Buffer…

  • Node.js Child Process

    The Node.js child process module provides the ability to spawn child processes in a similar manner to popen(3). There are three major way to create child process: Node.js child_process.exec() method The child_process.exec() method runs a command in a console and buffers the output. Syntax: Parameters: 1) command: It specifies the command to run, with space-separated…

  • Node.js Debugger

    Node.js provides a simple TCP based protocol and built-in debugging client. For debugging your JavaScript file, you can use debug argument followed by the js file name you want to debug. Syntax: Example: If you make any error: If you make any error in your js file source code or provide a wrong path on…

  • Node.js TLS/SSL

    What is TLS/SSL TLS stands for Transport Layer Security. It is the successor to Secure Sockets Layer (SSL). TLS along with SSL is used for cryptographic protocols to secure communication over the web. TLS uses public-key cryptography to encrypt messages. It encrypts communication generally on the TCP layer. What is public-key cryptography In public-key cryptography,…

  • Node.js Crypto

    The Node.js Crypto module supports cryptography. It provides cryptographic functionality that includes a set of wrappers for open SSL’s hash HMAC, cipher, decipher, sign and verify functions. What is Hash A hash is a fixed-length string of bits i.e. procedurally and deterministically generated from some arbitrary block of source data. What is HMAC HMAC stands…

  • Node.js Net

    Node.js provides the ability to perform socket programming. We can create chat application or communicate client and server applications using socket programming in Node.js. The Node.js net module contains functions for creating both servers and clients. Node.js Net Example In this example, we are using two command prompts: server: File: net_server.js Open Node.js command prompt…

  • Node.js DNS

    The Node.js DNS module contains methods to get information of given hostname. Let’s see the list of commonly used DNS functions: Node.js DNS Example 1 Let’s see the example of dns.lookup() function. File: dns_example1.js Open Node.js command prompt and run the following code: Node.js DNS Example 2 Let’s see the example of resolve4() and reverse()…

  • Node.js Errors

    The Node.js applications generally face four types of errors: Node.js Errors Example 1 Let’s take an example to deploy standard JavaScript error – ReferenceError. File: error_example1.js Open Node.js command prompt and run the following code: Node.js Errors Example 2 File: timer2.js Open Node.js command prompt and run the following code:

  • Node.js Timer

    Node.js Timer functions are global functions. You don’t need to use require() function in order to use timer functions. Let’s see the list of timer functions. Set timer functions: Clear timer functions: Node.js Timer setInterval() Example This example will set a time interval of 1000 millisecond and the specified comment will be displayed after every…

  • Node.js OS

    Node.js OS provides some basic operating-system related utility functions. Let’s see the list generally used functions or methods. Index Method Description 1. os.arch() This method is used to fetch the operating system CPU architecture. 2. os.cpus() This method is used to fetch an array of objects containing information about each cpu/core installed: model, speed (in…