(str: string | number, throwOnError = true)
| 160 | } |
| 161 | |
| 162 | export function parseMemoryMB(str: string | number, throwOnError = true) { |
| 163 | if (typeof str === 'number' || Number.isSafeInteger(+str)) return +str; |
| 164 | const match = MEMORY_RE.exec(str); |
| 165 | if (!match && throwOnError) throw new Error(`${str} error parsing memory`); |
| 166 | if (!match) return 256; |
| 167 | return Math.ceil(Number.parseFloat(match[1]) * MEMORY_UNITS[match[2].toLowerCase()]); |
| 168 | } |
| 169 | |
| 170 | function _digit2(number: number) { |
| 171 | return number < 10 ? `0${number}` : number.toString(); |
no outgoing calls
no test coverage detected