SassyLists 2.0.0 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +44 -43
- data/README.md +73 -73
- data/lib/SassyLists.rb +21 -21
- data/stylesheets/SassyLists/_chunk.scss +41 -41
- data/stylesheets/SassyLists/_comma-list.scss +9 -0
- data/stylesheets/SassyLists/_contain.scss +17 -17
- data/stylesheets/SassyLists/_count-values.scss +18 -18
- data/stylesheets/SassyLists/_debug.scss +96 -96
- data/stylesheets/SassyLists/_every.scss +17 -17
- data/stylesheets/SassyLists/_explode.scss +52 -52
- data/stylesheets/SassyLists/_first.scss +23 -23
- data/stylesheets/SassyLists/_flatten.scss +35 -35
- data/stylesheets/SassyLists/_insert-nth.scss +48 -48
- data/stylesheets/SassyLists/_intersection.scss +30 -30
- data/stylesheets/SassyLists/_is-empty.scss +18 -0
- data/stylesheets/SassyLists/_is-symmetrical.scss +20 -20
- data/stylesheets/SassyLists/_last-index.scss +20 -20
- data/stylesheets/SassyLists/_last.scss +17 -17
- data/stylesheets/SassyLists/_loop.scss +37 -37
- data/stylesheets/SassyLists/_prepend.scss +22 -22
- data/stylesheets/SassyLists/_purge.scss +29 -29
- data/stylesheets/SassyLists/_random-value.scss +29 -29
- data/stylesheets/SassyLists/_remove-duplicates.scss +24 -24
- data/stylesheets/SassyLists/_remove-nth.scss +21 -21
- data/stylesheets/SassyLists/_remove.scss +22 -22
- data/stylesheets/SassyLists/_replace-nth.scss +26 -26
- data/stylesheets/SassyLists/_replace.scss +32 -32
- data/stylesheets/SassyLists/_reverse.scss +29 -29
- data/stylesheets/SassyLists/_shuffle.scss +30 -30
- data/stylesheets/SassyLists/_slice.scss +53 -53
- data/stylesheets/SassyLists/_some.scss +17 -17
- data/stylesheets/SassyLists/_sort.scss +42 -42
- data/stylesheets/SassyLists/_sum.scss +28 -28
- data/stylesheets/SassyLists/_tail.scss +20 -20
- data/stylesheets/SassyLists/_to-list.scss +18 -0
- data/stylesheets/SassyLists/_to-map.scss +50 -50
- data/stylesheets/SassyLists/_to-string.scss +25 -25
- data/stylesheets/SassyLists/_union.scss +24 -24
- data/stylesheets/SassyLists/_walk.scss +23 -23
- data/stylesheets/SassyLists/helpers/_missing-dependencies.scss +22 -22
- data/stylesheets/SassyLists/helpers/_str-compare.scss +27 -27
- data/stylesheets/SassyLists/helpers/_true.scss +10 -10
- data/stylesheets/_SassyLists.scss +45 -42
- metadata +8 -5
@@ -1,30 +1,30 @@
|
|
1
|
-
// Shuffle `$list` using Fisher-Yates method.
|
2
|
-
//
|
3
|
-
// @ignore Documentation: http://sassylists.com/documentation
|
4
|
-
//
|
5
|
-
// @param {List} $list - list to shuffle
|
6
|
-
//
|
7
|
-
// @return {List}
|
8
|
-
|
9
|
-
@function sl-shuffle($list) {
|
10
|
-
$length: length($list);
|
11
|
-
|
12
|
-
@if $length < 2 {
|
13
|
-
@return $list;
|
14
|
-
}
|
15
|
-
|
16
|
-
@for $i from $length through 1 {
|
17
|
-
$j: random($length - 1) + 1;
|
18
|
-
$tmp: nth($list, $i);
|
19
|
-
$list: set-nth($list, $i, nth($list, $j));
|
20
|
-
$list: set-nth($list, $j, $tmp);
|
21
|
-
}
|
22
|
-
|
23
|
-
@return $list;
|
24
|
-
}
|
25
|
-
|
26
|
-
// @alias sl-shuffle
|
27
|
-
|
28
|
-
@function sl-randomize($list) {
|
29
|
-
@return sl-shuffle($list);
|
30
|
-
}
|
1
|
+
// Shuffle `$list` using Fisher-Yates method.
|
2
|
+
//
|
3
|
+
// @ignore Documentation: http://sassylists.com/documentation.html#sl-shuffle
|
4
|
+
//
|
5
|
+
// @param {List} $list - list to shuffle
|
6
|
+
//
|
7
|
+
// @return {List}
|
8
|
+
|
9
|
+
@function sl-shuffle($list) {
|
10
|
+
$length: length($list);
|
11
|
+
|
12
|
+
@if $length < 2 {
|
13
|
+
@return $list;
|
14
|
+
}
|
15
|
+
|
16
|
+
@for $i from $length through 1 {
|
17
|
+
$j: random($length - 1) + 1;
|
18
|
+
$tmp: nth($list, $i);
|
19
|
+
$list: set-nth($list, $i, nth($list, $j));
|
20
|
+
$list: set-nth($list, $j, $tmp);
|
21
|
+
}
|
22
|
+
|
23
|
+
@return $list;
|
24
|
+
}
|
25
|
+
|
26
|
+
// @alias sl-shuffle
|
27
|
+
|
28
|
+
@function sl-randomize($list) {
|
29
|
+
@return sl-shuffle($list);
|
30
|
+
}
|
@@ -1,54 +1,54 @@
|
|
1
|
-
// Slices `$list` between `$start` and `$end`.
|
2
|
-
//
|
3
|
-
// @ignore Documentation: http://sassylists.com/documentation
|
4
|
-
//
|
5
|
-
// @param {List} $list - list to slice
|
6
|
-
// @param {Number} $start (1) - start index
|
7
|
-
// @param {Number} $end (length($list)) - end index
|
8
|
-
//
|
9
|
-
// @throws List indexes $start and $end must be numbers for `sl-slice`.
|
10
|
-
// @throws Start index has to be lesser than or equals to the end index for `sl-slice`.
|
11
|
-
// @throws List indexes must be non-zero integers for `sl-slice`.
|
12
|
-
// @throws Start index has to be lesser than or equal to list length for `sl-slice`.
|
13
|
-
// @throws End index has to be lesser than or equal to list length for `sl-slice`.
|
14
|
-
//
|
15
|
-
// @return {List | Null}
|
16
|
-
|
17
|
-
@function sl-slice($list, $start: 1, $end: length($list)) {
|
18
|
-
@if type-of($start) != "number" or type-of($end) != "number" {
|
19
|
-
@warn "List indexes #{$start} and #{$end} must be numbers for `sl-slice`.";
|
20
|
-
@return null;
|
21
|
-
}
|
22
|
-
|
23
|
-
@if $start > $end {
|
24
|
-
@warn "Start index is #{$start} but has to be lesser than or equals to the end index (#{$end}) for `sl-slice`.";
|
25
|
-
@return null;
|
26
|
-
}
|
27
|
-
|
28
|
-
@if $start < 1 or $end < 1 {
|
29
|
-
@warn "List indexes must be non-zero integers for `sl-slice`.";
|
30
|
-
@return null;
|
31
|
-
}
|
32
|
-
|
33
|
-
@if $start > length($list) {
|
34
|
-
@warn "Start index is #{$start} but list is only #{length($list)} items long for `sl-slice`.";
|
35
|
-
@return null;
|
36
|
-
}
|
37
|
-
|
38
|
-
@if $end > length($list) {
|
39
|
-
@warn "End index is #{$end} but list is only #{length($list)} items long for `sl-slice`.";
|
40
|
-
@return null;
|
41
|
-
}
|
42
|
-
|
43
|
-
@if $start == $end {
|
44
|
-
@return nth($list, $start);
|
45
|
-
}
|
46
|
-
|
47
|
-
$result: ();
|
48
|
-
|
49
|
-
@for $i from $start through $end {
|
50
|
-
$result: append($result, nth($list, $i), list-separator($list));
|
51
|
-
}
|
52
|
-
|
53
|
-
@return $result;
|
1
|
+
// Slices `$list` between `$start` and `$end`.
|
2
|
+
//
|
3
|
+
// @ignore Documentation: http://sassylists.com/documentation.html#sl-slice
|
4
|
+
//
|
5
|
+
// @param {List} $list - list to slice
|
6
|
+
// @param {Number} $start (1) - start index
|
7
|
+
// @param {Number} $end (length($list)) - end index
|
8
|
+
//
|
9
|
+
// @throws List indexes $start and $end must be numbers for `sl-slice`.
|
10
|
+
// @throws Start index has to be lesser than or equals to the end index for `sl-slice`.
|
11
|
+
// @throws List indexes must be non-zero integers for `sl-slice`.
|
12
|
+
// @throws Start index has to be lesser than or equal to list length for `sl-slice`.
|
13
|
+
// @throws End index has to be lesser than or equal to list length for `sl-slice`.
|
14
|
+
//
|
15
|
+
// @return {List | Null}
|
16
|
+
|
17
|
+
@function sl-slice($list, $start: 1, $end: length($list)) {
|
18
|
+
@if type-of($start) != "number" or type-of($end) != "number" {
|
19
|
+
@warn "List indexes #{$start} and #{$end} must be numbers for `sl-slice`.";
|
20
|
+
@return null;
|
21
|
+
}
|
22
|
+
|
23
|
+
@if $start > $end {
|
24
|
+
@warn "Start index is #{$start} but has to be lesser than or equals to the end index (#{$end}) for `sl-slice`.";
|
25
|
+
@return null;
|
26
|
+
}
|
27
|
+
|
28
|
+
@if $start < 1 or $end < 1 {
|
29
|
+
@warn "List indexes must be non-zero integers for `sl-slice`.";
|
30
|
+
@return null;
|
31
|
+
}
|
32
|
+
|
33
|
+
@if $start > length($list) {
|
34
|
+
@warn "Start index is #{$start} but list is only #{length($list)} items long for `sl-slice`.";
|
35
|
+
@return null;
|
36
|
+
}
|
37
|
+
|
38
|
+
@if $end > length($list) {
|
39
|
+
@warn "End index is #{$end} but list is only #{length($list)} items long for `sl-slice`.";
|
40
|
+
@return null;
|
41
|
+
}
|
42
|
+
|
43
|
+
@if $start == $end {
|
44
|
+
@return nth($list, $start);
|
45
|
+
}
|
46
|
+
|
47
|
+
$result: ();
|
48
|
+
|
49
|
+
@for $i from $start through $end {
|
50
|
+
$result: append($result, nth($list, $i), list-separator($list));
|
51
|
+
}
|
52
|
+
|
53
|
+
@return $result;
|
54
54
|
}
|
@@ -1,17 +1,17 @@
|
|
1
|
-
// Tests whether some items from `$list` pass the test implemented by `$function`.
|
2
|
-
//
|
3
|
-
// @param {List} $list - list to run test against
|
4
|
-
// @param {String} $function - function to run against every item from list
|
5
|
-
// @param {ArgList} $args - extra arguments to pass to the function
|
6
|
-
//
|
7
|
-
// @return {Bool}
|
8
|
-
|
9
|
-
@function sl-some($list, $function, $args...) {
|
10
|
-
@each $item in $list {
|
11
|
-
@if call($function, $item, $args...) {
|
12
|
-
@return true;
|
13
|
-
}
|
14
|
-
}
|
15
|
-
|
16
|
-
@return false;
|
17
|
-
}
|
1
|
+
// Tests whether some items from `$list` pass the test implemented by `$function`.
|
2
|
+
//
|
3
|
+
// @param {List} $list - list to run test against
|
4
|
+
// @param {String} $function - function to run against every item from list
|
5
|
+
// @param {ArgList} $args - extra arguments to pass to the function
|
6
|
+
//
|
7
|
+
// @return {Bool}
|
8
|
+
|
9
|
+
@function sl-some($list, $function, $args...) {
|
10
|
+
@each $item in $list {
|
11
|
+
@if call($function, $item, $args...) {
|
12
|
+
@return true;
|
13
|
+
}
|
14
|
+
}
|
15
|
+
|
16
|
+
@return false;
|
17
|
+
}
|
@@ -1,42 +1,42 @@
|
|
1
|
-
// Sorts values of `$list` using quick-sort algorithm using `$order`.
|
2
|
-
//
|
3
|
-
// @ignore Documentation: http://sassylists.com/documentation
|
4
|
-
//
|
5
|
-
// @requires sl-str-compare
|
6
|
-
//
|
7
|
-
// @param {List} $list - list to sort
|
8
|
-
// @param {List} $order - order to respect
|
9
|
-
//
|
10
|
-
// @return {List}
|
11
|
-
|
12
|
-
@function sl-sort($list, $order: "!" "#" "$" "%" "&" "'" "(" ")" "*" "+" "," "-" "." "/" "[" "\\" "]" "^" "_" "{" "|" "}" "~" "0" "1" "2" "3" "4" "5" "6" "7" "8" "9" "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m" "n" "o" "p" "q" "r" "s" "t" "u" "v" "w" "x" "y" "z") {
|
13
|
-
@if sl-missing-dependencies(sl-str-compare) == true { @return null; }
|
14
|
-
|
15
|
-
$less: ();
|
16
|
-
$equal: ();
|
17
|
-
$large: ();
|
18
|
-
$length: length($list);
|
19
|
-
|
20
|
-
@if $length > 1 {
|
21
|
-
$seed: nth($list, ceil($length / 2));
|
22
|
-
@each $item in $list {
|
23
|
-
@if $item == $seed {
|
24
|
-
$equal: append($equal, $item, list-separator($list));
|
25
|
-
}
|
26
|
-
@else if sl-str-compare($item, $seed, $order) {
|
27
|
-
$less: append($less, $item, list-separator($list));
|
28
|
-
}
|
29
|
-
@else if not sl-str-compare($item, $seed, $order) {
|
30
|
-
$large: append($large, $item, list-separator($list));
|
31
|
-
}
|
32
|
-
}
|
33
|
-
@return join(join(sl-sort($less, $order), $equal), sl-sort($large, $order));
|
34
|
-
}
|
35
|
-
@return $list;
|
36
|
-
}
|
37
|
-
|
38
|
-
// @alias sl-sort
|
39
|
-
|
40
|
-
@function sl-order($list) {
|
41
|
-
@return sl-sort($list);
|
42
|
-
}
|
1
|
+
// Sorts values of `$list` using quick-sort algorithm using `$order`.
|
2
|
+
//
|
3
|
+
// @ignore Documentation: http://sassylists.com/documentation.html#sl-sort
|
4
|
+
//
|
5
|
+
// @requires sl-str-compare
|
6
|
+
//
|
7
|
+
// @param {List} $list - list to sort
|
8
|
+
// @param {List} $order - order to respect
|
9
|
+
//
|
10
|
+
// @return {List}
|
11
|
+
|
12
|
+
@function sl-sort($list, $order: "!" "#" "$" "%" "&" "'" "(" ")" "*" "+" "," "-" "." "/" "[" "\\" "]" "^" "_" "{" "|" "}" "~" "0" "1" "2" "3" "4" "5" "6" "7" "8" "9" "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m" "n" "o" "p" "q" "r" "s" "t" "u" "v" "w" "x" "y" "z") {
|
13
|
+
@if sl-missing-dependencies(sl-str-compare) == true { @return null; }
|
14
|
+
|
15
|
+
$less: ();
|
16
|
+
$equal: ();
|
17
|
+
$large: ();
|
18
|
+
$length: length($list);
|
19
|
+
|
20
|
+
@if $length > 1 {
|
21
|
+
$seed: nth($list, ceil($length / 2));
|
22
|
+
@each $item in $list {
|
23
|
+
@if $item == $seed {
|
24
|
+
$equal: append($equal, $item, list-separator($list));
|
25
|
+
}
|
26
|
+
@else if sl-str-compare($item, $seed, $order) {
|
27
|
+
$less: append($less, $item, list-separator($list));
|
28
|
+
}
|
29
|
+
@else if not sl-str-compare($item, $seed, $order) {
|
30
|
+
$large: append($large, $item, list-separator($list));
|
31
|
+
}
|
32
|
+
}
|
33
|
+
@return join(join(sl-sort($less, $order), $equal), sl-sort($large, $order));
|
34
|
+
}
|
35
|
+
@return $list;
|
36
|
+
}
|
37
|
+
|
38
|
+
// @alias sl-sort
|
39
|
+
|
40
|
+
@function sl-order($list) {
|
41
|
+
@return sl-sort($list);
|
42
|
+
}
|
@@ -1,28 +1,28 @@
|
|
1
|
-
// Sums up all numeric values in `$list`, stripping unit if `$force` set to `true`.
|
2
|
-
//
|
3
|
-
// @ignore Documentation: http://sassylists.com/documentation
|
4
|
-
//
|
5
|
-
// @param {List} $list - list
|
6
|
-
// @param {
|
7
|
-
//
|
8
|
-
// @return {Number}
|
9
|
-
|
10
|
-
@function sl-sum($list, $force: false) {
|
11
|
-
$result: 0;
|
12
|
-
|
13
|
-
@each $item in $list {
|
14
|
-
@if type-of($item) == number {
|
15
|
-
|
16
|
-
@if $force and not unitless($item) {
|
17
|
-
$item: $item / ($item * 0 + 1);
|
18
|
-
}
|
19
|
-
|
20
|
-
@if unitless($item) {
|
21
|
-
$result: $result + $item;
|
22
|
-
}
|
23
|
-
|
24
|
-
}
|
25
|
-
}
|
26
|
-
|
27
|
-
@return $result;
|
28
|
-
}
|
1
|
+
// Sums up all numeric values in `$list`, stripping unit if `$force` set to `true`.
|
2
|
+
//
|
3
|
+
// @ignore Documentation: http://sassylists.com/documentation.html#sl-sum
|
4
|
+
//
|
5
|
+
// @param {List} $list - list
|
6
|
+
// @param {Bool} $force (false) - enable/disable parseInt
|
7
|
+
//
|
8
|
+
// @return {Number}
|
9
|
+
|
10
|
+
@function sl-sum($list, $force: false) {
|
11
|
+
$result: 0;
|
12
|
+
|
13
|
+
@each $item in $list {
|
14
|
+
@if type-of($item) == number {
|
15
|
+
|
16
|
+
@if $force and not unitless($item) {
|
17
|
+
$item: $item / ($item * 0 + 1);
|
18
|
+
}
|
19
|
+
|
20
|
+
@if unitless($item) {
|
21
|
+
$result: $result + $item;
|
22
|
+
}
|
23
|
+
|
24
|
+
}
|
25
|
+
}
|
26
|
+
|
27
|
+
@return $result;
|
28
|
+
}
|
@@ -1,21 +1,21 @@
|
|
1
|
-
// Returns the tail of `$list`: all items except the first (head).
|
2
|
-
//
|
3
|
-
// @ignore Documentation: http://sassylists.com/documentation
|
4
|
-
//
|
5
|
-
// @requires sl-slice
|
6
|
-
//
|
7
|
-
// @param {List} $list - list to retrieve tail from
|
8
|
-
//
|
9
|
-
// @return {List | Null}
|
10
|
-
|
11
|
-
@function sl-tail($list) {
|
12
|
-
@if sl-missing-dependencies(sl-slice) == true { @return null; }
|
13
|
-
|
14
|
-
@return sl-slice($list, 2);
|
15
|
-
}
|
16
|
-
|
17
|
-
// @alias sl-tail
|
18
|
-
|
19
|
-
@function sl-rest($list) {
|
20
|
-
@return sl-tail($list);
|
1
|
+
// Returns the tail of `$list`: all items except the first (head).
|
2
|
+
//
|
3
|
+
// @ignore Documentation: http://sassylists.com/documentation.html#sl-tail
|
4
|
+
//
|
5
|
+
// @requires sl-slice
|
6
|
+
//
|
7
|
+
// @param {List} $list - list to retrieve tail from
|
8
|
+
//
|
9
|
+
// @return {List | Null}
|
10
|
+
|
11
|
+
@function sl-tail($list) {
|
12
|
+
@if sl-missing-dependencies(sl-slice) == true { @return null; }
|
13
|
+
|
14
|
+
@return sl-slice($list, 2);
|
15
|
+
}
|
16
|
+
|
17
|
+
// @alias sl-tail
|
18
|
+
|
19
|
+
@function sl-rest($list) {
|
20
|
+
@return sl-tail($list);
|
21
21
|
}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
// Casts `$value` into a list.
|
2
|
+
//
|
3
|
+
// @ignore Documentation: http://sassylists.com/documentation.html#sl-to-list
|
4
|
+
//
|
5
|
+
// @param {*} $value - value to cast to list
|
6
|
+
//
|
7
|
+
// @return {List}
|
8
|
+
|
9
|
+
@function sl-to-list($value) {
|
10
|
+
@return if(type-of($value) == "list", $value, ($value,));
|
11
|
+
}
|
12
|
+
|
13
|
+
// @requires sl-to-list
|
14
|
+
// @alias sl-to-list
|
15
|
+
|
16
|
+
@function sl-listify($value) {
|
17
|
+
@return sl-to-list($value);
|
18
|
+
}
|
@@ -1,51 +1,51 @@
|
|
1
|
-
//
|
2
|
-
// Useful for iterating through a list with an index variable.
|
3
|
-
// e.g. `@each $i, $value in to-map($list)`
|
4
|
-
//
|
5
|
-
// @author Andrey "Lolmaus" Mikhaylov
|
6
|
-
//
|
7
|
-
// @ignore Documentation: http://sassylists.com/documentation
|
8
|
-
//
|
9
|
-
// @param {List} $list - list to turn into map
|
10
|
-
// @param {Number} $start (1) - index to start with
|
11
|
-
//
|
12
|
-
// @throws List cannot be empty for `sl-to-map`.
|
13
|
-
// @throws $start is not a number for `sl-to-map`.
|
14
|
-
//
|
15
|
-
// @return {Map | Null}
|
16
|
-
|
17
|
-
@function sl-to-map($list, $start: 1) {
|
18
|
-
@if length($list) == 0 {
|
19
|
-
@warn "List cannot be empty for `sl-to-map`.";
|
20
|
-
@return null;
|
21
|
-
}
|
22
|
-
|
23
|
-
@if type-of($start) != "number" {
|
24
|
-
@warn "$start provided to `sl-to-map` was #{type-of($start)}, but it should be a number.";
|
25
|
-
@return null;
|
26
|
-
}
|
27
|
-
|
28
|
-
$map: ();
|
29
|
-
|
30
|
-
@for $index from 1 through length($list) {
|
31
|
-
$key: $index + $start - 1;
|
32
|
-
$value: nth($list, $index);
|
33
|
-
$map: map-merge($map, ($key: $value));
|
34
|
-
}
|
35
|
-
|
36
|
-
@return $map;
|
37
|
-
}
|
38
|
-
|
39
|
-
// @requires sl-to-map
|
40
|
-
// @alias sl-to-map
|
41
|
-
|
42
|
-
@function sl-enumerate($list, $start: 1) {
|
43
|
-
@return sl-to-map($list, $start);
|
44
|
-
}
|
45
|
-
|
46
|
-
// @requires sl-to-map
|
47
|
-
// @alias sl-to-map
|
48
|
-
|
49
|
-
@function sl-mapify($list, $start: 1) {
|
50
|
-
@return sl-to-map($list, $start);
|
1
|
+
// Casts `$list` into a map, using indexes as keys (starting with `$start`).
|
2
|
+
// Useful for iterating through a list with an index variable.
|
3
|
+
// e.g. `@each $i, $value in to-map($list)`
|
4
|
+
//
|
5
|
+
// @author Andrey "Lolmaus" Mikhaylov
|
6
|
+
//
|
7
|
+
// @ignore Documentation: http://sassylists.com/documentation.html#sl-to-map
|
8
|
+
//
|
9
|
+
// @param {List} $list - list to turn into map
|
10
|
+
// @param {Number} $start (1) - index to start with
|
11
|
+
//
|
12
|
+
// @throws List cannot be empty for `sl-to-map`.
|
13
|
+
// @throws $start is not a number for `sl-to-map`.
|
14
|
+
//
|
15
|
+
// @return {Map | Null}
|
16
|
+
|
17
|
+
@function sl-to-map($list, $start: 1) {
|
18
|
+
@if length($list) == 0 {
|
19
|
+
@warn "List cannot be empty for `sl-to-map`.";
|
20
|
+
@return null;
|
21
|
+
}
|
22
|
+
|
23
|
+
@if type-of($start) != "number" {
|
24
|
+
@warn "$start provided to `sl-to-map` was #{type-of($start)}, but it should be a number.";
|
25
|
+
@return null;
|
26
|
+
}
|
27
|
+
|
28
|
+
$map: ();
|
29
|
+
|
30
|
+
@for $index from 1 through length($list) {
|
31
|
+
$key: $index + $start - 1;
|
32
|
+
$value: nth($list, $index);
|
33
|
+
$map: map-merge($map, ($key: $value));
|
34
|
+
}
|
35
|
+
|
36
|
+
@return $map;
|
37
|
+
}
|
38
|
+
|
39
|
+
// @requires sl-to-map
|
40
|
+
// @alias sl-to-map
|
41
|
+
|
42
|
+
@function sl-enumerate($list, $start: 1) {
|
43
|
+
@return sl-to-map($list, $start);
|
44
|
+
}
|
45
|
+
|
46
|
+
// @requires sl-to-map
|
47
|
+
// @alias sl-to-map
|
48
|
+
|
49
|
+
@function sl-mapify($list, $start: 1) {
|
50
|
+
@return sl-to-map($list, $start);
|
51
51
|
}
|
@@ -1,26 +1,26 @@
|
|
1
|
-
// Joins all elements of `$list` with `$glue`.
|
2
|
-
//
|
3
|
-
// @ignore Documentation: http://sassylists.com/documentation
|
4
|
-
//
|
5
|
-
// @param {List} $list - list to cast
|
6
|
-
// @param {String} $glue ('') - value to use as a join string
|
7
|
-
//
|
8
|
-
// @return {String}
|
9
|
-
|
10
|
-
@function sl-to-string($list, $glue: '') {
|
11
|
-
$result: '';
|
12
|
-
$length: length($list);
|
13
|
-
|
14
|
-
@for $i from 1 through $length {
|
15
|
-
$item: nth($list, $i);
|
16
|
-
$result: $result + if(length($item) > 1, sl-to-string($item, $glue), $item + $glue);
|
17
|
-
}
|
18
|
-
|
19
|
-
@return quote(str-slice($result, 1, str-length($glue) * -1 - 1));
|
20
|
-
}
|
21
|
-
|
22
|
-
// @alias sl-to-string
|
23
|
-
|
24
|
-
@function sl-stringify($list, $glue: '') {
|
25
|
-
@return sl-to-string($list, $glue);
|
1
|
+
// Joins all elements of `$list` with `$glue`.
|
2
|
+
//
|
3
|
+
// @ignore Documentation: http://sassylists.com/documentation.html#sl-to-string
|
4
|
+
//
|
5
|
+
// @param {List} $list - list to cast
|
6
|
+
// @param {String} $glue ('') - value to use as a join string
|
7
|
+
//
|
8
|
+
// @return {String}
|
9
|
+
|
10
|
+
@function sl-to-string($list, $glue: '') {
|
11
|
+
$result: '';
|
12
|
+
$length: length($list);
|
13
|
+
|
14
|
+
@for $i from 1 through $length {
|
15
|
+
$item: nth($list, $i);
|
16
|
+
$result: $result + if(length($item) > 1, sl-to-string($item, $glue), $item + $glue);
|
17
|
+
}
|
18
|
+
|
19
|
+
@return quote(str-slice($result, 1, str-length($glue) * -1 - 1));
|
20
|
+
}
|
21
|
+
|
22
|
+
// @alias sl-to-string
|
23
|
+
|
24
|
+
@function sl-stringify($list, $glue: '') {
|
25
|
+
@return sl-to-string($list, $glue);
|
26
26
|
}
|
@@ -1,24 +1,24 @@
|
|
1
|
-
// Returns a list of values from `$lists` minus duplicates.
|
2
|
-
//
|
3
|
-
// @ignore Documentation: http://sassylists.com/documentation
|
4
|
-
//
|
5
|
-
// @requires sl-flatten
|
6
|
-
// @requires sl-remove-duplicates
|
7
|
-
//
|
8
|
-
// @param {ArgList} $lists - lists to unify
|
9
|
-
//
|
10
|
-
// @return {List}
|
11
|
-
|
12
|
-
@function sl-union($lists...) {
|
13
|
-
@if sl-missing-dependencies(sl-flatten, sl-remove-duplicates) == true { @return null; }
|
14
|
-
|
15
|
-
$result: sl-remove-duplicates(sl-flatten($lists));
|
16
|
-
|
17
|
-
@return if(length($result) == 1, nth($result, 1), $result);
|
18
|
-
}
|
19
|
-
|
20
|
-
// @alias sl-union
|
21
|
-
|
22
|
-
@function sl-merge($lists...) {
|
23
|
-
@return sl-union($lists...);
|
24
|
-
}
|
1
|
+
// Returns a list of values from `$lists` minus duplicates.
|
2
|
+
//
|
3
|
+
// @ignore Documentation: http://sassylists.com/documentation.html#sl-union
|
4
|
+
//
|
5
|
+
// @requires sl-flatten
|
6
|
+
// @requires sl-remove-duplicates
|
7
|
+
//
|
8
|
+
// @param {ArgList} $lists - lists to unify
|
9
|
+
//
|
10
|
+
// @return {List}
|
11
|
+
|
12
|
+
@function sl-union($lists...) {
|
13
|
+
@if sl-missing-dependencies(sl-flatten, sl-remove-duplicates) == true { @return null; }
|
14
|
+
|
15
|
+
$result: sl-remove-duplicates(sl-flatten($lists));
|
16
|
+
|
17
|
+
@return if(length($result) == 1, nth($result, 1), $result);
|
18
|
+
}
|
19
|
+
|
20
|
+
// @alias sl-union
|
21
|
+
|
22
|
+
@function sl-merge($lists...) {
|
23
|
+
@return sl-union($lists...);
|
24
|
+
}
|
@@ -1,24 +1,24 @@
|
|
1
|
-
// Apply `$function` to every item from `$list` passing $args as parameters.
|
2
|
-
//
|
3
|
-
// @ignore Documentation: http://sassylists.com/documentation
|
4
|
-
//
|
5
|
-
// @param {List} $list - list to update
|
6
|
-
// @param {String} $function - function to call on each value
|
7
|
-
// @param {ArgList} $args - optional function arguments
|
8
|
-
//
|
9
|
-
// @throws There is no $function function.
|
10
|
-
//
|
11
|
-
// @return {List | Null}
|
12
|
-
|
13
|
-
@function sl-walk($list, $function, $args...) {
|
14
|
-
@if not function-exists($function) {
|
15
|
-
@warn "There is no `#{$function}` function.";
|
16
|
-
@return null;
|
17
|
-
}
|
18
|
-
|
19
|
-
@for $i from 1 through length($list) {
|
20
|
-
$list: set-nth($list, $i, call($function, nth($list, $i), $args...));
|
21
|
-
}
|
22
|
-
|
23
|
-
@return $list;
|
1
|
+
// Apply `$function` to every item from `$list` passing $args as parameters.
|
2
|
+
//
|
3
|
+
// @ignore Documentation: http://sassylists.com/documentation.html#sl-walk
|
4
|
+
//
|
5
|
+
// @param {List} $list - list to update
|
6
|
+
// @param {String} $function - function to call on each value
|
7
|
+
// @param {ArgList} $args - optional function arguments
|
8
|
+
//
|
9
|
+
// @throws There is no $function function.
|
10
|
+
//
|
11
|
+
// @return {List | Null}
|
12
|
+
|
13
|
+
@function sl-walk($list, $function, $args...) {
|
14
|
+
@if not function-exists($function) {
|
15
|
+
@warn "There is no `#{$function}` function.";
|
16
|
+
@return null;
|
17
|
+
}
|
18
|
+
|
19
|
+
@for $i from 1 through length($list) {
|
20
|
+
$list: set-nth($list, $i, call($function, nth($list, $i), $args...));
|
21
|
+
}
|
22
|
+
|
23
|
+
@return $list;
|
24
24
|
}
|