(value: any, errorMessage: string)
| 5 | |
| 6 | |
| 7 | export function tryIntConversion(value: any, errorMessage: string): number { |
| 8 | if (typeof value === 'string') { |
| 9 | try { |
| 10 | const parsed = parseInt(value, 10); |
| 11 | if (!isNaN(parsed)) { |
| 12 | return parsed; |
| 13 | } |
| 14 | } catch (error) { |
| 15 | throw new JsonHTTPResponseWithMessage(errorMessage); |
| 16 | } |
| 17 | |
| 18 | }else if (typeof value === 'number' && Number.isInteger(value) ){ |
| 19 | return value |
| 20 | } |
| 21 | throw new JsonHTTPResponseWithMessage(errorMessage); |
| 22 | } |
| 23 | |
| 24 | export async function serialize(data: any, withResult: boolean = true){ |
| 25 | if (isNullish(data)) { |
no outgoing calls
no test coverage detected