From 898d4238208e46fc0f402c6f978ae0f77cb8edce Mon Sep 17 00:00:00 2001 From: Brian White Date: Tue, 28 Apr 2015 10:53:06 -0400 Subject: [PATCH] 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 PORT-PR-URL: https://github.com/iojs/io.js/pull/1560 PORT-FROM: v2.x / 0fa6c4a6fc7ed4a2dfe821f1d3a46d5f6ff43e69 Reviewed-By: Evan Lucas Reviewed-By: Ben Noordhuis --- lib/string_decoder.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/string_decoder.js b/lib/string_decoder.js index 61a3bb20d588d3..62ea38e08f051c 100644 --- a/lib/string_decoder.js +++ b/lib/string_decoder.js @@ -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); } }