(val: JSONValue)
| 11 | * or Nested Resources. Throws an error when fails |
| 12 | */ |
| 13 | export function valToArray(val: JSONValue): string[] { |
| 14 | if (val == undefined) { |
| 15 | throw new Error(`Not an array: ${val}, is ${typeof val}`); |
| 16 | } |
| 17 | if (val.constructor == Array) { |
| 18 | // TODO: check this better |
| 19 | return val as string[]; |
| 20 | } |
| 21 | throw new Error(`Not an array: ${val}, is a ${typeof val}`); |
| 22 | } |
| 23 | |
| 24 | /** Tries to make a boolean from this value. Throws if it is not a boolean. */ |
| 25 | export function valToBoolean(val: JSONValue): boolean { |
no outgoing calls
no test coverage detected