Skip to content

Commit ed1a80d

Browse files
committed
Add the utils file
1 parent a9cda51 commit ed1a80d

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/js/utils.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/**
2+
* Rounds a number to the nearest 0.5 increment.
3+
* This reduces URL variations for DPR values.
4+
*
5+
* @param {number} value - The value to round.
6+
* @return {number} The rounded value (e.g., 1.666 -> 1.5, 2.3 -> 2.5).
7+
*/
8+
export const roundToHalf = ( value ) => {
9+
return Math.round( value * 2 ) / 2;
10+
};

0 commit comments

Comments
 (0)