All files get-denominators.ts

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

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                        1x 514x 500x 500x   58x 7x 7x   7x 7x  
import { type Numbering } from './numbering.ts';
 
/**
 * Returns an array of denominators based on the provided `denominators` parameter.
 *
 * - If `denominators` is `'common'`, returns the default set: `[1, 2, 3, 4, 5, 6, 7, 8, 12]`.
 * - If `denominators` is `'wrench'`, returns the wrench set: `[1, 2, 4, 8, 16, 32]`.
 * - Otherwise, returns the provided array of denominators.
 * @param denominators - The type or array of denominators to use. Can be `'common'`, `'wrench'`, or a custom array of numbers.
 * @returns An array of denominators as numbers.
 * @internal
 */
export function getDenominators(denominators: Numbering['denominators']): number[] {
  if (denominators === 'common' || denominators === undefined) {
    return [1, 2, 3, 4, 5, 6, 7, 8, 12];
  }
 
  if (denominators === 'wrench') {
    return [1, 2, 4, 8, 16, 32];
  }
 
  return denominators;
}