Skip to content

Commit 18967f4

Browse files
decareanorefack
authored andcommitted
buffer: increase coverage
Buffer.js file. L196 if (value == null) guarantees obj != null so L406 is unnecessary. Removing outer if statement L406 and L418.
1 parent 67d792a commit 18967f4

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

lib/buffer.js

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -404,17 +404,15 @@ function fromObject(obj) {
404404
return b;
405405
}
406406

407-
if (obj != null) {
408-
if (obj.length !== undefined || isAnyArrayBuffer(obj.buffer)) {
409-
if (typeof obj.length !== 'number' || obj.length !== obj.length) {
410-
return new FastBuffer();
411-
}
412-
return fromArrayLike(obj);
407+
if (obj.length !== undefined || isAnyArrayBuffer(obj.buffer)) {
408+
if (typeof obj.length !== 'number' || obj.length !== obj.length) {
409+
return new FastBuffer();
413410
}
411+
return fromArrayLike(obj);
412+
}
414413

415-
if (obj.type === 'Buffer' && Array.isArray(obj.data)) {
416-
return fromArrayLike(obj.data);
417-
}
414+
if (obj.type === 'Buffer' && Array.isArray(obj.data)) {
415+
return fromArrayLike(obj.data);
418416
}
419417
}
420418

0 commit comments

Comments
 (0)