Giter Site home page Giter Site logo

Comments (3)

gfx avatar gfx commented on May 22, 2024

Those examples look not so good and should be improved.

In fact, both can handle chunk of encoded MessagePack binaries, but they handle different formats.

decodeStream handles {"name": "foo"}{"name":"bar"} (shown as JSON for readability), whereas decodeArrayStream handles [{"name": "foo"},{"name":"bar"}].

Does it make sense for you?

from msgpack-javascript.

grantila avatar grantila commented on May 22, 2024

Kind of, clarifying that would surely be useful.

My question is rather, can I send a stream of individually incomplete chunks? Uint8Array's that are, say, at most n bytes large. This would be an input stream as your example of (n=6):

         +--------+
 Chunk 1 | {"name |
         +--------+
         +--------+
 Chunk 2 | ": "fo |
         +--------+
         +--------+
 Chunk 3 | o"}{"n |
         +--------+
         +--------+
 Chunk 4 | ame":" |
         +--------+
         +-------+
 Chunk 5 | bar"} |
         +-------+

Can I get this output stream of decoded:

           +---------------+
 Message 1 | {name: 'foo'} |
           +---------------+
           +---------------+
 Message 2 | {name: 'bar'} |
           +---------------+

Is this possible?

from msgpack-javascript.

gfx avatar gfx commented on May 22, 2024

@grantila

Yes, it is possible and the default in all the async or stream decoders. For example, see tests for decodeAsync https://github.com/msgpack/msgpack-javascript/blob/master/test/decodeAsync.test.ts#L28-L37

from msgpack-javascript.

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.