////
/// Checks for data types
/// @group Type Checks
/// @author Robin Radic
////

/// Check if the given value is a number
/// @param {*} $value - The value to check
/// @return {Bool} - True if is
@function is-number($value) {
    @return type-of($value) == 'number';
}

/// Check if the given value is a time ('ms' 's')
/// @param {*} $value - The value to check
/// @return {Bool} - True if is
@function is-time($value) {
    @return is-number($value) and index('ms' 's', unit($value)) != null;
}

/// Check if the given value is a duration
/// @param {*} $value - The value to check
/// @return {Bool} - True if is
@function is-duration($value) {
    @return is-time($value);
}

/// Check if the given value is a angle ('deg' 'rad' 'grad' 'turn')
/// @param {*} $value - The value to check
/// @return {Bool} - True if is
@function is-angle($value) {
    @return is-number($value) and index('deg' 'rad' 'grad' 'turn', unit($value)) != null;
}

/// Check if the given value is a frequency ('Hz' 'kHz')
/// @param {*} $value - The value to check
/// @return {Bool} - True if is
@function is-frequency($value) {
    @return is-number($value) and index('Hz' 'kHz', unit($value)) != null;
}

/// Check if the given value is a integer
/// @param {*} $value - The value to check
/// @return {Bool} - True if is
@function is-integer($value) {
    @return is-number($value) and round($value) == $value;
}

/// Check if the given value is a number('em' 'ex' 'ch' 'rem' 'vw' 'vh' 'vmin' 'vmax')
/// @param {*} $value - The value to check
/// @return {Bool} - True if is
@function is-relative-length($value) {
    @return is-number($value) and index('em' 'ex' 'ch' 'rem' 'vw' 'vh' 'vmin' 'vmax', unit($value)) != null;
}

/// Check if the given value is a absolute length ('cm' 'mm' 'in' 'px' 'pt' 'pc')
/// @param {*} $value - The value to check
/// @return {Bool} - True if is
@function is-absolute-length($value) {
    @return is-number($value) and index('cm' 'mm' 'in' 'px' 'pt' 'pc', unit($value)) != null;
}

/// Check if the given value is a percentage
/// @param {*} $value - The value to check
/// @return {Bool} - True if is
@function is-percentage($value) {
    @return is-number($value) and unit($value) == '%';
}

/// Check if the given value is a length
/// @param {*} $value - The value to check
/// @return {Bool} - True if is
@function is-length($value) {
    @return is-relative-length($value) or is-absolute-length($value);
}

/// Check if the given value is a resolution ('dpi' 'dpcm' 'dppx')
/// @param {*} $value - The value to check
/// @return {Bool} - True if is
@function is-resolution($value) {
    @return is-number($value) and index('dpi' 'dpcm' 'dppx', unit($value)) != null;
}

/// Check if the given value is a position ('top' 'right' 'bottom' 'left' 'center')
/// @param {*} $value - The value to check
/// @return {Bool} - True if is
@function is-position($value) {
    @return is-length($value) or is-percentage($value) or index('top' 'right' 'bottom' 'left' 'center', $value) != null;
}
