Total Complexity | 12 |
Complexity/F | 6 |
Lines of Code | 30 |
Function Count | 2 |
Duplicated Lines | 0 |
Ratio | 0 % |
Coverage | 100% |
Changes | 0 |
1 | /** |
||
2 | * @class Symbolizer |
||
3 | * @name Symbolizer |
||
4 | */ |
||
5 | 4 | export class Symbolizer { |
|
6 | 45 | symbols: string[] = [] |
|
7 | |||
8 | /** |
||
9 | * Initialize a symbolizer. |
||
10 | */ |
||
11 | constructor(symbols?: string) { |
||
12 | 45 | if (symbols) this.symbols = symbols.split('') |
|
13 | } |
||
14 | |||
15 | /** |
||
16 | * Symbol generator. |
||
17 | */ |
||
18 | *generator(): Generator<string> { |
||
19 | 30 | for (let i = 0; ; i++) { |
|
20 | 75 | if (i < this.symbols.length) { |
|
21 | 25 | yield this.symbols[i] ?? '?' |
|
22 | } else { |
||
23 | 50 | yield String.fromCharCode(945 + i - this.symbols.length) |
|
24 | } |
||
25 | } |
||
26 | } |
||
27 | } |
||
28 | |||
29 | export default Symbolizer |
||
30 |