UNPKG

css-time

Version:

A tiny library that converts milliseconds to and from CSS time.

1 lines 483 B
!function(e){"use strict";function n(e){var n=t.exec(e);if(null===n)throw new Error("Invalid CSS time");return parseFloat(n[1])*("s"===n[3]?1e3:1)}function o(e){if("number"!=typeof e||isNaN(e))throw new Error("Invalid milliseconds");return e+"ms"}function r(){"function"==typeof define&&define.amd?define(function(){return i}):"undefined"!=typeof module&&null!==module&&module.exports?module.exports=i:e.cssTime=i}var t=/^([\-\+]?[0-9]+(\.[0-9]+)?)(m?s)$/,i={from:n,to:o};r()}(this);