| 152 | // We could use the conversion functions but it seems that doing the conversion |
| 153 | // via toString is just as good and slightly more generic... |
| 154 | function int(val) { |
| 155 | if (typeof val === 'number') { |
| 156 | return Number.isInteger(val) ? val : undefined; |
| 157 | } |
| 158 | if (typeof val === 'object') { |
| 159 | let n = parseInt(val.toString()); |
| 160 | return isNaN(n) ? undefined : n; |
| 161 | } |
| 162 | return undefined; |
| 163 | } |
| 164 | |
| 165 | function is_live_session() { |
| 166 | // Assume that there is a single session (not sure how to get multiple ones |