Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit e0340af

Browse files
committedJul 17, 2017
buffer: fix indentation nits
Fix indentation issues that will be flagged by upcoming stricter linting. PR-URL: #14224 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 9cbfd5b commit e0340af

File tree

1 file changed

+45
-25
lines changed

1 file changed

+45
-25
lines changed
 

‎lib/buffer.js

+45-25
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,9 @@ function Buffer(arg, encodingOrOffset, length) {
143143
// Common case.
144144
if (typeof arg === 'number') {
145145
if (typeof encodingOrOffset === 'string') {
146-
throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'string',
147-
'string', arg);
146+
throw new errors.TypeError(
147+
'ERR_INVALID_ARG_TYPE', 'string', 'string', arg
148+
);
148149
}
149150
return Buffer.alloc(arg);
150151
}
@@ -172,13 +173,19 @@ Buffer.from = function(value, encodingOrOffset, length) {
172173
if (isAnyArrayBuffer(value))
173174
return fromArrayBuffer(value, encodingOrOffset, length);
174175

175-
if (value == null)
176-
throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'first argument',
177-
['string', 'buffer', 'arrayBuffer', 'array', 'array-like object'], value);
176+
if (value == null) {
177+
throw new errors.TypeError(
178+
'ERR_INVALID_ARG_TYPE',
179+
'first argument',
180+
['string', 'buffer', 'arrayBuffer', 'array', 'array-like object'],
181+
value
182+
);
183+
}
178184

179185
if (typeof value === 'number')
180-
throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'value', 'not number',
181-
value);
186+
throw new errors.TypeError(
187+
'ERR_INVALID_ARG_TYPE', 'value', 'not number', value
188+
);
182189

183190
const valueOf = value.valueOf && value.valueOf();
184191
if (valueOf != null && valueOf !== value)
@@ -194,8 +201,11 @@ Buffer.from = function(value, encodingOrOffset, length) {
194201
length);
195202
}
196203

197-
throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'first argument',
198-
['string', 'buffer', 'arrayBuffer', 'array', 'array-like object']);
204+
throw new errors.TypeError(
205+
'ERR_INVALID_ARG_TYPE',
206+
'first argument',
207+
['string', 'buffer', 'arrayBuffer', 'array', 'array-like object']
208+
);
199209
};
200210

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

398408
Buffer.compare = function compare(a, b) {
399409
if (!isUint8Array(a) || !isUint8Array(b)) {
400-
throw new errors.TypeError('ERR_INVALID_ARG_TYPE', ['buf1', 'buf2'],
401-
['buffer', 'uint8Array']);
410+
throw new errors.TypeError(
411+
'ERR_INVALID_ARG_TYPE', ['buf1', 'buf2'], ['buffer', 'uint8Array']
412+
);
402413
}
403414

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

418-
const kConcatErr = new errors.TypeError('ERR_INVALID_ARG_TYPE', 'list',
419-
['array', 'buffer', 'uint8Array']);
429+
const kConcatErr = new errors.TypeError(
430+
'ERR_INVALID_ARG_TYPE', 'list', ['array', 'buffer', 'uint8Array']
431+
);
420432

421433
Buffer.concat = function(list, length) {
422434
var i;
@@ -474,8 +486,9 @@ function byteLength(string, encoding) {
474486
return string.byteLength;
475487
}
476488

477-
throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'string',
478-
['string', 'buffer', 'arrayBuffer']);
489+
throw new errors.TypeError(
490+
'ERR_INVALID_ARG_TYPE', 'string', ['string', 'buffer', 'arrayBuffer']
491+
);
479492
}
480493

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

633646

634647
Buffer.prototype.equals = function equals(b) {
635-
if (!isUint8Array(b))
636-
throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'otherBuffer',
637-
['buffer', 'uint8Array']);
648+
if (!isUint8Array(b)) {
649+
throw new errors.TypeError(
650+
'ERR_INVALID_ARG_TYPE', 'otherBuffer', ['buffer', 'uint8Array']
651+
);
652+
}
638653
if (this === b)
639654
return true;
640655

@@ -658,9 +673,11 @@ Buffer.prototype.compare = function compare(target,
658673
end,
659674
thisStart,
660675
thisEnd) {
661-
if (!isUint8Array(target))
662-
throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'target',
663-
['buffer', 'uint8Array']);
676+
if (!isUint8Array(target)) {
677+
throw new errors.TypeError(
678+
'ERR_INVALID_ARG_TYPE', 'target', ['buffer', 'uint8Array']
679+
);
680+
}
664681
if (arguments.length === 1)
665682
return compare_(this, target);
666683

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

742-
throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'val',
743-
['string', 'buffer', 'uint8Array']);
759+
throw new errors.TypeError(
760+
'ERR_INVALID_ARG_TYPE', 'val', ['string', 'buffer', 'uint8Array']
761+
);
744762
}
745763

746764

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

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

0 commit comments

Comments
 (0)
Please sign in to comment.