Node.js Stream readable.readableObjectMode Property
The readable.readableObjectMode property in a Readable Stream that is used to check the objectMode of the stream.
Syntax:
readable.readableObjectMode
Return Value: It returns the Boolean value.
Below examples illustrate the use of readable.readableObjectMode property in Node.js:
Example 1:
const Readable = require( 'readable-stream' ).Readable;
const readable = Readable({objectMode: true });
readable._read = () => {};
readable.on( 'readable' , () => {
let chunk;
while ( null !== (chunk = readable.read(4))) {
console.log(`read: ${chunk}`);
}
});
readable.readableObjectMode;
console.log( "objectMode is true!!" );
|
Output:
objectMode is true!!
Example 2:
const Readable = require( 'readable-stream' ).Readable;
const readable = Readable({objectMode: false });
readable._read = () => {};
readable.on( 'readable' , () => {
let chunk;
while ( null !== (chunk = readable.read(4))) {
console.log(`read: ${chunk}`);
}
});
readable.readableObjectMode;
console.log( "objectMode is false!!" );
|
Output:
objectMode is false!!
Reference: https://nodejs.org/api/stream.html#stream_readable_readableobjectmode
Last Updated :
12 Oct, 2021
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...