Author: admin

  • Node.js ZLIB

    The Node.js Zlib module is used to provide compression and decompression (zip and unzip) functionalities. It is implemented using Gzip and deflate/inflate. The zlib module can be accessed using: Compressing and decompressing a file can be done by piping the source stream data into a destination stream through zlib stream. Node.js ZLIB Example: Compress File…

  • 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: Parameters: 1) command: It specifies the command to run, with space-separated…

  • Node.js Process

    Node.js provides the facility to get process information such as process id, architecture, platform, version, release, uptime, upu usage etc. It can also be used to kill process, set uid, set groups, unmask etc. The process is a global object, an instance of EventEmitter, can be accessed from anywhere. Node.js Process Properties A list of…

  • 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…