Node.jsのwritable.writableObjectModeプロパティをストリーミングします
writable.writableObjectModeプロパティは、指定された書き込み可能なストリームのobjectModeプロパティを取得するために使用されます。オブジェクトモードが設定されている場合、プロパティは「true」を返します。そうでない場合は、「false」が返されます。
構文
writeable.writableObjectMode
例
writableObjectMode.jsという名前のファイルを作成し、以下のコードスニペットをコピーします。ファイルを作成したら、次のコマンドを使用して、以下の例に示すようにこのコードを実行します-
node writableObjectMode.js
writableObjectMode.js
// Program to demonstrate writable.writableObjectMode property
// Importing the stream module
const stream = require('stream');
// Setting the objectMode to true
objectMode: true
// Creating a data stream with writable
const writable = new stream.Writable({
// Writing the data from stream
write: function(chunk, encoding, next) {
// Converting the data chunk to be displayed
console.log(chunk.toString());
next();
}
});
// Writing data - Not in the buffer queue
writable.write('Welcome to TutorialsPoint !');
writable.write('SIMPLY LEARNING ');
// Printing the length of the queue data
console.log(writable.writableObjectMode == true); 出力
C:\home\node>> node writableObjectMode.js Welcome to TutorialsPoint ! SIMPLY LEARNING true
例
もう1つの例を見てみましょう。
// Program to demonstrate writable.writableObjectMode property
// Importing the stream module
const stream = require('stream');
// Creating a data stream with writable
const writable = new stream.Writable({
// Writing the data from stream
write: function(chunk, encoding, next) {
// Converting the data chunk to be displayed
console.log(chunk.toString());
next();
}
});
// Writing data - Not in the buffer queue
writable.write('Welcome to TutorialsPoint !');
writable.write('SIMPLY LEARNING ');
// Printing the length of the queue data
console.log(writable.writableObjectMode); 出力
C:\home\node>> node writableObjectMode.js Welcome to TutorialsPoint ! SIMPLY LEARNING undefined Default value is undefined.
-
JavaScriptのlengthプロパティを使用せずにノードリストから最後のアイテムを取得しますか?
以下が私たちのテーブルだとしましょう- <table id="demo" border="1"> <tr> <td>John</td> </tr> <tr> <td>David</td> </tr> <tr> <td>Mike</td> </tr> </table> </body> 以下をtext()とともに使用して、最後のアイテムを取得します- $('table t
-
HTMLDOMfirstChildプロパティ
HTML DOMのfirstChildプロパティは、特定のノードの最初の子ノードをノードオブジェクトとして返すために使用されます。どのノードが最初であるかに応じて、テキストノード、要素ノード、またはコメントノードとして戻ることができます。これは読み取り専用のプロパティです。 構文 以下は、HTMLDOMfirstChildプロパティの構文です- node.firstChild 例 firstChildプロパティの例を見てみましょう- <!DOCTYPE html> <html> <head> <script> fun