All files / math ceil-to-step.ts

100% Statements 1/1
100% Branches 1/1
100% Functions 1/1
100% Lines 1/1

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16                          8x    
import { snapToStep } from './internal';
 
/**
 * Rounds a number up to a multiple of a step, without float noise.
 *
 * @param value - The number to round up.
 * @param step - The step, a positive number. Defaults to `1`.
 * @returns The smallest multiple of `step` greater than or equal to `value`.
 * @example
 * ceilToStep(0.31, 0.1); // 0.4
 * ceilToStep(-7, 5); // -5
 */
export function ceilToStep(value: number, step = 1): number {
  return snapToStep(value, step, Math.ceil);
}