MCPcopy Create free account
hub / github.com/angular/components / parseCssTime

Function parseCssTime

src/material/dialog/dialog-container.ts:269–286  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

267 * number, it is assumed to be in ms.
268 */
269function 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}

Callers 1

MatDialogContainerClass · 0.85

Calls 1

coerceNumberPropertyFunction · 0.90

Tested by

no test coverage detected