-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
buffer.toString() no longer accepts null as encoding #13936
Comments
It is most likely caused by the #11120 and listed among the semver-major changes. |
To be fair though, fixing this use case and the original use case (passing Whether we'd want to support such a change is another question (e.g. would anyone complain about not accepting |
I understand the rationale given in #11120. However, shouldn't |
|
Another +1 from me for keeping the 8.x behavior. I did not review the original PR because I saw it already had lots of love - but I'm definitely in favor of the behavior change. |
@vsemozhetbyt One small request … can you leave off the version-specific labels if the issue is the same on master? Otherwise it seems like the issue is only occuring on v8.x. :) |
Closing as expected behavior. |
Why is this the expected behavior? The signature of the method is: buffer.toString([encoding[, start[, end]]]) So |
That's how default arguments work in JavaScript in general: > function foo(arg = 5) { console.log(arg); }
> foo()
5
> foo(undefined)
5
> foo(null)
null However, it might be a good idea to document that explicitly.
Per the signature, it's only optional if |
Good and clarifying code snip. Thanks.
Completely right. Thanks, I was wrong. |
According to the doc,
buffer.toString([encoding[, start[, end]]])
:In Node 4/5/6/7 this works:
However, in Node 8,
null
does not work and producesTypeError: Unknown encoding: null
.Example:
Not sure why
null
is no longer considered "use the default value".The text was updated successfully, but these errors were encountered: