Skip to content

Commit

Permalink
buffer: fix indentation nits
Browse files Browse the repository at this point in the history
Fix indentation issues that will be flagged by upcoming stricter
linting.

PR-URL: #14224
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
Trott committed Jul 17, 2017
1 parent 9cbfd5b commit e0340af
Showing 1 changed file with 45 additions and 25 deletions.
70 changes: 45 additions & 25 deletions lib/buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,9 @@ function Buffer(arg, encodingOrOffset, length) {
// Common case.
if (typeof arg === 'number') {
if (typeof encodingOrOffset === 'string') {
throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'string',
'string', arg);
throw new errors.TypeError(
'ERR_INVALID_ARG_TYPE', 'string', 'string', arg
);
}
return Buffer.alloc(arg);
}
Expand Down Expand Up @@ -172,13 +173,19 @@ Buffer.from = function(value, encodingOrOffset, length) {
if (isAnyArrayBuffer(value))
return fromArrayBuffer(value, encodingOrOffset, length);

if (value == null)
throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'first argument',
['string', 'buffer', 'arrayBuffer', 'array', 'array-like object'], value);
if (value == null) {
throw new errors.TypeError(
'ERR_INVALID_ARG_TYPE',
'first argument',
['string', 'buffer', 'arrayBuffer', 'array', 'array-like object'],
value
);
}

if (typeof value === 'number')
throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'value', 'not number',
value);
throw new errors.TypeError(
'ERR_INVALID_ARG_TYPE', 'value', 'not number', value
);

const valueOf = value.valueOf && value.valueOf();
if (valueOf != null && valueOf !== value)
Expand All @@ -194,8 +201,11 @@ Buffer.from = function(value, encodingOrOffset, length) {
length);
}

throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'first argument',
['string', 'buffer', 'arrayBuffer', 'array', 'array-like object']);
throw new errors.TypeError(
'ERR_INVALID_ARG_TYPE',
'first argument',
['string', 'buffer', 'arrayBuffer', 'array', 'array-like object']
);
};

Object.setPrototypeOf(Buffer, Uint8Array);
Expand Down Expand Up @@ -397,8 +407,9 @@ Buffer.isBuffer = function isBuffer(b) {

Buffer.compare = function compare(a, b) {
if (!isUint8Array(a) || !isUint8Array(b)) {
throw new errors.TypeError('ERR_INVALID_ARG_TYPE', ['buf1', 'buf2'],
['buffer', 'uint8Array']);
throw new errors.TypeError(
'ERR_INVALID_ARG_TYPE', ['buf1', 'buf2'], ['buffer', 'uint8Array']
);
}

if (a === b) {
Expand All @@ -415,8 +426,9 @@ Buffer.isEncoding = function(encoding) {
};
Buffer[internalUtil.kIsEncodingSymbol] = Buffer.isEncoding;

const kConcatErr = new errors.TypeError('ERR_INVALID_ARG_TYPE', 'list',
['array', 'buffer', 'uint8Array']);
const kConcatErr = new errors.TypeError(
'ERR_INVALID_ARG_TYPE', 'list', ['array', 'buffer', 'uint8Array']
);

Buffer.concat = function(list, length) {
var i;
Expand Down Expand Up @@ -474,8 +486,9 @@ function byteLength(string, encoding) {
return string.byteLength;
}

throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'string',
['string', 'buffer', 'arrayBuffer']);
throw new errors.TypeError(
'ERR_INVALID_ARG_TYPE', 'string', ['string', 'buffer', 'arrayBuffer']
);
}

const len = string.length;
Expand Down Expand Up @@ -632,9 +645,11 @@ Buffer.prototype.toString = function(encoding, start, end) {


Buffer.prototype.equals = function equals(b) {
if (!isUint8Array(b))
throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'otherBuffer',
['buffer', 'uint8Array']);
if (!isUint8Array(b)) {
throw new errors.TypeError(
'ERR_INVALID_ARG_TYPE', 'otherBuffer', ['buffer', 'uint8Array']
);
}
if (this === b)
return true;

Expand All @@ -658,9 +673,11 @@ Buffer.prototype.compare = function compare(target,
end,
thisStart,
thisEnd) {
if (!isUint8Array(target))
throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'target',
['buffer', 'uint8Array']);
if (!isUint8Array(target)) {
throw new errors.TypeError(
'ERR_INVALID_ARG_TYPE', 'target', ['buffer', 'uint8Array']
);
}
if (arguments.length === 1)
return compare_(this, target);

Expand Down Expand Up @@ -739,8 +756,9 @@ function bidirectionalIndexOf(buffer, val, byteOffset, encoding, dir) {
return binding.indexOfNumber(buffer, val, byteOffset, dir);
}

throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'val',
['string', 'buffer', 'uint8Array']);
throw new errors.TypeError(
'ERR_INVALID_ARG_TYPE', 'val', ['string', 'buffer', 'uint8Array']
);
}


Expand Down Expand Up @@ -878,8 +896,10 @@ Buffer.prototype.write = function(string, offset, length, encoding) {
// if someone is still calling the obsolete form of write(), tell them.
// we don't want eg buf.write("foo", "utf8", 10) to silently turn into
// buf.write("foo", "utf8"), so we can't ignore extra args
throw new errors.Error('ERR_NO_LONGER_SUPPORTED',
'Buffer.write(string, encoding, offset[, length])');
throw new errors.Error(
'ERR_NO_LONGER_SUPPORTED',
'Buffer.write(string, encoding, offset[, length])'
);
}

if (!encoding) return this.utf8Write(string, offset, length);
Expand Down

0 comments on commit e0340af

Please sign in to comment.