Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
buffer: fix indentation nits
Fix indentation issues that will be flagged by upcoming stricter
linting.
  • Loading branch information
Trott committed Jul 13, 2017
commit 77b9375a74c8d1dc8ede38ce867b34c80506874e
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