mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
lint
This commit is contained in:
@@ -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];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user