admin管理员组文章数量:1323497
The internal library which I'm using is providing NodeJS.ReadableStream
, which I need to pass to nodemailer
(attachments), which is taking as parameter Readable
.
Argument of type 'Buffer | ReadableStream' is not assignable to parameter of type 'Buffer | Readable'.
Type 'ReadableStream' is not assignable to type 'Buffer | Readable'.
Resolved. Created Readable
instance, and used .wrap
method for ReadableStream
The internal library which I'm using is providing NodeJS.ReadableStream
, which I need to pass to nodemailer
(attachments), which is taking as parameter Readable
.
Argument of type 'Buffer | ReadableStream' is not assignable to parameter of type 'Buffer | Readable'.
Type 'ReadableStream' is not assignable to type 'Buffer | Readable'.
Resolved. Created Readable
instance, and used .wrap
method for ReadableStream
- 2 Thank you very much for sharing! Link to node doc: nodejs/api/stream.html#stream_readable_wrap_stream – Huan Commented Jun 27, 2020 at 11:37
- See my answer on duplicate question: stackoverflow./questions/71509505/… – Mikael Couzic Commented Jul 15, 2024 at 11:59
1 Answer
Reset to default 4Posting the solution provided from @hejkerooo as an answer:
const { OldReader } = require('./old-api-module.js');
const { Readable } = require('node:stream');
const oreader = new OldReader(); // ReadableStream
const myReader = new Readable().wrap(oreader); // Readable
Source: https://nodejs/api/stream.html#readablewrapstream
本文标签: javascriptHow to cast ReadableStream to ReadableStack Overflow
版权声明:本文标题:javascript - How to cast ReadableStream to Readable - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742143601a2422690.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论