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

Consider matching Buffer.toJSON() more closely #34

Closed
humphd opened this issue Jul 10, 2014 · 3 comments
Closed

Consider matching Buffer.toJSON() more closely #34

humphd opened this issue Jul 10, 2014 · 3 comments

Comments

@humphd
Copy link

humphd commented Jul 10, 2014

> var buf = new Buffer([1,2,3])
> buf.toJSON()
[ 1, 2, 3 ]

With buffer in the browser I get {type: 'Buffer', data: [...]}. Obviously you're doing this intentionally, since the code does exactly this. However, I wonder why you've chosen to do it this way? At the very least, documenting the difference will save users problems when it works differently than they expect.

@feross
Copy link
Owner

feross commented Jul 10, 2014

Actually, this is how buffer.toJSON() works in node 0.11 which this module
is tracking.

0.11 also made some other changes including adding buffer.equal(),
buffer.compare(), buffer.toArrayBuffer() which are also available in this
module.

On Thursday, July 10, 2014, David Humphrey notifications@github.com wrote:

var buf = new Buffer([1,2,3])> buf.toJSON()[ 1, 2, 3 ]

With buffer in the browser I get {type: 'Buffer', data: [...]}. Obviously
you're doing this intentionally, since the code does exactly this. However,
I wonder why you've chosen to do it this way? At the very least,
documenting the difference will save users problems when it works
differently than they expect.


Reply to this email directly or view it on GitHub
#34.

Feross | blog http://feross.org/ | webtorrent http://webtorrent.io/ |
studynotes http://www.apstudynotes.org/

@humphd
Copy link
Author

humphd commented Jul 10, 2014

Ah, that's really useful, thanks for the info. You should consider calling this out in your README.

@feross feross closed this as completed in f112544 Jul 17, 2014
@feross
Copy link
Owner

feross commented Jul 17, 2014

Added a note to the readme, thanks!

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