Skip to content

Commit

Permalink
string_decoder: don't cache Buffer.isEncoding
Browse files Browse the repository at this point in the history
Some modules are monkey-patching Buffer.isEncoding, so without this
they cannot do that.

Fixes: #1547
PR-URL: #1548
Reviewed-By: Evan Lucas <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
  • Loading branch information
mscdex committed Apr 28, 2015
1 parent e55fdc4 commit 0fa6c4a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/string_decoder.js
Original file line number Diff line number Diff line change
@@ -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);
}
}
Expand Down

0 comments on commit 0fa6c4a

Please sign in to comment.