Zlib
is a built-in module in Node.js that provides compression or decompression properties on texts and buffers in a program.
We use the zlib.createDeflateRaw()
module to create a new createDeflateRaw()
module was added in version v0.5.8 of Node.js.
zlib.createDeflateRaw( options )
The function accepts only a single parameter that specifies the different options of a Zlib
object. It returns the created DeflateRaw
object.
We can implement the createDeflateRaw()
module in the program using the following syntax:
const obj_defraw = zlib.createDeflateRaw();
We have to create a new object for this function to use in the future.
To better understand how to implement a createDeflateRaw()
method, let’s observe the following example code.
const zlib = require('zlib'); var obj1; var def_raw1 = zlib.createDeflateRaw(obj1).toString('utf8'); var obj2; var def_raw2 = zlib.createDeflateRaw(obj2); console.log(def_raw1); console.log("\n", def_raw2);
The above illustration demonstrates two objects that hold no data: obj1
and obj2
.
Objects def_raw1
and def_raw2
use these objects to create new objects for DeflateRaw
. We have passed these objects as parameters into the createDeflateRaw()
method.
The output for def_raw1
displays the object and its type class in utf8
format, whereas def_raw2
returns the JSON type for obj2
. All properties of the new object created using def_raw2
are listed in the console log.
RELATED TAGS
CONTRIBUTOR
View all Courses