Total Complexity | 8 |
Complexity/F | 4 |
Lines of Code | 30 |
Function Count | 2 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | /*jslint |
||
5 | function id2alpha(id) { |
||
6 | 'use strict'; |
||
7 | |||
8 | if (id >= 0 && id < 26) { |
||
9 | return String.fromCharCode('A'.charCodeAt() + (id % 26)); |
||
10 | } |
||
11 | |||
12 | if (id >= 26 && id < 260) { |
||
13 | return String.fromCharCode('A'.charCodeAt() + (id % 26)) + String.fromCharCode('0'.charCodeAt() + (id / 26)); |
||
14 | } |
||
15 | |||
16 | return ""; |
||
17 | } |
||
18 | |||
19 | |||
20 | function alpha2id(alpha) { |
||
21 | 'use strict'; |
||
22 | |||
23 | alpha = alpha.toLowerCase(); |
||
24 | |||
25 | if (/^[a-z]$/.test(alpha)) { |
||
26 | return alpha.charCodeAt(0) - 'a'.charCodeAt(0); |
||
27 | } |
||
28 | |||
29 | if (/^[a-z][0-9]$/.test(alpha)) { |
||
30 | return (alpha.charCodeAt(0) - 'a'.charCodeAt(0)) + 26 * (alpha.charCodeAt(1) - '0'.charCodeAt(0)); |
||
31 | } |
||
32 | |||
33 | return -1; |
||
34 | } |
||
35 |