range.up()

The math.range-up() or range.up() function returns the range of numbers where $from is lower than $to.

// Sass.
@use 'sass:list';

// Functions.
@use '../../meta/meta.of-type.function';

// The `math.range-up()` or `range.up` function.
@function up($from, $to, $step: 1, $except: null, $separator: auto) {
  @if meta.of-type(number, $from, $to, $step) and $from < $to {
    $result: ();
    $number: $from;
    @while $number <= $to {
      $result: if(
        not $except or ($except and not list.index($except, $number)),
        list.append($result, $number, $separator),
        $result
      );
      $number: $number + $step;
    }

    @return if(list.length($result) > 0, $result, null);
  }
  @return null;
}
https://github.com/angular-package/sass/blob/main/math/range/_range.up.function.scss

Parameters

$from

The value of the number type indicates the beginning of the range.

$to

The value of number type indicates the end of the range.

$step: 1

The value of number type indicates each increment of the range. By default, it's 1.

$except: null

The value of a number or list of numbers not belonging to the range.

$separator: auto

A separator between the given range numbers.

Return

The return value is the list of numbers from the given range.

Examples

Last updated

Was this helpful?