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

Support part buffer for decode #43

Closed
KlonD90 opened this issue Jul 9, 2016 · 2 comments
Closed

Support part buffer for decode #43

KlonD90 opened this issue Jul 9, 2016 · 2 comments

Comments

@KlonD90
Copy link

KlonD90 commented Jul 9, 2016

It's about that works in this way:

var b = Buffer.alloc(1000);
msgPackBuffer.copy(b, 100);
var obj = m.decode(b, {from: 100, length: msgPackBuffer.length});

My case: https://github.com/KlonD90/node-tarantool-driver. Now work for optimisation and use your implementation. I want less allocation for more speed/less memory usage.

Please help me with improve this. Can i pull request you or do something for this way?

@kawanet
Copy link
Owner

kawanet commented Jul 10, 2016

There is a public but undocumented lower-level class Decoder as I've mentioned at #31. I guess the code below would work with this class.

var Decoder = require("msgpack-lite").Decoder;
var decoder = new Decoder();
decoder.buffer = msgPackBuffer;
decoder.offset = 100;
var obj = decoder.fetch(); // decode the first element only

@KlonD90
Copy link
Author

KlonD90 commented Jul 10, 2016

@kawanet thank you :) it is very helpful for me.

@KlonD90 KlonD90 closed this as completed Oct 13, 2016
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

2 participants