-
Notifications
You must be signed in to change notification settings - Fork 268
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
Support object streams #53
Comments
this is fixed by #54 |
Nice, thanks for pointing this out. I've known for a while the stream-related stuff in Lazy is really shaky and was actually intending on making that my next big focus. I am on a bus at the moment but will take a closer look in the near future. |
i sent a PR :) #54 from what i can tell all you need to do is stop trying to do setEncoding when it isn't there. locally i'm doing map and each and pluck and they seem to work fine using the JSONStream in the example above. |
OK, looks good! Thanks again. |
yeah, it works good enough for certain cases. i actually ended up writing something new after wrestling a bit with lazy. the big problem was that the return value of the lazy methods isn't a valid stream so i just wrote a new little library that'll go up on github/npm soon enough. |
Interesting. I'm actually a relative newcomer to streams in Node—as you could probably tell from some of the code in lazy.node.js (such as bug you pointed out in this very issue)—but I was thinking about this and was actually planning on looking into implementing Node's streaming API so that you could do things like... Lazy(stream).map([whatever]).filter([whatever]).pipe(otherStream); Alternately (or in addition) it might make sense to expose something like a It could be that this is precisely what you're working on. If so I will be curious to see how our approaches overlap,if at all. |
here you go, https://github.com/mikeal/funcstream, no docs yet. there's also a few things I know I'm doing wrong. for instance, I'm still using old style streams listeners in a few places: https://github.com/mikeal/funcstream/blob/master/index.js#L77 I'll need to talk to @isaacs about how to do this properly with streams2 transform streams. |
Gotcha. Yeah, definitely looks like something that can be done properly from within Lazy as well. I just need to learn a bit more about streams in Node. But I can also definitely see the appeal of using a library that specializes in just providing functional constructs over streams (as opposed to Lazy.js, which is bigger and more general). Plenty of room for both, I think. |
@dtao i looked at adapting lazy.js more before i wrote funcstream, the main reason I didn't was that there's just so much work in lazy to lazily evaluate and compute any computationally intensive task which isn't a concern at all when streaming since the stream is already iterative and computation is already broken in to natural blocks. there's also a few other things like a number of methods actually return values which just isn't possible with streams and needs to be in a callback. enough assumptions differed that it made sense to write another library but hopefully i'll test out enough things that you can learn from them and do better integration in the future. |
Yes, some of this is in line w/ things I'm planning on doing with Lazy as well. For example my intention is to take methods that return a value (e.g., If nothing else, this exchange has somewhat motivated me to get off my butt and actually work through some of these things, which I've been intending to do for months but just haven't gotten around to! |
You appear to be assuming that the readable stream you get is going to give you strings (and has a setEncoding method) but it should just take whatever the body is.
results in
The text was updated successfully, but these errors were encountered: