function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
/**
* Copyright IBM Corp. 2016, 2023
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/
/**
* Utility to parse aspect ratios into width & height values
*
* @example
* import {parseAspectRatio} from '@carbon/ibmdotcom-utilities';
*
* const [width, height] = parseAspectRatio('16x9');
* @param {string} aspectRatioString string in format <integer><separator><integer>
* @returns {Array} [widthInt, heightInt]
*/
function parseAspectRatio(aspectRatioString) {
if (typeof aspectRatioString !== 'string') {
throw new TypeError("parseAspectRatio expected a string but was given a ".concat(_typeof(aspectRatioString)));
}
var parsed = aspectRatioString.split(/[^0-9]{1}/).filter(function (i) {
return i;
});
if (parsed.length !== 2) {
throw new RangeError("Parsed aspect ratio should have a length of 2, but had ".concat(parsed.length, " instead"));
}
return parsed;
}
export default parseAspectRatio;