Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Documentation update about Buffer initialization #9104

Closed
wants to merge 1 commit into from
Closed

Documentation update about Buffer initialization #9104

wants to merge 1 commit into from

Conversation

sarathms
Copy link

fixes #7230

@@ -64,7 +64,7 @@ It can be constructed in a variety of ways.

Allocates a new buffer of `size` octets. Note, `size` must be no more than
[kMaxLength](smalloc.html#smalloc_smalloc_kmaxlength). Otherwise, a `RangeError`
will be thrown here.
will be thrown here. Unlike `ArrayBuffers`, the underlying memory for buffers is not initialized. So the contents of a newly created `Buffer` is unknown. Use `buf.fill(0)`to initialize a buffer to zeroes.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would just say:

The underlying memory of a Buffer is not initialized. If this behavior is desired, use Buffer.prototype.fill().

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added the 'Unlike ArrayBuffers... ' part as suggested by another core dev. I think it helps. If its the length, I can paraphrase it further. But the Buffer.protoype.fill() usage is inconsistent with rest of the documentation. Its gonna take a while to change all references to match it. What do you advice?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see a real need to mention ArrayBuffers at all, but I'm not strongly opposed to it. I guess it makes more sense to stick with the existing style of the docs.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about this?

Unlike, the underlying memory of a Buffer is not initialized. Use
buf.fill(0) to initialize a buffer to zeroes.

There's a comparison with ArrayBuffer in the explanation for #slice too. I'd say let's keep it. Ready to commit and push.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tjfontaine thoughts?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please wrap at 80 chars.

@trevnorris
Copy link

One style nit, but LGTM otherwise.

@jasnell
Copy link
Member

jasnell commented Jun 24, 2015

LGTM

@jasnell
Copy link
Member

jasnell commented Jun 26, 2015

Landed in 70efdf3

@jasnell jasnell closed this Jun 26, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants