string_decoder: don't cache Buffer.isEncoding

Some modules are monkey-patching Buffer.isEncoding, so without this
they cannot do that.

Fixes: https://github.com/iojs/io.js/issues/1547
PR-URL: https://github.com/iojs/io.js/pull/1548
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
pull/1548/merge
Brian White 2015-04-28 10:53:06 -04:00
parent e55fdc47a7
commit 0fa6c4a6fc
1 changed files with 3 additions and 3 deletions

View File

@ -1,9 +1,9 @@
'use strict';
const isEncoding = Buffer.isEncoding;
function assertEncoding(encoding) {
if (encoding && !isEncoding(encoding)) {
// Do not cache `Buffer.isEncoding`, some modules monkey-patch it to support
// additional encodings
if (encoding && !Buffer.isEncoding(encoding)) {
throw new Error('Unknown encoding: ' + encoding);
}
}