(fields: Iterator<string>, showUnset = false)
| 50 | } |
| 51 | |
| 52 | export function decodeInt(fields: Iterator<string>, showUnset = false): number { |
| 53 | const r = fields.next() |
| 54 | if (r.done) throw new BadMessage('no more fields') |
| 55 | const s = r.value |
| 56 | if (showUnset) { |
| 57 | if (s === null || s === undefined || s.length === 0) return UNSET_INTEGER |
| 58 | return parseInt(s, 10) |
| 59 | } |
| 60 | return parseInt(s || '0', 10) |
| 61 | } |
| 62 | |
| 63 | export function decodeFloat(fields: Iterator<string>, showUnset = false): number { |
| 64 | const r = fields.next() |
no test coverage detected