zlib.inflateSync()方法是Zlib模塊的內置應用程序編程接口,用於通過Inflate解壓縮數據塊。
用法:
zlib.inflateSync( buffer, options )
參數:此方法接受上述和以下所述的兩個參數:
- buffer:此參數保存類型為Buffer,TypedArray,DataView,ArrayBuffer,字符串的緩衝區。
- options:此參數保存zlib選項的值。
返回值:它使用Inflate返回數據塊。
以下示例說明了Node.js中zlib.inflateSync()方法的使用:
範例1:
// Node.js program to demonstrate the
// zlib.inflateSync() method
// Including zlib module
var zlib = require('zlib');
// Declaring input and assigning
// it a value string
var input = "GeeksforGeeks";
// Calling deflateSync method
var deflated = zlib.deflateSync(input);
// Calling inflateSync method
var inflated = zlib.inflateSync(
new Buffer.from(deflated)).toString();
console.log(inflated);
輸出:
GeeksforGeeks
範例2:
// Node.js program to demonstrate the
// zlib.inflateSync() method
// Including zlib module
var zlib = require('zlib');
// Declaring input and assigning
// it a value string
var input = "GeeksforGeeks";
// Calling deflateSync method
var deflated = zlib.deflateSync(input).toString('hex');
// Calling inflateSync method
var inflated = zlib.inflateSync(new Buffer.from(
deflated, 'hex')).toString('base64');
console.log(inflated);
輸出:
R2Vla3Nmb3JHZWVrcw==
參考: https://nodejs.org/api/zlib.html#zlib_zlib_inflatesync_buffer_options
相關用法
- Node.js GM whitePoint()用法及代碼示例
- Node.js GM sharpen()用法及代碼示例
- Node.js GM threshold()用法及代碼示例
- Node.js GM thumbnail()用法及代碼示例
- Node.js GM transparent()用法及代碼示例
- Node.js GM resize()用法及代碼示例
- Node.js GM drawPolyline()用法及代碼示例
- Node.js GM charcoal()用法及代碼示例
- Node.js GM drawRectangle()用法及代碼示例
- Node.js GM drawPolygon()用法及代碼示例
注:本文由純淨天空篩選整理自nidhi1352singh大神的英文原創作品 Node.js | zlib.inflateSync() Method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。