zlib.createInflate()方法是Zlib模塊的內置應用程序編程接口,用於創建新的Inflate對象。
用法:
zlib.createInflate( options )
參數:此方法接受單個參數選項,這是一個包含zlib選項的可選參數。
返回值:它返回一個新的Inflate對象。
以下示例說明了Node.js中zlib.createInflate()方法的使用:
範例1:
// Node.js program to demonstrate the      
// createInflate() method 
  
// Including zlib module 
var zlib = require('zlib'); 
  
// Calling deflate function to compress data 
zlib.deflate('Hello World!', function(err, data) 
 { 
  if (err)  
  {  
    return console.log('err', err); 
  } 
  
  // Calling createInflate method 
  // to decompress the data again 
  var gunzip = zlib.createInflate(); 
  gunzip.write(data); 
  gunzip.on('data', function (data) 
   { 
      console.log(data.toString()); 
  }); 
});輸出:
Hello World!
範例2:
// Node.js program to demonstrate the      
// createInflate() method 
  
// Including zlib module 
var zlib = require('zlib'); 
  
// Calling deflate function to compress data 
zlib.deflate('Decompressed..', function(err, data) 
 { 
  if (err)  
  {  
    return console.log('err', err); 
  } 
  
  // Calling createInflate method 
  // to decompress the data again 
  var gunzip = zlib.createInflate(); 
  gunzip.write(data); 
  gunzip.on('data', function (data) 
   { 
      console.log(data.toString('hex')); 
  }); 
});輸出:
4465636f6d707265737365642e2e
參考: https://nodejs.org/api/zlib.html#zlib_zlib_createinflate_options
相關用法
- Node.js GM blur()用法及代碼示例
 - Node.js GM drawRectangle()用法及代碼示例
 - Node.js GM sharpen()用法及代碼示例
 - Node.js GM drawPolyline()用法及代碼示例
 - Node.js GM drawEllipse()用法及代碼示例
 - Node.js GM drawCircle()用法及代碼示例
 - Node.js GM drawPolygon()用法及代碼示例
 
注:本文由純淨天空篩選整理自nidhi1352singh大神的英文原創作品 Node.js | zlib.createInflate() Method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。
