summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorBrian White <mscdex@mscdex.net>2014-10-09 16:07:50 -0400
committerTrevor Norris <trev.norris@gmail.com>2014-10-09 16:48:59 -0700
commit874dd590cf385baa534556eadee0fa5c2f985519 (patch)
tree9f0fde0c0da4f00ba1dd885dbc6f1b6e4157e281 /lib
parentdb7df57e0342a5a6922bd2700ffc78c5a99841c8 (diff)
downloadnode-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.js8
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) {