diff options
author | Brian White <mscdex@mscdex.net> | 2014-10-09 16:07:50 -0400 |
---|---|---|
committer | Trevor Norris <trev.norris@gmail.com> | 2014-10-09 16:48:59 -0700 |
commit | 874dd590cf385baa534556eadee0fa5c2f985519 (patch) | |
tree | 9f0fde0c0da4f00ba1dd885dbc6f1b6e4157e281 /lib | |
parent | db7df57e0342a5a6922bd2700ffc78c5a99841c8 (diff) | |
download | node-new-874dd590cf385baa534556eadee0fa5c2f985519.tar.gz |
streams: make setDefaultEncoding() throw
PR-URL: https://github.com/joyent/node/pull/8529
Fixes: f04f3a0 "streams: set default encoding for writable streams"
[trev.norris@gmail.com: update tests to check if throws]
Signed-off-by: Trevor Norris <trev.norris@gmail.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/_stream_writable.js | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/lib/_stream_writable.js b/lib/_stream_writable.js index 11b57c78cd..92984eb08e 100644 --- a/lib/_stream_writable.js +++ b/lib/_stream_writable.js @@ -222,14 +222,12 @@ Writable.prototype.uncork = function() { }; Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) { - if (typeof encoding !== 'string') - return false; // node::ParseEncoding() requires lower case. - encoding = encoding.toLowerCase(); + if (typeof encoding === 'string') + encoding = encoding.toLowerCase(); if (!Buffer.isEncoding(encoding)) - return false; + throw new TypeError('Unknown encoding: ' + encoding); this._writableState.defaultEncoding = encoding; - return true; }; function decodeChunk(state, chunk, encoding) { |