at-import / SassyLists

MIT License
276 stars 27 forks source link

Update to-map #42

Closed KittyGiraudel closed 10 years ago

KittyGiraudel commented 10 years ago
// Casts `$list` into a map, using indexes as keys (starting with `$start`).
// Useful for iterating through a list with an index variable.
// e.g. `@each $index, $value in to-map($list)`
//
// @author Andrey "Lolmaus" Mikhaylov and Chris Eppstein
// 
// @ignore Documentation: http://sassylists.com/documentation.html#sl-to-map
// 
// @param {List} $list - list to turn into map
//
// @requires sl-range
// 
// @throws List cannot be empty for `sl-to-map`.
// 
// @return {Map | Null}

@function sl-to-map($list) {
  @if sl-missing-dependencies(sl-range) { @return null; }

  @if length($list) == 0 {
    @warn "List cannot be empty for `sl-to-map`.";
    @return null;
  }

  @return zip(sl-range(length($list)), $list);
}
KittyGiraudel commented 10 years ago

Ref https://github.com/sass/sass/issues/996.