Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

node.js

What is deflateRaw() in Node.js?

Adnan Abbas

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

The zlib module in Node.js provides compression and decompression functionality utilizing Gzip, Deflate/Inflate, and Brotli.

It can be accessed in your program with:

const zlib = require('zlib');

deflateRaw() is a function of the zlib module, which allows compressing a stream of data.

Syntax

zlib.deflateRaw( buffer, options, callback )

Parameters

  • buffer is the data to be decompressed. It can be of any type, such as Buffer, TypedArray, DataView, ArrayBuffer, or string.

  • options is an optional argument used to provide options to the zlib classes.

  • callback is the call-back function that is executed.

Return value

The deflateRaw() method returns compressed data.

Example

In the following example, we provide an input string to the deflateRaw() method, which compresses the input in line 8.

// Including zlib module
const zlib = require("zlib");
  
//input declaration
var input = "Educative Inc.";
  
// Calling zlib.deflateRaw to compress data
zlib.deflateRaw(input, (err, buffer) => {
  console.log("Compressed data: ",buffer.toString('utf8'));
  });

RELATED TAGS

node.js

CONTRIBUTOR

Adnan Abbas
Copyright ©2022 Educative, Inc. All rights reserved

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring