This repository has been archived by the owner. It is now read-only.

Add lines about additonal uses of Buffer #4257

Closed
wants to merge 2 commits into
from

Conversation

Projects
None yet
4 participants
@trevnorris

That Buffers can be used with Typed Array Views and DataViews. Included are a couple simple examples.

Add lines about additonal uses of Buffer
That Buffers can be used with Typed Array Views and DataViews. Included
are a couple simple examples.
@TooTallNate

This comment has been minimized.

Show comment Hide comment
@TooTallNate

TooTallNate Nov 21, 2012

Looks good, I'll merge.

The apparent global var leaks in your example kinda bugs me, mind fixing those first?

Looks good, I'll merge.

The apparent global var leaks in your example kinda bugs me, mind fixing those first?

Fix global var leak
Per TooTallNate's request, variables in doc have now been explicitly
declared.
@trevnorris

This comment has been minimized.

Show comment Hide comment
@trevnorris

trevnorris Nov 22, 2012

@TooTallNate There ya go. Thanks for the feedback.

@TooTallNate There ya go. Thanks for the feedback.

@Mithgol

This comment has been minimized.

Show comment Hide comment
@Mithgol

Mithgol Nov 22, 2012

For a future reference, since which Node version is using Buffers with Typed Array Views and DataViews supported?

(I am considering some changes in jDataView and jParser but I am not sure how backwards-compatible that would be.)

Mithgol commented Nov 22, 2012

For a future reference, since which Node version is using Buffers with Typed Array Views and DataViews supported?

(I am considering some changes in jDataView and jParser but I am not sure how backwards-compatible that would be.)

@bnoordhuis

This comment has been minimized.

Show comment Hide comment
@bnoordhuis

bnoordhuis Nov 22, 2012

Member

@Mithgol 0.8. The feature was landed in one of the 0.7 dev releases.

Member

bnoordhuis commented Nov 22, 2012

@Mithgol 0.8. The feature was landed in one of the 0.7 dev releases.

@TooTallNate

This comment has been minimized.

Show comment Hide comment
@TooTallNate

TooTallNate Nov 22, 2012

Thanks @trevnorris, merged in bb867c0.

Thanks @trevnorris, merged in bb867c0.

@Mithgol

This comment has been minimized.

Show comment Hide comment
@Mithgol

Mithgol Dec 16, 2012

@bnoordhuis I've just tried the following in Node v0.6.21:

buff = new Buffer(4);
view = new DataView(buff);
view.setInt16(0, 1);
view.setInt16(2, 2, true);
console.log(buff);

I got <Buffer 00 01 02 00>.

So the DataView() of buffers seems to be possible before 0.8 and 0.7.

I wonder how far in the past it goes and how it should be tested.

Mithgol commented Dec 16, 2012

@bnoordhuis I've just tried the following in Node v0.6.21:

buff = new Buffer(4);
view = new DataView(buff);
view.setInt16(0, 1);
view.setInt16(2, 2, true);
console.log(buff);

I got <Buffer 00 01 02 00>.

So the DataView() of buffers seems to be possible before 0.8 and 0.7.

I wonder how far in the past it goes and how it should be tested.

@Mithgol

This comment has been minimized.

Show comment Hide comment
@Mithgol

Mithgol Dec 16, 2012

Tested in 0.6.0, got the same result.

Mithgol commented Dec 16, 2012

Tested in 0.6.0, got the same result.

@bnoordhuis

This comment has been minimized.

Show comment Hide comment
@bnoordhuis

bnoordhuis Dec 16, 2012

Member

@Mithgol The feature I mean was landed in 5b05429. It doesn't matter though, v0.6's end of life is in two weeks.

Member

bnoordhuis commented Dec 16, 2012

@Mithgol The feature I mean was landed in 5b05429. It doesn't matter though, v0.6's end of life is in two weeks.

@Mithgol

This comment has been minimized.

Show comment Hide comment
@Mithgol

Mithgol Dec 16, 2012

What was the Node version when the commit 5b05429 happened?

(Currently jDataView supports Node versions of 0.5.5 and above, so it does matter: I'd have to persuade that library's author to drop some support if I write some uncompatible pull request.)

Mithgol commented Dec 16, 2012

What was the Node version when the commit 5b05429 happened?

(Currently jDataView supports Node versions of 0.5.5 and above, so it does matter: I'd have to persuade that library's author to drop some support if I write some uncompatible pull request.)

@bnoordhuis

This comment has been minimized.

Show comment Hide comment
@bnoordhuis

bnoordhuis Dec 16, 2012

Member

What was the Node version when the commit 5b05429 happened?

git tag --contains 5b05429 :-)

(v0.7.0 is the first one.)

Member

bnoordhuis commented Dec 16, 2012

What was the Node version when the commit 5b05429 happened?

git tag --contains 5b05429 :-)

(v0.7.0 is the first one.)

@Mithgol

This comment has been minimized.

Show comment Hide comment
@Mithgol

Mithgol Dec 16, 2012

Wait, I understand now; the feature you meant was getting a typed array (such as Uint16Array()) out of a buffer, however, DataView() of a buffer was possible earlier.

I've just tested the same code in Node v0.5.6:

buff = new Buffer(4);
view = new DataView(buff);
view.setInt16(0, 1);
view.setInt16(2, 2, true);
console.log(buff);

Got the same output (<Buffer 00 01 02 00>).

Mithgol commented Dec 16, 2012

Wait, I understand now; the feature you meant was getting a typed array (such as Uint16Array()) out of a buffer, however, DataView() of a buffer was possible earlier.

I've just tested the same code in Node v0.5.6:

buff = new Buffer(4);
view = new DataView(buff);
view.setInt16(0, 1);
view.setInt16(2, 2, true);
console.log(buff);

Got the same output (<Buffer 00 01 02 00>).

@Mithgol

This comment has been minimized.

Show comment Hide comment
@Mithgol

Mithgol Dec 16, 2012

Node v0.5.4 says DataView is not defined.

Node v0.5.5 cannot run on Windows XP.

I guess the least of the compatible versions is v0.5.6 (or v0.5.5, but I am unable to test that).

Mithgol commented Dec 16, 2012

Node v0.5.4 says DataView is not defined.

Node v0.5.5 cannot run on Windows XP.

I guess the least of the compatible versions is v0.5.6 (or v0.5.5, but I am unable to test that).

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