(val: JSONValue)
| 23 | |
| 24 | /** Tries to make a boolean from this value. Throws if it is not a boolean. */ |
| 25 | export function valToBoolean(val: JSONValue): boolean { |
| 26 | if (typeof val !== 'boolean') { |
| 27 | throw new Error(`Not a boolean: ${val}, is a ${typeof val}`); |
| 28 | } |
| 29 | return val; |
| 30 | } |
| 31 | |
| 32 | /** |
| 33 | * Tries to convert the value (timestamp or date) to a JS Date. Throws an error |