Skip to content

Commit 0bc0b81

Browse files
committed
satisfy linter
1 parent 3c18a13 commit 0bc0b81

File tree

2 files changed

+18
-15
lines changed

2 files changed

+18
-15
lines changed

lib/buffer.js

+12-8
Original file line numberDiff line numberDiff line change
@@ -243,18 +243,22 @@ function copyImpl(source, target, targetStart, sourceStart, sourceEnd) {
243243

244244
function _copyActual(source, target, targetStart, sourceStart, sourceEnd) {
245245
// Enforce: 0 <= sourceStart <= sourceEnd
246-
if (!(0 <= sourceStart && sourceStart <= sourceEnd))
247-
throw new ERR_BUFFER_OUT_OF_BOUNDS();
246+
if (!(0 <= sourceStart && sourceStart <= sourceEnd)) {
247+
throw new ERR_BUFFER_OUT_OF_BOUNDS('expected 0 <= sourceStart <= sourceEnd' +
248+
' but got 0 <= ' + sourceStart + ' <= ' + sourceEnd);
249+
}
248250

249-
sourceEnd = Math.min(sourceEnd, source.byteLength);
251+
sourceEnd = MathMin(sourceEnd, source.byteLength);
250252

251253
// Enforce: 0 <= targetStart <= target.byteLength;
252-
if (!(0 <= targetStart && targetStart <= target.byteLength))
253-
throw new ERR_BUFFER_OUT_OF_BOUNDS();
254+
if (!(0 <= targetStart && targetStart <= target.byteLength)) {
255+
throw new ERR_BUFFER_OUT_OF_BOUNDS('expected 0 <= targetStart <= target.byteLength' +
256+
' but got 0 <= ' + targetStart + ' <= ' + target.byteLength);
257+
}
254258

255-
let sourceLength = sourceEnd - sourceStart;
256-
let targetLength = target.byteLength - targetStart;
257-
let copyLength = Math.min(sourceLength, targetLength);
259+
const sourceLength = sourceEnd - sourceStart;
260+
const targetLength = target.byteLength - targetStart;
261+
const copyLength = MathMin(sourceLength, targetLength);
258262

259263
_copy(source, target, targetStart, sourceStart, copyLength);
260264

test/parallel/test-buffer-concat.js

+6-7
Original file line numberDiff line numberDiff line change
@@ -99,16 +99,15 @@ assert.deepStrictEqual(
9999
assert.deepStrictEqual(Buffer.concat([new Uint8Array([0x41, 0x42]),
100100
new Uint8Array([0x43, 0x44])]),
101101
Buffer.from('ABCD'));
102-
102+
103+
103104
if (2 ** 32 + 1 <= kMaxLength) {
104-
let a = Buffer.alloc(2 ** 31, 0);
105-
let b = Buffer.alloc(2 ** 31, 1);
106-
let c = Buffer.alloc(1, 2);
107-
108-
let destin = Buffer.concat([a, b, c]);
105+
const a = Buffer.alloc(2 ** 31, 0);
106+
const b = Buffer.alloc(2 ** 31, 1);
107+
const c = Buffer.alloc(1, 2);
108+
const destin = Buffer.concat([a, b, c]);
109109

110110
assert.deepStrictEqual(destin.subarray(0, 2 ** 31), a);
111111
assert.deepStrictEqual(destin.subarray(2 ** 31, 2 ** 32), b);
112112
assert.deepStrictEqual(destin.subarray(2 ** 32), c);
113113
}
114-

0 commit comments

Comments
 (0)