(articles: number)
| 102 | * plain scan over twelve entries rather than anything that allocates. |
| 103 | */ |
| 104 | export function levelOf(articles: number): number { |
| 105 | if (articles <= 0) { |
| 106 | return 0; |
| 107 | } |
| 108 | let level = 1; |
| 109 | for (let i = 0; i < LEVELS.length; i += 1) { |
| 110 | if (articles >= LEVELS[i].reads) { |
| 111 | level = i + 1; |
| 112 | } |
| 113 | } |
| 114 | return level; |
| 115 | } |
| 116 | |
| 117 | /** The minimum a district needs to sit on `level`, and 0 for untouched ground. */ |
| 118 | export const floorOf = (level: number): number => |
no outgoing calls
no test coverage detected