All files / core/src/utilities indexAlmostWithinDimensions.ts

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

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 17 18 19 20 21 22 23 24 25 26 27 28 29 30                                41x               19x     22x    
import { EPSILON } from '../constants';
import type { Point3 } from '../types';
 
/**
 * Returns true if the specified index is within the given dimensions.
 *
 * @param index - The index to check.
 * @param dimensions - The dimensions to check against.
 *
 * @returns True if the index is in-bounds.
 */
 
export default function indexAlmostWithinDimensions(
  index: Point3,
  dimensions: Point3
): boolean {
  if (
    index[0] < -EPSILON ||
    index[0] >= dimensions[0] + EPSILON ||
    index[1] < -EPSILON ||
    index[1] >= dimensions[1] + EPSILON ||
    index[2] < -EPSILON ||
    index[2] >= dimensions[2] + EPSILON
  ) {
    return false;
  }
 
  return true;
}