Search the reference...
/
BuildDocsReferenceGuidesBlogDiscord/node:tty/WriteStream/readMreadmethod
tty.WriteStream.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-03-02 23:56:29
数码科技
成功
标题:电脑白屏了按哪个键可以修复 电脑白屏的解决方法-驱动人生
简介:不知道大家有没有遇到过电脑用着用着突然白屏的情况,近期有不少小伙伴就遇到了,这可能是由于硬件故障、软件冲突、驱动程序问题
-
2026-03-03 03:07:58
电商商城
成功
标题:METROCITY面霜怎么样 - 京东
简介:京东是专业的METROCITY面霜网上购物商城,为您提供METROCITY面霜价格图片信息、METROCITY面霜怎么样
-
2026-03-03 08:33:37
数码科技
成功
标题:中美冲突升级的下一步,一定是军事较量,我们要做好全面准备 中美冲突 二战 军事较量 唐纳德·特朗普 德国 战争 日本 美国 美防长_手机网易网
简介:特朗普开打关税战,中国强硬反击,双方针尖对麦芒,冲突越来越激烈。事情发展到现在,已经不是关税多少的经济问题了,而是谁先让
-
2026-03-02 10:30:19
综合导航
成功
标题:Central Limit Theorem Archives - Making Sense of the Infinite
简介:Central Limit Theorem Archives - Making Sense of the Infinit
-
2026-03-03 08:34:34
图片素材
成功
标题:逆耳的作文250字 描写逆耳的作文 关于逆耳的作文-作文网
简介:作文网精选关于逆耳的250字作文,包含逆耳的作文素材,关于逆耳的作文题目,以逆耳为话题的250字作文大全,作文网原创名师
-
2026-03-02 20:16:32
综合导航
成功
标题:Luxe Design Forecasts Long Island Interior Design Trend: Turning Forgotten Corners Into Functional Nooks - PR.com
简介:Long Island homeowners are reimagining unused corners as fun
-
2026-03-02 10:08:06
教育培训
成功
标题:我的房间小学作文合集六篇
简介:在日常学习、工作抑或是生活中,大家都经常接触到作文吧,作文是人们以书面形式表情达意的言语活动。如何写一篇有思想、有文采的
-
2026-03-02 10:18:36
综合导航
成功
标题:Lavender Law Conference & Career Fair 2024
简介:Fish & Richardson Principal Ayan Roy-Chowdhury, Ph.D., will
-
2026-03-03 03:23:31
综合导航
成功
标题:What Do Coffee Consumers Value in a Cup of Joe?
简介:New study from Peet’s reveals customers’ java preferences
-
2026-03-02 20:37:04
综合导航
成功
标题:Workplace Trends - Biophilic Design Inspiring Workspaces by BOS
简介:We all strive to live and work in places that are beautiful,
-
2026-03-02 10:25:46
综合导航
成功
标题:JJMICROELECTRONICS
简介:JJM products are developed to meet a wide range of applicati
-
2026-03-03 08:32:57
综合导航
成功
标题:大小姐的贴身夫婿_没墨水了_第七十章 我不理你们了!_风云中文网
简介:风云中文网提供大小姐的贴身夫婿(没墨水了)第七十章 我不理你们了!在线阅读,所有小说均免费阅读,努力打造最干净的阅读环境
-
2026-03-02 20:21:23
综合导航
成功
标题:没ä¸çæ¼é³_没ä¸çææ_没ä¸çç¹ä½_è¯ç»ç½
简介:è¯ç»ç½æ²¡ä¸é¢é,ä»ç»æ²¡ä¸,没ä¸çæ¼é³,æ²¡ä¸æ¯
-
2026-03-02 20:37:17
教育培训
成功
标题:揭秘银行校招和社招的区别,你了解多少?-高顿教育
简介:银行校招和社招都是银行招聘中常见的招聘方式,虽然它们都是为了吸引优秀人才加入银行业,但在招聘对象、招聘流程和职位安排等方
-
2026-03-02 20:16:31
综合导航
成功
标题:å亡ç»çµ¶çæ¼é³_å亡ç»çµ¶çææ_å亡ç»çµ¶çç¹ä½_è¯ç»ç½
简介:è¯ç»ç½å亡ç»çµ¶é¢é,ä»ç»å亡ç»çµ¶,å亡ç»çµ¶ç
-
2026-03-02 20:32:15
综合导航
成功
标题:æ°æ¬çæ¼é³_æ°æ¬çææ_æ°æ¬çç¹ä½_è¯ç»ç½
简介:è¯ç»ç½æ°æ¬é¢é,ä»ç»æ°æ¬,æ°æ¬çæ¼é³,æ°æ¬æ¯
-
2026-03-02 20:10:29
综合导航
成功
标题:Odoacer (c. 433-493). The Reader's Biographical Encyclopaedia. 1922
简介:Odoacer (c. 433-493). The Reader
-
2026-03-02 20:09:00
游戏娱乐
成功
标题:苹果超人9虫虫终结,苹果超人9虫虫终结小游戏,4399小游戏 www.4399.com
简介:苹果超人9虫虫终结在线玩,苹果超人9虫虫终结下载, 苹果超人9虫虫终结攻略秘籍.更多苹果超人9虫虫终结游戏尽在4399小
-
2026-03-02 21:29:37
综合导航
成功
标题:my soon to be mr2 [Archive] - Toyota MR2 Message Board
简介:If you read my profile, u
-
2026-03-02 23:52:38
电商商城
成功
标题:大宇daewoo冰箱图片 - 京东
简介:京东是国内专业的大宇daewoo冰箱网上购物商城,本频道提供大宇daewoo冰箱商品图片,大宇daewoo冰箱精选图片大
-
2026-03-03 08:33:25
综合导航
成功
标题:柏梁宴的拼音_柏梁宴的意思_柏梁宴的繁体_词组网
简介:词组网柏梁宴频道,介绍柏梁宴,柏梁宴的拼音,柏梁宴是什么意思,柏梁宴的意思,柏梁宴的繁体,柏梁宴怎么读,柏梁宴的近义词,
-
2026-03-02 23:51:04
综合导航
成功
标题:BCMR2 2006 Calenders are coming...Want one? [Archive] - Toyota MR2 Message Board
简介:Hey guys/gals I am just finishing up BCMR2.com
-
2026-03-02 19:57:29
视频影音
成功
标题:基金从业培训视频:债券估值、债券的收益率和债券久期的计算-基金从业-233网校
简介:债券的收益率和久期的计算在基金从业考试中几乎每次都会出题,多则5~6题,少则2~3题,如果之后从业的话,这几个计算可能会
-
2026-03-03 08:05:04
游戏娱乐
成功
标题:谜团【光明的未来】-寻找被盗物品_夺宝奇兵古老之圈攻略-夺宝奇兵古老之圈关卡解密谜团密码锁合集_3DM单机
简介:《夺宝奇兵:古老之圈》关卡解密谜团密码锁合集,在本作游戏中有大量的解密关卡,有很多玩家都不知道怎么做,下面会给大家整理一
-
2026-03-02 21:12:10
游戏娱乐
成功
标题:美人鱼化妆,美人鱼化妆小游戏,4399小游戏 www.4399.com
简介:4399为您提供美人鱼化妆在线玩,美人鱼化妆下载, 美人鱼化妆攻略秘籍.更多美人鱼化妆游戏尽在4399小游戏,好玩记得告
-
2026-03-03 00:03:37
健康养生
成功
标题:医疗儿科护理常规试题及答案参考 - 豆丁网
简介:豆丁网是面向全球的中文社会化阅读分享平台,拥有商业,教育,研究报告,行业资料,学术论文,认证考试,星座,心理学等数亿实用
-
2026-03-03 03:42:18
电商商城
成功
标题:换鞋凳韩式怎么样 - 京东
简介:京东是专业的换鞋凳韩式网上购物商城,为您提供换鞋凳韩式价格图片信息、换鞋凳韩式怎么样的用户评论、换鞋凳韩式精选导购、更多
-
2026-03-02 10:21:17
综合导航
成功
标题:Автоматическая поилка-фонтанчик для собак и кошек, 2,5л (217222828) - RIA
简介:Продаю на RIA - Автоматическая поилка-фонтанчик для собак и
-
2026-03-03 08:13:34
图片素材
成功
标题:逃脱的作文550字 描写逃脱的作文 关于逃脱的作文-作文网
简介:作文网精选关于逃脱的550字作文,包含逃脱的作文素材,关于逃脱的作文题目,以逃脱为话题的550字作文大全,作文网原创名师
-
2026-03-02 20:35:17
综合导航
成功
标题:æççæ¼é³_æççææ_æççç¹ä½_è¯ç»ç½
简介:è¯ç»ç½æçé¢é,ä»ç»æç,æççæ¼é³,æçæ¯