-
-
Notifications
You must be signed in to change notification settings - Fork 34.2k
Closed
Labels
bufferIssues and PRs related to the buffer subsystem.Issues and PRs related to the buffer subsystem.docIssues and PRs related to the documentations.Issues and PRs related to the documentations.questionIssues that look for answers.Issues that look for answers.
Description
- Version: Node.js v7.1.0
- Platform: Darwin Kernel Version 16.1.0
As stated in the issue title, Buffer.isEncoding('') returns true.
Actually, passing an empty string to encoding options of fs.readFile, Buffer.from or other functions supporting encoding doesn't result in an error, because they use the default encoding utf8 as a fallback in that case.
From this point of view, '' is also a valid encoding and Buffer.isEncoding('') === true looks fine. However, if we approve this behavior of Buffer.isEncoding, I think it's inconsistent that Buffer.isEncoding returns false when it takes other falsy values − false, null, undefined etc.
So, which design of Buffer.isEncoding is most reasonable?
- There is no problem with the current behavior of
Buffer.isEncoding. Buffer.isEncodingshould returnfalsewhen it takes''.Buffer.isEncodingshould returntruewhen it takes any falsy values.
I support the second one and can create a pull request.
I'd like to hear your opinion. Thanks.
BrandonZacharie and calebsander
Metadata
Metadata
Assignees
Labels
bufferIssues and PRs related to the buffer subsystem.Issues and PRs related to the buffer subsystem.docIssues and PRs related to the documentations.Issues and PRs related to the documentations.questionIssues that look for answers.Issues that look for answers.