Buffer.writeBigUInt64LE()方法是Buffer模塊中Buffer類的內置應用程序編程接口,用於將小端64位大整數值以指定的偏移量寫入分配的緩衝區。
用法:
Buffer.writeBigUInt64LE( value, offset )
參數:
- value:此參數指定要寫入緩衝區的大整數值。它應該是有效的64位Little Endian Big整數值。當值不是此值時,行為是不確定的。
- offset:它指定在寫入之前要跳過的字節數,或者隻是表示緩衝區中的索引。 offset的值是0 <= offset <= Buffer.length-8。其默認值為0。
返回值:此方法返回一個無符號整數值,該值是偏移量和寫入的字節數的總和。
以下示例說明了Node.js中Buffer.writeBigUInt64LE()方法的使用:
範例1:
文件名:index.js
// Node.js program to demonstrate the
// buffer.writeBigUInt64LE() method
const buf = Buffer.allocUnsafe(8);
// Writing big integer value into buffer
// by using writeBigUInt64LE() method
buf.writeBigUInt64LE(0x01030405060708n, 0);
// display the buffer
console.log(buf);
使用以下命令運行index.js文件:
node index.js
輸出:
<Buffer 08 07 06 05 04 03 01 00>
範例2:
文件名:index.js
// Node.js program to demonstrate the
// buffer.writeBigUInt64LE() method
const buf = Buffer.allocUnsafe(8);
// writing big integer value into buffer
// by using writeBigUInt64LE() method
buf.writeBigUInt64LE(0xaa03040506efffn, 0);
// Display the buffer
console.log(buf);
使用以下命令運行index.js文件:
node index.js
輸出:
<Buffer ff ef 06 05 04 03 aa 00>
參考:https://nodejs.org/dist/latest-v12.x/docs/api/buffer.html#buffer_buf_writebiguint64le_value_offset
相關用法
- Node.js console.timeLog()用法及代碼示例
- Node.js GM write()用法及代碼示例
- Node.js GM operator()用法及代碼示例
- Node.js GM randomThreshold()用法及代碼示例
- Node.js GM negative()用法及代碼示例
- Node.js GM median()用法及代碼示例
- Node.js GM crop()用法及代碼示例
- Node.js GM despeckle()用法及代碼示例
- Node.js GM emboss()用法及代碼示例
- Node.js GM whitePoint()用法及代碼示例
- Node.js GM drawRectangle()用法及代碼示例
- Node.js GM shave()用法及代碼示例
- Node.js GM recolor()用法及代碼示例
- Node.js GM gamma()用法及代碼示例
注:本文由純淨天空篩選整理自RohitPrasad3大神的英文原創作品 Node.js Buffer.writeBigUInt64LE() Method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。