Buffer.buffer屬性是緩衝區模塊中Buffer類的內置應用程序編程接口,用於獲取與此緩衝區對象等效的數組緩衝區的對象。
用法:
const buf.buffer
返回值:此屬性返回數組緩衝區的對象。
範例1: 文件名:index.js
Javascript
// Node.js program to demonstrate the
// Buffer.buffer property
// Creating a Buffer
const buff = Buffer.from([1, 2, 3, 4, 5]);
// Getting the value of array buffer
const value = buff.buffer;
// Display the result
console.log("Big Integer:- " + value);
輸出:
Big Integer:- [object ArrayBuffer]
範例2: 文件名:index.js
Javascript
// Node.js program to demonstrate the
// Buffer.buffer property
// Creating and initializing arraybuffer object
const arrbuff = new ArrayBuffer(16);
// Getting buffer object form existing
// arraybuffer object
const buffer = Buffer.from(arrbuff);
// Display the result
if(buffer.buffer === arrbuff)
console.log("both buffer is equivalent");
else
console.log("both buffer is not equivalent");
輸出:
both buffer is equivalent
使用以下命令運行index.js文件:
node index.js
相關用法
- Node.js GM charcoal()用法及代碼示例
- Node.js GM blur()用法及代碼示例
- Node.js GM sharpen()用法及代碼示例
- Node.js GM drawLine()用法及代碼示例
- Node.js GM drawArc()用法及代碼示例
- Node.js GM drawPolyline()用法及代碼示例
- Node.js GM drawBezier()用法及代碼示例
- Node.js GM drawCircle()用法及代碼示例
- Node.js GM drawEllipse()用法及代碼示例
- Node.js GM drawPolygon()用法及代碼示例
- Node.js GM drawRectangle()用法及代碼示例
注:本文由純淨天空篩選整理自RohitPrasad3大神的英文原創作品 Node.js Buffer.buffer Property。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。