Skip to content
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

Report amount of decoded data #119

Open
anonghuser opened this issue Jan 18, 2023 · 1 comment
Open

Report amount of decoded data #119

anonghuser opened this issue Jan 18, 2023 · 1 comment

Comments

@anonghuser
Copy link

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.

@anonghuser
Copy link
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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant