summaryrefslogtreecommitdiff
path: root/lib/string_decoder.js
diff options
context:
space:
mode:
authorRyan Dahl <ry@tinyclouds.org>2010-12-01 20:59:06 -0800
committerRyan Dahl <ry@tinyclouds.org>2010-12-01 20:59:06 -0800
commitdd53ceebe4e87ed2c71486e17cdcd33af88cec59 (patch)
tree436f09d076c79be675741e64283dc7a07c0aee7f /lib/string_decoder.js
parente232f6e7356531bb6ab50cdf9c82386538ae2c79 (diff)
downloadandroid-node-v8-dd53ceebe4e87ed2c71486e17cdcd33af88cec59.tar.gz
android-node-v8-dd53ceebe4e87ed2c71486e17cdcd33af88cec59.tar.bz2
android-node-v8-dd53ceebe4e87ed2c71486e17cdcd33af88cec59.zip
lint
Diffstat (limited to 'lib/string_decoder.js')
-rw-r--r--lib/string_decoder.js15
1 files changed, 8 insertions, 7 deletions
diff --git a/lib/string_decoder.js b/lib/string_decoder.js
index 59be68c99f..3ed2839047 100644
--- a/lib/string_decoder.js
+++ b/lib/string_decoder.js
@@ -1,5 +1,5 @@
-var StringDecoder = exports.StringDecoder = function (encoding) {
- this.encoding = (encoding || 'utf8').toLowerCase().replace(/[-_]/,'');
+var StringDecoder = exports.StringDecoder = function(encoding) {
+ this.encoding = (encoding || 'utf8').toLowerCase().replace(/[-_]/, '');
if (this.encoding === 'utf8') {
this.charBuffer = new Buffer(4);
this.charReceived = 0;
@@ -8,7 +8,7 @@ var StringDecoder = exports.StringDecoder = function (encoding) {
};
-StringDecoder.prototype.write = function (buffer) {
+StringDecoder.prototype.write = function(buffer) {
// If not utf8...
if (this.encoding !== 'utf8') {
return buffer.toString(this.encoding);
@@ -18,9 +18,9 @@ StringDecoder.prototype.write = function (buffer) {
// if our last write ended with an incomplete multibyte character
if (this.charLength) {
// determine how many remaining bytes this buffer has to offer for this char
- var i = (buffer.length >= this.charLength - this.charReceived)
- ? this.charLength - this.charReceived
- : buffer.length;
+ var i = (buffer.length >= this.charLength - this.charReceived) ?
+ this.charLength - this.charReceived :
+ buffer.length;
// add the new bytes to the char buffer
buffer.copy(this.charBuffer, this.charReceived, 0, i);
@@ -46,7 +46,8 @@ StringDecoder.prototype.write = function (buffer) {
// determine how many bytes we have to check at the end of this buffer
var i = (buffer.length >= 3) ? 3 : buffer.length;
- // figure out if one of the last i bytes of our buffer announces an incomplete char
+ // Figure out if one of the last i bytes of our buffer announces an
+ // incomplete char.
for (; i > 0; i--) {
c = buffer[buffer.length - i];