From 38e77a05d639c099de1ecf020a850e214a35060f Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Mon, 3 Feb 2014 00:42:11 -0800 Subject: [PATCH] style --- index.js | 40 ++++++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/index.js b/index.js index 7b7d7c6..a148d4b 100644 --- a/index.js +++ b/index.js @@ -274,26 +274,34 @@ Buffer.prototype.write = function (string, offset, length, encoding) { } encoding = String(encoding || 'utf8').toLowerCase() + var ret switch (encoding) { case 'hex': - return _hexWrite(this, string, offset, length) + ret = _hexWrite(this, string, offset, length) + break case 'utf8': case 'utf-8': - return _utf8Write(this, string, offset, length) + ret = _utf8Write(this, string, offset, length) + break case 'ascii': - return _asciiWrite(this, string, offset, length) + ret = _asciiWrite(this, string, offset, length) + break case 'binary': - return _binaryWrite(this, string, offset, length) + ret = _binaryWrite(this, string, offset, length) + break case 'base64': - return _base64Write(this, string, offset, length) + ret = _base64Write(this, string, offset, length) + break case 'ucs2': case 'ucs-2': case 'utf16le': case 'utf-16le': - return _utf16leWrite(this, string, offset, length) + ret = _utf16leWrite(this, string, offset, length) + break default: throw new Error('Unknown encoding') } + return ret } Buffer.prototype.toString = function (encoding, start, end) { @@ -309,26 +317,34 @@ Buffer.prototype.toString = function (encoding, start, end) { if (end === start) return '' + var ret switch (encoding) { case 'hex': - return _hexSlice(self, start, end) + ret = _hexSlice(self, start, end) + break case 'utf8': case 'utf-8': - return _utf8Slice(self, start, end) + ret = _utf8Slice(self, start, end) + break case 'ascii': - return _asciiSlice(self, start, end) + ret = _asciiSlice(self, start, end) + break case 'binary': - return _binarySlice(self, start, end) + ret = _binarySlice(self, start, end) + break case 'base64': - return _base64Slice(self, start, end) + ret = _base64Slice(self, start, end) + break case 'ucs2': case 'ucs-2': case 'utf16le': case 'utf-16le': - return _utf16leSlice(self, start, end) + ret = _utf16leSlice(self, start, end) + break default: throw new Error('Unknown encoding') } + return ret } Buffer.prototype.toJSON = function () { -- 2.34.1