// Convert a string of comma-separated values into a list

@function to-list($string, $separator: ', ') {
  $list: ();
      
  @while str-index($string, $separator) {
    $index: 1;
    $comma-idx: str-index($string, $separator);
    $cut-string: str-slice($string, 0, $comma-idx - 1);
    $list: join($cut-string, $list);

    $string: str-slice($string, $comma-idx + 1);
  }

  $list: join($string, $list);

  @return reverse-list($list);
}
// Convert a string of comma-separated values into a list

@function to-list($string, $separator: ',') {
  @if type-of($string) != "string" {
    @warn "`to-list` function expecting a string for $string; #{type-of($string)} given.";
    @return false;
  }

  @if type-of($separator) != "string" {
    @warn "`to-list` function expecting a string for $separator; #{type-of($separator)} given.";
    @return false;
  }

  $list: ();
      
  @while str-index($string, $separator) {
    $index: 1;
    $comma-idx: str-index($string, $separator);
    $cut-string: str-slice($string, 0, $comma-idx - str-length($separator));
    $list: join($list, $cut-string);

    $string: str-slice($string, $comma-idx + str-length($separator));
  }

  @return join($list, $string);
}
Add some type checkers to to-list and remove need for reverse-list function
Add some type checkers to to-list and remove need for reverse-list function
