writable.writableHighWaterMark屬性是流模塊的內置應用程序編程接口,用於檢查創建Writable時傳遞的highWaterMark值。
用法:
writable.writableHighWaterMark
返回值:如果設置,它將返回高水印值,否則返回默認值。
以下示例說明了Node.js中writable.writableHighWaterMark屬性的使用:
範例1:
// Node.js program to demonstrate the
// writable.writableHighWaterMark Property
// Accessing stream module
const stream = require('stream');
// Creating a stream and creating
// a write function
const writable = new stream.Writable({
// Write function with its
// parameters
write:function(chunk, encoding, next) {
// Converting the chunk of
// data to string
console.log(chunk.toString());
next();
}
});
// Writing data
writable.write('hi');
// Again writing some data
writable.write('GFG');
// Calling writable.writableHighWaterMark
// Property
writable.writableHighWaterMark;
輸出:
hi GFG 16384
在此,返回默認值。
範例2:
// Node.js program to demonstrate the
// writable.writableHighWaterMark Property
// Accessing stream module
const stream = require('stream');
// Creating a stream and setting the value
// of the highWaterMark
const writable = new stream.Writable({
highWaterMark:1234
});
// Calling writable.writableHighWaterMark
// Property
writable.writableHighWaterMark;
輸出:
1234
這裏,返回在創建可寫流時設置的highWaterMark的值。
參考: https://nodejs.org/api/stream.html#stream_writable_writablehighwatermark
相關用法
- node.js Stream writable.writableLength用法及代碼示例
- node.js Stream writable.destroyed用法及代碼示例
- node.js Stream writable.writableEnded用法及代碼示例
- node.js Stream readable.destroyed用法及代碼示例
- node.js Stream writable.writableCorked用法及代碼示例
- node.js Stream writable.writableFinished用法及代碼示例
- node.js Stream writable.writableObjectMode用法及代碼示例
- node.js Stream readable.readable用法及代碼示例
- node.js Stream writable.writable用法及代碼示例
注:本文由純淨天空篩選整理自nidhi1352singh大神的英文原創作品 Node.js | Stream writable.writableHighWaterMark Property。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。