* Converts a CSS time string to a number in ms. If the given time is already a * number, it is assumed to be in ms.
(time: string | number | undefined)
| 267 | * number, it is assumed to be in ms. |
| 268 | */ |
| 269 | function parseCssTime(time: string | number | undefined): number | null { |
| 270 | if (time == null) { |
| 271 | return null; |
| 272 | } |
| 273 | if (typeof time === 'number') { |
| 274 | return time; |
| 275 | } |
| 276 | if (time.endsWith('ms')) { |
| 277 | return coerceNumberProperty(time.substring(0, time.length - 2)); |
| 278 | } |
| 279 | if (time.endsWith('s')) { |
| 280 | return coerceNumberProperty(time.substring(0, time.length - 1)) * 1000; |
| 281 | } |
| 282 | if (time === '0') { |
| 283 | return 0; |
| 284 | } |
| 285 | return null; // anything else is invalid. |
| 286 | } |
no test coverage detected