All files / packages/core/src/utilities indexWithinDimensions.ts

66.66% Statements 2/3
87.5% Branches 7/8
100% Functions 1/1
66.66% Lines 2/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                            127x                     127x    
import { 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 indexWithinDimensions(
  index: Point3,
  dimensions: Point3
): boolean {
  Iif (
    index[0] < 0 ||
    index[0] >= dimensions[0] ||
    index[1] < 0 ||
    index[1] >= dimensions[1] ||
    index[2] < 0 ||
    index[2] >= dimensions[2]
  ) {
    return false;
  }
 
  return true;
}