src/modules/grid/domain/gridHelpers.ts   A
last analyzed

Complexity

Total Complexity 5
Complexity/F 1.25

Size

Lines of Code 33
Function Count 4

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 25
dl 0
loc 33
rs 10
c 0
b 0
f 0
wmc 5
mnd 1
bc 1
fnc 4
bpm 0.25
cpm 1.25
noi 0

4 Functions

Rating   Name   Duplication   Size   Complexity  
A gridHelpers.ts ➔ calculateBitValue 0 3 1
A gridHelpers.ts ➔ generateBoxAriaLabel 0 3 1
A gridHelpers.ts ➔ generateBoxConfigs 0 14 2
A gridHelpers.ts ➔ getBoxCount 0 3 1
1
export interface BoxConfig {
2
  index: number;
3
  bitValue: number;
4
  ariaLabel: string;
5
}
6
7
export function calculateBitValue(index: number): number {
8
  return Math.pow(2, 11 - index);
9
}
10
11
export function generateBoxAriaLabel(index: number, bitValue: number): string {
12
  return `Bit ${index + 1}, value ${bitValue}`;
13
}
14
15
export function generateBoxConfigs(): BoxConfig[] {
16
  const configs: BoxConfig[] = [];
17
18
  for (let i = 0; i < 12; i++) {
19
    const bitValue = calculateBitValue(i);
20
    configs.push({
21
      index: i,
22
      bitValue,
23
      ariaLabel: generateBoxAriaLabel(i, bitValue),
24
    });
25
  }
26
27
  return configs;
28
}
29
30
export function getBoxCount(): number {
31
  return 12;
32
}
33