Category: 01. Tutorial

  • Node.js StringDecoder

    The Node.js StringDecoder is used to decode buffer into string. It is similar to buffer.toString() but provides extra support to UTF. You need to use require(‘string_decoder’) to use StringDecoder module. Node.js StringDecoder Methods StringDecoder class has two methods only. Method Description decoder.write(buffer) It is used to return the decoded string. decoder.end() It is used to…

  • Node.js Path

    The Node.js path module is used to handle and transform files paths. This module can be imported by using the following syntax: Syntax: Node.js Path Methods Let’s see the list of methods used in path module: Index Method Description 1. path.normalize(p) It is used to normalize a string path, taking care of ‘..’ and ‘.’…

  • Node.js File System (FS)

    In Node.js, file I/O is provided by simple wrappers around standard POSIX functions. Node File System (fs) module can be imported using following syntax: Syntax: Node.js FS Reading File Every method in fs module has synchronous and asynchronous forms. Asynchronous methods take a last parameter as completion function callback. Asynchronous method is preferred over synchronous…

  • Node.js Streams

    Streams are the objects that facilitate you to read data from a source and write data to a destination. There are four types of streams in Node.js: Each type of stream is an Event emitter instance and throws several events at different times. Following are some commonly used events: Node.js Reading from stream Create a…

  • 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:PlayNextMute Current Time 0:11 / Duration 18:10 Loaded: 5.14%  Fullscreen Parameters: 1) command: It specifies…

  • 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:PauseNextMute Current Time 0:01 / Duration 18:10 Loaded: 2.94%  Fullscreen If you make any error in your js file source code…

  • 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.jsPlayNextMute Current Time 0:02 / Duration 18:10…