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
PORT-PR-URL: #1560
PORT-FROM: v2.x / 0fa6c4a
Reviewed-By: Evan Lucas <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
  • Loading branch information
mscdex authored and Fishrock123 committed May 14, 2015
1 parent 65dd10e commit 898d423
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 898d423

Please sign in to comment.