Skip to content

Report amount of decoded data #119

Description

@anonghuser

The library should be able to report what portion of the provided buffer has been decoded, so that the caller can know if there is extra data after the messagepack structure and where it starts.

Activity

  1. anonghuser commented on Jan 19, 2023

    @anonghuser
    Author

    FWIW I am able to hack a solution with

        const options = {codec: msgpack.createCodec({})};
        options.codec.decode = (old => function(decoder){
          options.decoder = decoder;
          return old.apply(this, arguments);
        })(options.codec.decode);
    
        msgpack.decode(buf, options);
    
        console.log('decoded amount:', options.decoder.offset);
    

    But something cleaner and documented would be welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions