diff --git a/lib/buffer.js b/lib/buffer.js index 53553253209923..88c0e8226dadfb 100644 --- a/lib/buffer.js +++ b/lib/buffer.js @@ -190,27 +190,21 @@ Buffer.compare = function compare(a, b) { Buffer.isEncoding = function(encoding) { - var loweredCase = false; - for (;;) { - switch (encoding) { - case 'hex': - case 'utf8': - case 'utf-8': - case 'ascii': - case 'binary': - case 'base64': - case 'ucs2': - case 'ucs-2': - case 'utf16le': - case 'utf-16le': - return true; - - default: - if (loweredCase) - return false; - encoding = ('' + encoding).toLowerCase(); - loweredCase = true; - } + var loweredCase = ('' + encoding).toLowerCase(); + switch (loweredCase) { + case 'hex': + case 'utf8': + case 'utf-8': + case 'ascii': + case 'binary': + case 'base64': + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return true; + default: + return false; } };