Skip to content
This repository was archived by the owner on Apr 2, 2020. It is now read-only.

create stream from iterator #3

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

create stream from iterator #3

wants to merge 3 commits into from

Conversation

calvinmetcalf
Copy link
Owner

from tc39/proposal-async-iteration#74, adds a wrapIterator method on the prototype similar to wrap, wonder if it would also make sense to add a similar static method on the constructor, maybe taking a second argument for constructor options

@calvinmetcalf
Copy link
Owner Author

making it static would probably be more robust against clashes but would have the problem of needing to specify objectMode, which would make sense to be off by default for a lot of cases, but not all

Readable.from([1, 2, 3]);// objectMode makes sense
Readable.from(Buffer.from([1, 2, 3])); // objectMode does not make sense
// but what about
Readable.from([buffer1, buffer2, buffer3]);// either could make sense
// same with
Readable.from('a string');// do we iterate through the characters in object more or just treat it as a string not in object mode

@mcollina
Copy link

@calvinmetcalf how about:

const from = require('async-iter-stream').from

from(Buffer.from([1, 2, 3]))
from.obj([1, 2, 3])

It follow the same pattern of through2, and we can even publish it as its own module.
It make sense here, as it's more an "experimental module" for streams and promises.

Copy link

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

really really good work.

@calvinmetcalf
Copy link
Owner Author

yes but I was thinking of it in terms of api for bringing into node possibly which doesn't use the .obj convention

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants