Passed
Push — main ( 590153...ba27c8 )
by Dylan
04:30
created

Symbolizer.generator   A

Complexity

Conditions 4

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 4

Importance

Changes 0
Metric Value
cc 4
eloc 7
dl 0
loc 11
ccs 4
cts 4
cp 1
crap 4
rs 10
c 0
b 0
f 0
1
/**
2
 * @class Symbolizer
3
 * @name Symbolizer
4
 */
5 3
export class Symbolizer {
6 10
  symbols: string[] = []
7
8
  /**
9
   * Initialize a symbolizer.
10
   */
11
  constructor(symbols?: string) {
12 10
    if (symbols) this.symbols = symbols.split('')
13
  }
14
  
15
  /**
16
   * Symbol generator.
17
   */
18
  *generator(): Generator<string> {
19 6
    for (let i=0;;i++) {
20 38
      if (i < this.symbols.length) {
21 9
        yield this.symbols[i]
22
      }
23
      else {
24 29
        yield String.fromCharCode(945 + i - this.symbols.length)
25
      }
26
    }
27
  }
28
}
29
30
export default Symbolizer
31