Search the reference...
/
BuildDocsReferenceGuidesBlogDiscord/node:net/Socket/readMreadmethod
net.Socket.read { let chunk; console.log('Stream is readable (new data received in buffer)'); // Use a loop to make sure we read all currently available data while (null !== (chunk = readable.read())) { console.log(`Read ${chunk.length} bytes of data...`); } }); // 'end' will be triggered once when there is no more data available readable.on('end', () => { console.log('Reached end of stream.'); }); ``` Each call to `readable.read()` returns a chunk of data, or `null`. The chunks are not concatenated. A `while` loop is necessary to consume all data currently in the buffer. When reading a large file `.read()` may return `null`, having consumed all buffered content so far, but there is still more data to come not yet buffered. In this case a new `'readable'` event will be emitted when there is more data in the buffer. Finally the `'end'` event will be emitted when there is no more data to come. Therefore to read a file's whole contents from a `readable`, it is necessary to collect chunks across multiple `'readable'` events: ```js const chunks = []; readable.on('readable', () => { let chunk; while (null !== (chunk = readable.read())) { chunks.push(chunk); } }); readable.on('end', () => { const content = chunks.join(''); }); ``` A `Readable` stream in object mode will always return a single item from a call to `readable.read(size)`, regardless of the value of the `size` argument. If the `readable.read()` method returns a chunk of data, a `'data'` event will also be emitted. Calling read after the `'end'` event has been emitted will return `null`. No runtime error will be raised." data-algolia-static="false" data-algolia-merged="false" data-type="Method">read(size?: number): any;The readable.read() method reads data out of the internal buffer and returns it. If no data is available to be read, null is returned. By default, the data is returned as a Buffer object unless an encoding has been specified using the readable.setEncoding() method or the stream is operating in object mode.The optional size argument specifies a specific number of bytes to read. If size bytes are not available to be read, null will be returned unless the stream has ended, in which case all of the data remaining in the internal buffer will be returned.If the size argument is not specified, all of the data contained in the internal buffer will be returned.The size argument must be less than or equal to 1 GiB.The readable.read() method should only be called on Readable streams operating in paused mode. In flowing mode, readable.read() is called automatically until the internal buffer is fully drained.const readable = getReadableStreamSomehow(); // 'readable' may be triggered multiple times as data is buffered in readable.on('readable', () => { let chunk; console.log('Stream is readable (new data received in buffer)'); // Use a loop to make sure we read all currently available data while (null !== (chunk = readable.read())) { console.log(`Read ${chunk.length} bytes of data...`); } }); // 'end' will be triggered once when there is no more data available readable.on('end', () => { console.log('Reached end of stream.'); }); Each call to readable.read() returns a chunk of data, or null. The chunks are not concatenated. A while loop is necessary to consume all data currently in the buffer. When reading a large file .read() may return null, having consumed all buffered content so far, but there is still more data to come not yet buffered. In this case a new 'readable' event will be emitted when there is more data in the buffer. Finally the 'end' event will be emitted when there is no more data to come.Therefore to read a file's whole contents from a readable, it is necessary to collect chunks across multiple 'readable' events:const chunks = []; readable.on('readable', () => { let chunk; while (null !== (chunk = readable.read())) { chunks.push(chunk); } }); readable.on('end', () => { const content = chunks.join(''); }); A Readable stream in object mode will always return a single item from a call to readable.read(size), regardless of the value of the size argument.If the readable.read() method returns a chunk of data, a 'data' event will also be emitted.Calling read after the 'end' event has been emitted will return null. No runtime error will be raised.@param sizeOptional argument to specify how much data to read.Resources
ReferenceDocsGuidesDiscordMerch StoreGitHubBlogToolkit
RuntimePackage managerTest runnerBundlerPackage runnerProject
Bun 1.0Bun 1.1Bun 1.2Bun 1.3RoadmapContributingLicenseBaked with ❤️ in San FranciscoWe're hiring →智能索引记录
-
2026-02-27 14:43:13
综合导航
成功
标题:Eskimo Men's Mou Official Website
简介: Our iconic mou eskimo range offers sophisticated colour, un
-
2026-02-28 06:13:33
综合导航
成功
标题:Gzip.unshift method Node.js zlib module Bun
简介:API documentation for method node:zlib.Gzip.unshift Bun
-
2026-02-27 23:54:29
教育培训
成功
标题:上海浦东秋季辅导班_高中辅导补习班-上海新王牌培优
简介:新王牌创立于2005年,拥有一支强大的名师天团,定位培优,学生都来自重点中学,采用分层授课,小班教学,支持按月收费,成就
-
2026-02-28 03:27:46
综合导航
成功
标题:Database Integration Archives - Making Sense of the Infinite
简介:Database Integration Archives - Making Sense of the Infinite
-
2026-02-27 23:17:45
综合导航
成功
标题:宠妃的演技大赏_发达的泪腺_来世番(夺妻)_风云中文网
简介:风云中文网提供宠妃的演技大赏(发达的泪腺)来世番(夺妻)在线阅读,所有小说均免费阅读,努力打造最干净的阅读环境,24小时
-
2026-02-27 16:24:22
综合导航
成功
标题:Annapurna Announce Stray For The PS5, Coming Next Year - PlayStation Universe
简介:Annapurna have announced Stray for the PS5. Watch the traile
-
2026-02-28 08:12:03
综合导航
成功
标题:Contactless Payment with TD Credit Cards TD Canada Trust
简介:TD offers customers both the convenience of contactless paym
-
2026-02-28 08:19:38
综合导航
成功
标题:UltraBac Backup and Disaster Recovery Software
简介:Fast, easy-to-use backup and disaster recovery software prov
-
2026-02-28 06:16:54
综合导航
成功
标题:NBA coaches exposed to illegal gambling scandal, predicting the dilemma of insider trading in the surging market Bee Network
简介:Original translation: Felix, PANews As the sports world was
-
2026-02-27 16:56:51
综合导航
成功
标题:AmplifyME Recruiting Program
简介:Learn how we have teamed up with AmplifyME to identify and v
-
2026-02-28 03:34:26
综合导航
成功
标题:Midnight Tropical Piped Shirt Cue
简介:Midnight Tropical Reverie print Classic shirt Relaxed fit Co
-
2026-02-28 05:52:13
综合导航
成功
标题:CP08シリーズ (MIL-STD-348Aに準拠した同軸コネクタ) コネクタ メーカー JAE 日本航空電子工業
简介:日本航空電子工業株式会社(JAE)のCP08シリーズ (MIL-STD-348Aに準拠した同軸コネクタ)がご覧いただけま
-
2026-02-28 02:27:20
综合导航
成功
标题:Amy Vip Shopper Dress Up - Play The Free Mobile Game Online
简介:Amy Vip Shopper Dress Up - click to play online. Amy is goin
-
2026-02-27 21:56:55
综合导航
成功
标题:优惠网-文化-星座
简介:优惠网-文化-星座www.pj036.com经营范围含:画框、树脂、压缩设备、飞机、禽蛋、机油三滤、碳素产品、供暖工程、
-
2026-02-28 09:32:25
综合导航
成功
标题:Mathpup Math Adventure - Play The Free Mobile Game Online
简介:Mathpup Math Adventure - click to play online. Mathpup Math
-
2026-02-28 03:24:39
数码科技
成功
标题:北京孤凡电子商务有限公司
简介:北京孤凡电子商务有限公司专注于为客户带来卓越的产品和服务,致力于满足每一位客户的独特需求。我们深知,只有提供高品质的产品
-
2026-02-28 09:17:48
综合导航
成功
标题:SPT181A - StrongShop
简介:Item Name : SPT181A Description : 2.75
-
2026-02-28 02:56:54
综合导航
成功
标题:“Pure Happiness:” A Discussion on UPath with Nick Iskovych
简介:Read about Nick Iskovych’s path from Ukraine to Canada, util
-
2026-02-27 15:20:46
综合导航
成功
标题:Play Free 2048 games on PC, Mobile & Tablet - yad.com
简介:There are 26 2048 games on yad.com. We have chosen the best
-
2026-02-27 21:49:02
综合导航
成功
标题:† Wafter v.2. World English Historical Dictionary
简介:† Wafter v.2. World English Historical Dictionary
-
2026-02-27 15:33:10
综合导航
成功
标题:Dreams in Progress: ILSC LTE Scholar Pooja Das' Story
简介:Pooja Das has a strong desire to learn English in the hopes
-
2026-02-28 09:36:04
综合导航
成功
标题:971B-72024 Vacuum Pressure Transducer
简介:The 971B-72024 UniMag Cold Cathode Inverted Magnetron Vacuum
-
2026-02-28 09:35:51
综合导航
成功
标题:UPS Uninterruptible Power Supplies - Data Center Power System Solutions - FS
简介:FS UPS Power Supplies secure your critical data and protect
-
2026-02-28 09:29:07
综合导航
成功
标题:【必备】二年级的春天作文汇编八篇
简介:在平平淡淡的日常中,大家总少不了接触作文吧,作文是由文字组成,经过人的思想考虑,通过语言组织来表达一个主题意义的文体。那
-
2026-02-27 21:50:26
教育培训
成功
标题:(精)五年级优秀作文4篇
简介:在日常学习、工作或生活中,大家都经常看到作文的身影吧,作文是通过文字来表达一个主题意义的记叙方法。你所见过的作文是什么样
-
2026-02-27 17:46:59
旅游出行
成功
标题:钓鱼+大沙漠②+希雍④+埃多斯7号⑤+废土⑤_剑星怎么全收集-全收集全剧情白金攻略分享_3DM单机
简介:《剑星》中的可收集内容和剧情是非常丰富的,结局也很有特点,首先是分别选不牵手与牵手,做2个结局。如果没有备份存档,bos
-
2026-02-27 22:55:41
综合导航
成功
标题:Coupe cors pédicure - Vitry
简介:Les coupe cors pédicure VITRY sont indispensables pour élimi
-
2026-02-28 03:18:36
综合导航
成功
标题:Employee Benefit News HR & Benefits News and Insights Employee Benefit News
简介:Employee Benefit News offers expert HR management, healthcar
-
2026-02-28 07:51:11
综合导航
成功
标题:variable Z_BEST_SPEED Node.js zlib module Bun
简介:API documentation for variable node:zlib.constants.Z_BEST_SP
-
2026-02-28 06:00:51
游戏娱乐
成功
标题:塔王之王2_塔王之王2html5游戏在线玩_4399h5游戏-4399在线玩
简介:4399为您提供塔王之王2在线玩,塔王之王2下载, 塔王之王2攻略秘籍.更多塔王之王2游戏尽在4399小游戏,好玩记得告