-
-
Notifications
You must be signed in to change notification settings - Fork 33.8k
stream: do not chunk strings and Buffer in Readable.from. #30912
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,13 +4,25 @@ const { | |
| Symbol, | ||
| SymbolIterator | ||
| } = primordials; | ||
| const { Buffer } = require('buffer'); | ||
|
|
||
| const { | ||
| ERR_INVALID_ARG_TYPE | ||
| } = require('internal/errors').codes; | ||
|
|
||
| function from(Readable, iterable, opts) { | ||
| let iterator; | ||
| if (typeof iterable === 'string' || iterable instanceof Buffer) { | ||
| return new Readable({ | ||
| objectMode: true, | ||
|
||
| ...opts, | ||
| read() { | ||
| this.push(iterable); | ||
| this.push(null); | ||
| } | ||
| }); | ||
| } | ||
|
|
||
| if (iterable && iterable[Symbol.asyncIterator]) | ||
| iterator = iterable[Symbol.asyncIterator](); | ||
| else if (iterable && iterable[SymbolIterator]) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we check for
Stream._isUint8Arrayas well?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would only be okay if we turn off object mode, I think