You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
maybe require('buffer') could show a message #6891
I misread the doc, i did var Buffer = require('buffer'); and could not figure out why this was true Buffer.alloc===undefined.
Maybe node could display a warning message if someone tries to require buffer like i did, or, maybe it could throw an error as if it was not an existing package ?
Activity
bnoordhuis commentedon May 20, 2016
Node has no (reliable) way to determine how the return value of
require('buffer')is used.That would be a breaking change and rather disruptive to the ecosystem, so the chances of that happening are low.
What might be an option is to change
lib/buffer.jsso that it does:But personally, I don't think that's much of an improvement.
ChALkeR commentedon May 20, 2016
@mh-cbon Why should it throw?
bufferis an existing module, it's documented, and there is no way it's going to throw an error now. Moreover,require('buffer')is the documented way to getbuffer.INSPECT_MAX_BYTES: https://nodejs.org/api/buffer.html#buffer_buffer_inspect_max_bytes andbuffer.kMaxLength: https://nodejs.org/api/buffer.html#buffer_class_method_buffer_alloc_size_fill_encoding.mh-cbon commentedon May 20, 2016
:s I see, makes sense, thanks for information.
So i was thinking, maybe that sentence, at the beginning of the doc page about
Buffer, is misleadingThe Buffer class is a global within Node.js, making it unlikely that one would need to ever use require('buffer').As
require('buffer')is in fact a totally different thing ofBuffer.As a doc reader I d say it should stop right after the coma.
ChALkeR commentedon May 20, 2016
@mh-cbon Perhaps that should look like this instead:
But I'm not sure. /cc @nodejs/documentation
doc: clarify buffer class
doc: clarify buffer class
doc: clarify buffer class
doc: clarify buffer class