function parseDuration(duration, defaultDuration) {
        if (typeof duration === "number") {
            return duration;
        }

        if (typeof duration === "string") {
            let split = duration.match(/^([\d\.,]+)\s?([a-zA-Z]+)$/);

            if (split.length === 3) {
                let len = parseFloat(split[1]);
                let unit = split[2].replace(/s$/i, "").toLowerCase();
                if (unit === "m") {
                    unit = "ms";
                }

                return (len || 1) * (t[unit] || 0);
            }
        }

        return defaultDuration;
    }
Converts a duration string to an integer number of milliseconds.
@param {(string|number)} duration The string to convert.
@param {number} defaultDuration The default duration to return if
can't parse duration
@returns {number} The converted value in milliseconds, or the
defaultDuration if it can't be parsed.