Skip to content

Commit e4bf819

Browse files
Update src/utils/image.js
Reduce function calls for optimisation. Co-authored-by: Joshua Lochner <[email protected]>
1 parent 8860359 commit e4bf819

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/utils/image.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -324,11 +324,13 @@ export class RawImage {
324324
// the user passed a null value in.
325325
// This allows users to pass in something like `resize(320, null)` to
326326
// resize to 320 width, but maintain aspect ratio.
327-
if (isNullishDimension(width) && isNullishDimension(height)) {
327+
const nullish_width = isNullishDimension(width);
328+
const nullish_height = isNullishDimension(height);
329+
if (nullish_width && nullish_height) {
328330
return this;
329-
} else if (isNullishDimension(width)) {
331+
} else if (nullish_width) {
330332
width = (height / this.height) * this.width;
331-
} else if (isNullishDimension(height)) {
333+
} else if (nullish_height) {
332334
height = (width / this.width) * this.height;
333335
}
334336

0 commit comments

Comments
 (0)