(a: undefined | boolean | 'optional' | HostGPURequirements, b: undefined | boolean | 'optional' | HostGPURequirements)
| 223 | } |
| 224 | |
| 225 | function mergeGpuRequirements(a: undefined | boolean | 'optional' | HostGPURequirements, b: undefined | boolean | 'optional' | HostGPURequirements): undefined | boolean | 'optional' | HostGPURequirements { |
| 226 | // simple cases if either are undefined/false we use the other one |
| 227 | if (a === undefined || a === false) { |
| 228 | return b; |
| 229 | } else if (b === undefined || b === false) { |
| 230 | return a; |
| 231 | } else if (a === 'optional' && b === 'optional') { |
| 232 | return 'optional'; |
| 233 | } else { |
| 234 | const aObject = asHostGPURequirements(a); |
| 235 | const bObject = asHostGPURequirements(b); |
| 236 | const cores = Math.max(aObject.cores || 0, bObject.cores || 0); |
| 237 | const memory = Math.max(parseBytes(aObject.memory || '0'), parseBytes(bObject.memory || '0')); |
| 238 | return { |
| 239 | cores: cores ? cores : undefined, |
| 240 | memory: memory ? `${memory}` : undefined, |
| 241 | }; |
| 242 | } |
| 243 | } |
| 244 | |
| 245 | function asHostGPURequirements(a: undefined | boolean | 'optional' | HostGPURequirements): HostGPURequirements { |
| 246 | if (typeof a !== 'object') { |
nothing calls this directly
no test coverage detected