Code Monkey home page Code Monkey logo

Comments (5)

joliss avatar joliss commented on July 23, 2024

(This is Node v0.10.5 btw.)

from concat-stream.

max-mapper avatar max-mapper commented on July 23, 2024

Thanks for the bug report. This is a limitation of concat-stream... right now it only knows how to process streams where all chunks are the same type. Here's the current implementation https://github.com/maxogden/node-concat-stream/blob/master/index.js#L32-L41, it keeps an array of chunks and then does some pretty simplistic testing to see which concatenation method it should use.

To add support for multiple types of chunks in a single stream it would add some complexity to the code and could be kind of klunky. Also I'm not sure what the correct should be in your situation (new Buffer('foo') and 'bar'), should it return a Buffer with 'foobar' as the contents or a string 'foobar'?

A quick workaround would be to make sure that you .toString() all buffers before writing them to the stream so that you ensure that all chunks are strings, or vice versa with Buffers

from concat-stream.

joliss avatar joliss commented on July 23, 2024

Seems like a fair limitation. Some ideas:

  • Type-cast to the first type encountered?
  • Print a warning if there's a type mismatch?
  • Throw an error if there's a type mismatch?

from concat-stream.

jonathanong avatar jonathanong commented on July 23, 2024

imo this is an issue with combined-streams. it should cast all the data to a single type (buffers).

https://github.com/stream-utils/combine-streams handles this

from concat-stream.

joliss avatar joliss commented on July 23, 2024

Sounds good. I guess we can close this then, yes?

from concat-stream.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.