SassyLists 1.1.1 → 2.0.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 +8 -1
- data/README.md +73 -0
- data/lib/SassyLists.rb +15 -8
- data/stylesheets/SassyLists/_chunk.scss +6 -6
- data/stylesheets/SassyLists/_contain.scss +5 -5
- data/stylesheets/SassyLists/_count-values.scss +2 -2
- data/stylesheets/SassyLists/_debug.scss +6 -6
- data/stylesheets/SassyLists/_every.scss +17 -0
- data/stylesheets/SassyLists/_explode.scss +12 -9
- data/stylesheets/SassyLists/_first.scss +6 -6
- data/stylesheets/SassyLists/_flatten.scss +6 -6
- data/stylesheets/SassyLists/_insert-nth.scss +13 -11
- data/stylesheets/SassyLists/_intersection.scss +6 -4
- data/stylesheets/SassyLists/_is-symmetrical.scss +9 -7
- data/stylesheets/SassyLists/_last-index.scss +4 -4
- data/stylesheets/SassyLists/_last.scss +3 -3
- data/stylesheets/SassyLists/_loop.scss +10 -8
- data/stylesheets/SassyLists/_prepend.scss +8 -6
- data/stylesheets/SassyLists/_purge.scss +9 -7
- data/stylesheets/SassyLists/_random-value.scss +10 -10
- data/stylesheets/SassyLists/_remove-duplicates.scss +5 -5
- data/stylesheets/SassyLists/_remove-nth.scss +10 -8
- data/stylesheets/SassyLists/_remove.scss +9 -7
- data/stylesheets/SassyLists/_replace-nth.scss +11 -9
- data/stylesheets/SassyLists/_replace.scss +7 -4
- data/stylesheets/SassyLists/_reverse.scss +6 -6
- data/stylesheets/SassyLists/_shuffle.scss +6 -5
- data/stylesheets/SassyLists/_slice.scss +23 -18
- data/stylesheets/SassyLists/_some.scss +17 -0
- data/stylesheets/SassyLists/_sort.scss +11 -9
- data/stylesheets/SassyLists/_sum.scss +2 -2
- data/stylesheets/SassyLists/_tail.scss +10 -8
- data/stylesheets/SassyLists/_to-map.scss +51 -0
- data/stylesheets/SassyLists/_to-string.scss +6 -6
- data/stylesheets/SassyLists/_union.scss +11 -8
- data/stylesheets/SassyLists/_walk.scss +4 -4
- data/stylesheets/SassyLists/helpers/_missing-dependencies.scss +23 -0
- data/stylesheets/SassyLists/helpers/_str-compare.scss +5 -2
- data/stylesheets/SassyLists/helpers/_true.scss +2 -2
- data/stylesheets/_SassyLists.scss +5 -1
- metadata +13 -21
@@ -1,4 +1,4 @@
|
|
1
|
-
// Removes duplicate values from
|
1
|
+
// Removes duplicate values from `$list`.
|
2
2
|
//
|
3
3
|
// @ignore Documentation: http://sassylists.com/documentation/#remove-duplicates
|
4
4
|
//
|
@@ -6,7 +6,7 @@
|
|
6
6
|
//
|
7
7
|
// @return {List}
|
8
8
|
|
9
|
-
@function remove-duplicates($list) {
|
9
|
+
@function sl-remove-duplicates($list) {
|
10
10
|
$result: ();
|
11
11
|
|
12
12
|
@each $item in $list {
|
@@ -18,8 +18,8 @@
|
|
18
18
|
@return $result;
|
19
19
|
}
|
20
20
|
|
21
|
-
// @alias remove-duplicates
|
21
|
+
// @alias sl-remove-duplicates
|
22
22
|
|
23
|
-
@function unique($list) {
|
24
|
-
@return remove-duplicates($list);
|
23
|
+
@function sl-unique($list, $recursive: false) {
|
24
|
+
@return sl-remove-duplicates($list, $recursive);
|
25
25
|
}
|
@@ -1,20 +1,22 @@
|
|
1
|
-
// Removes value from
|
1
|
+
// Removes value from `$list` at index `$index`.
|
2
2
|
//
|
3
3
|
// @ignore Documentation: http://sassylists.com/documentation/#remove-nth
|
4
4
|
//
|
5
|
-
// @requires replace-nth
|
5
|
+
// @requires sl-replace-nth
|
6
6
|
//
|
7
7
|
// @param {List} $list - list to remove value from
|
8
8
|
// @param {Number} $index - index to remove
|
9
9
|
//
|
10
|
-
// @return {List |
|
10
|
+
// @return {List | Null}
|
11
11
|
|
12
|
-
@function remove-nth($list, $index) {
|
13
|
-
@
|
12
|
+
@function sl-remove-nth($list, $index) {
|
13
|
+
@if sl-missing-dependencies(sl-replace-nth) == true { @return null; }
|
14
|
+
|
15
|
+
@return sl-replace-nth($list, $index, "");
|
14
16
|
}
|
15
17
|
|
16
|
-
// @alias remove-nth
|
18
|
+
// @alias sl-remove-nth
|
17
19
|
|
18
|
-
@function without-nth($list, $index) {
|
19
|
-
@return remove-nth($list, $index);
|
20
|
+
@function sl-without-nth($list, $index) {
|
21
|
+
@return sl-remove-nth($list, $index);
|
20
22
|
}
|
@@ -1,8 +1,8 @@
|
|
1
|
-
// Removes value(s)
|
1
|
+
// Removes value(s) `$value` from `$list`.
|
2
2
|
//
|
3
3
|
// @ignore Documentation: http://sassylists.com/documentation/#remove
|
4
4
|
//
|
5
|
-
// @requires replace
|
5
|
+
// @requires sl-replace
|
6
6
|
//
|
7
7
|
// @param {List} $list - list to update
|
8
8
|
// @param {*} $value - value to remove
|
@@ -10,12 +10,14 @@
|
|
10
10
|
//
|
11
11
|
// @return {List}
|
12
12
|
|
13
|
-
@function remove($list, $value) {
|
14
|
-
@
|
13
|
+
@function sl-remove($list, $value) {
|
14
|
+
@if sl-missing-dependencies(sl-replace) == true { @return null; }
|
15
|
+
|
16
|
+
@return sl-replace($list, $value, null);
|
15
17
|
}
|
16
18
|
|
17
|
-
// @alias remove
|
19
|
+
// @alias sl-remove
|
18
20
|
|
19
|
-
@function without($list, $value) {
|
20
|
-
@return remove($list, $value);
|
21
|
+
@function sl-without($list, $value) {
|
22
|
+
@return sl-remove($list, $value);
|
21
23
|
}
|
@@ -1,24 +1,26 @@
|
|
1
|
-
// Replaces value at
|
1
|
+
// Replaces value at `$index` from `$list` by `$value`.
|
2
2
|
//
|
3
3
|
// @ignore Documentation: http://sassylists.com/documentation/#replace-nth
|
4
4
|
//
|
5
|
-
// @requires purge
|
6
|
-
// @requires is-true
|
5
|
+
// @requires sl-purge
|
6
|
+
// @requires sl-is-true
|
7
7
|
//
|
8
8
|
// @param {List} $list - list to update
|
9
9
|
// @param {Number} $index - index to update
|
10
10
|
// @param {*} $value - new value for index
|
11
11
|
//
|
12
|
-
// @throws Invalid index $index for `replace-nth`.
|
12
|
+
// @throws Invalid index $index for `sl-replace-nth`.
|
13
13
|
//
|
14
|
-
// @return {List |
|
14
|
+
// @return {List | Null}
|
15
|
+
|
16
|
+
@function sl-replace-nth($list, $index, $value) {
|
17
|
+
@if sl-missing-dependencies(sl-purge, sl-is-true) == true { @return null; }
|
15
18
|
|
16
|
-
@function replace-nth($list, $index, $value) {
|
17
19
|
@if type-of($index) != "number" or $index == 0 or abs($index) > length($list) {
|
18
|
-
@warn "Invalid index (#{$index}) for `replace-nth`.";
|
19
|
-
@return
|
20
|
+
@warn "Invalid index (#{$index}) for `sl-replace-nth`.";
|
21
|
+
@return null;
|
20
22
|
}
|
21
23
|
|
22
24
|
$list: set-nth($list, $index, $value);
|
23
|
-
@return if(not is-true($value), purge($list), $list);
|
25
|
+
@return if(not sl-is-true($value), sl-purge($list), $list);
|
24
26
|
}
|
@@ -1,8 +1,9 @@
|
|
1
|
-
// Replaces
|
1
|
+
// Replaces `$old` by `$new` in `$list`.
|
2
2
|
//
|
3
3
|
// @ignore Documentation: http://sassylists.com/documentation.html#replace
|
4
4
|
//
|
5
|
-
// @requires is-true
|
5
|
+
// @requires sl-is-true
|
6
|
+
// @requires sl-purge
|
6
7
|
//
|
7
8
|
// @param {List} $list - list to update
|
8
9
|
// @param {*} $old - value to replace
|
@@ -10,7 +11,9 @@
|
|
10
11
|
//
|
11
12
|
// @return {List}
|
12
13
|
|
13
|
-
@function replace($list, $old, $value) {
|
14
|
+
@function sl-replace($list, $old, $value) {
|
15
|
+
@if sl-missing-dependencies(sl-is-true, sl-purge) == true { @return null; }
|
16
|
+
|
14
17
|
$running: true;
|
15
18
|
|
16
19
|
@while $running {
|
@@ -26,5 +29,5 @@
|
|
26
29
|
|
27
30
|
}
|
28
31
|
|
29
|
-
@return if(not is-true($value), purge($list), $list);
|
32
|
+
@return if(not sl-is-true($value), sl-purge($list), $list);
|
30
33
|
}
|
@@ -1,12 +1,12 @@
|
|
1
|
-
// Reverses the order of
|
1
|
+
// Reverses the order of `$list`.
|
2
2
|
//
|
3
3
|
// @ignore Documentation: http://sassylists.com/documentation/#reverse
|
4
4
|
//
|
5
|
-
// @param {List} $list - list to
|
5
|
+
// @param {List} $list - list to reverse
|
6
6
|
//
|
7
7
|
// @return {List}
|
8
8
|
|
9
|
-
@function reverse($list) {
|
9
|
+
@function sl-reverse($list) {
|
10
10
|
$length: length($list);
|
11
11
|
$end: floor($length/2);
|
12
12
|
|
@@ -23,8 +23,8 @@
|
|
23
23
|
@return $list;
|
24
24
|
}
|
25
25
|
|
26
|
-
// @alias reverse
|
26
|
+
// @alias sl-reverse
|
27
27
|
|
28
|
-
@function mirror($list) {
|
29
|
-
@return reverse($list);
|
28
|
+
@function sl-mirror($list) {
|
29
|
+
@return sl-reverse($list);
|
30
30
|
}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
// Shuffle
|
1
|
+
// Shuffle `$list` using Fisher-Yates method.
|
2
2
|
//
|
3
3
|
// @ignore Documentation: http://sassylists.com/documentation/#shuffle
|
4
4
|
//
|
@@ -6,7 +6,7 @@
|
|
6
6
|
//
|
7
7
|
// @return {List}
|
8
8
|
|
9
|
-
@function shuffle($list) {
|
9
|
+
@function sl-shuffle($list) {
|
10
10
|
$length: length($list);
|
11
11
|
|
12
12
|
@if $length < 2 {
|
@@ -19,11 +19,12 @@
|
|
19
19
|
$list: set-nth($list, $i, nth($list, $j));
|
20
20
|
$list: set-nth($list, $j, $tmp);
|
21
21
|
}
|
22
|
+
|
22
23
|
@return $list;
|
23
24
|
}
|
24
25
|
|
25
|
-
// @alias shuffle
|
26
|
+
// @alias sl-shuffle
|
26
27
|
|
27
|
-
@function randomize($list) {
|
28
|
-
@return shuffle($list);
|
28
|
+
@function sl-randomize($list) {
|
29
|
+
@return sl-shuffle($list);
|
29
30
|
}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
// Slices
|
1
|
+
// Slices `$list` between `$start` and `$end`.
|
2
2
|
//
|
3
3
|
// @ignore Documentation: http://sassylists.com/documentation/#slice
|
4
4
|
//
|
@@ -6,41 +6,46 @@
|
|
6
6
|
// @param {Number} $start (1) - start index
|
7
7
|
// @param {Number} $end (length($list)) - end index
|
8
8
|
//
|
9
|
-
// @throws List indexes $start and $end must be numbers for `slice`.
|
10
|
-
// @throws Start index has to be lesser than or equals to the end index for `slice`.
|
11
|
-
// @throws List indexes must be non-zero integers for `slice`.
|
12
|
-
// @throws Start index has to be lesser than or equal to list length for `slice`.
|
13
|
-
// @throws End index has to be lesser than or equal to list length for `slice`.
|
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
14
|
//
|
15
|
-
// @return {List |
|
15
|
+
// @return {List | Null}
|
16
16
|
|
17
|
-
@function slice($list, $start: 1, $end: length($list)) {
|
17
|
+
@function sl-slice($list, $start: 1, $end: length($list)) {
|
18
18
|
@if type-of($start) != "number" or type-of($end) != "number" {
|
19
|
-
@warn "List indexes #{$start} and #{$end} must be numbers for `slice`.";
|
20
|
-
@return
|
19
|
+
@warn "List indexes #{$start} and #{$end} must be numbers for `sl-slice`.";
|
20
|
+
@return null;
|
21
21
|
}
|
22
22
|
|
23
23
|
@if $start > $end {
|
24
|
-
@warn "Start index is #{$start} but has to be lesser than or equals to the end index (#{$end}) for `slice`.";
|
25
|
-
@return
|
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
26
|
}
|
27
27
|
|
28
28
|
@if $start < 1 or $end < 1 {
|
29
|
-
@warn "List indexes must be non-zero integers for `slice`.";
|
30
|
-
@return
|
29
|
+
@warn "List indexes must be non-zero integers for `sl-slice`.";
|
30
|
+
@return null;
|
31
31
|
}
|
32
32
|
|
33
33
|
@if $start > length($list) {
|
34
|
-
@warn "Start index is #{$start} but list is only #{length($list)} items long for `slice`.";
|
35
|
-
@return
|
34
|
+
@warn "Start index is #{$start} but list is only #{length($list)} items long for `sl-slice`.";
|
35
|
+
@return null;
|
36
36
|
}
|
37
37
|
|
38
38
|
@if $end > length($list) {
|
39
|
-
@warn "End index is #{$end} but list is only #{length($list)} items long for `slice`.";
|
40
|
-
@return
|
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);
|
41
45
|
}
|
42
46
|
|
43
47
|
$result: ();
|
48
|
+
|
44
49
|
@for $i from $start through $end {
|
45
50
|
$result: append($result, nth($list, $i), list-separator($list));
|
46
51
|
}
|
@@ -0,0 +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,15 +1,17 @@
|
|
1
|
-
// Sorts values of
|
1
|
+
// Sorts values of `$list` using quick-sort algorithm using `$order`.
|
2
2
|
//
|
3
3
|
// @ignore Documentation: http://sassylists.com/documentation/#sort
|
4
4
|
//
|
5
|
-
// @requires str-compare
|
5
|
+
// @requires sl-str-compare
|
6
6
|
//
|
7
7
|
// @param {List} $list - list to sort
|
8
8
|
// @param {List} $order - order to respect
|
9
9
|
//
|
10
10
|
// @return {List}
|
11
11
|
|
12
|
-
@function 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") {
|
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
|
+
|
13
15
|
$less: ();
|
14
16
|
$equal: ();
|
15
17
|
$large: ();
|
@@ -21,20 +23,20 @@
|
|
21
23
|
@if $item == $seed {
|
22
24
|
$equal: append($equal, $item, list-separator($list));
|
23
25
|
}
|
24
|
-
@else if str-compare($item, $seed, $order) {
|
26
|
+
@else if sl-str-compare($item, $seed, $order) {
|
25
27
|
$less: append($less, $item, list-separator($list));
|
26
28
|
}
|
27
|
-
@else if not str-compare($item, $seed, $order) {
|
29
|
+
@else if not sl-str-compare($item, $seed, $order) {
|
28
30
|
$large: append($large, $item, list-separator($list));
|
29
31
|
}
|
30
32
|
}
|
31
|
-
@return join(join(sort($less, $order), $equal), sort($large, $order));
|
33
|
+
@return join(join(sl-sort($less, $order), $equal), sl-sort($large, $order));
|
32
34
|
}
|
33
35
|
@return $list;
|
34
36
|
}
|
35
37
|
|
36
|
-
// @alias sort
|
38
|
+
// @alias sl-sort
|
37
39
|
|
38
|
-
@function order($list) {
|
39
|
-
@return sort($list);
|
40
|
+
@function sl-order($list) {
|
41
|
+
@return sl-sort($list);
|
40
42
|
}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
// Sums up all numeric values in
|
1
|
+
// Sums up all numeric values in `$list`, stripping unit if `$force` set to `true`.
|
2
2
|
//
|
3
3
|
// @ignore Documentation: http://sassylists.com/documentation/#sum
|
4
4
|
//
|
@@ -7,7 +7,7 @@
|
|
7
7
|
//
|
8
8
|
// @return {Number}
|
9
9
|
|
10
|
-
@function sum($list, $force: false) {
|
10
|
+
@function sl-sum($list, $force: false) {
|
11
11
|
$result: 0;
|
12
12
|
|
13
13
|
@each $item in $list {
|
@@ -1,19 +1,21 @@
|
|
1
|
-
// Returns the tail of
|
1
|
+
// Returns the tail of `$list`: all items except the first (head).
|
2
2
|
//
|
3
3
|
// @ignore Documentation: http://sassylists.com/documentation/#tail
|
4
4
|
//
|
5
|
-
// @requires slice
|
5
|
+
// @requires sl-slice
|
6
6
|
//
|
7
7
|
// @param {List} $list - list to retrieve tail from
|
8
8
|
//
|
9
|
-
// @return {List |
|
9
|
+
// @return {List | Null}
|
10
10
|
|
11
|
-
@function tail($list) {
|
12
|
-
@
|
11
|
+
@function sl-tail($list) {
|
12
|
+
@if sl-missing-dependencies(sl-slice) == true { @return null; }
|
13
|
+
|
14
|
+
@return sl-slice($list, 2);
|
13
15
|
}
|
14
16
|
|
15
|
-
// @alias tail
|
17
|
+
// @alias sl-tail
|
16
18
|
|
17
|
-
@function rest($list) {
|
18
|
-
@return tail($list);
|
19
|
+
@function sl-rest($list) {
|
20
|
+
@return sl-tail($list);
|
19
21
|
}
|
@@ -0,0 +1,51 @@
|
|
1
|
+
// Cast a `$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/#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
|
+
}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
// Joins all elements of
|
1
|
+
// Joins all elements of `$list` with `$glue`.
|
2
2
|
//
|
3
3
|
// @ignore Documentation: http://sassylists.com/documentation/#to-string
|
4
4
|
//
|
@@ -7,20 +7,20 @@
|
|
7
7
|
//
|
8
8
|
// @return {String}
|
9
9
|
|
10
|
-
@function to-string($list, $glue: '') {
|
10
|
+
@function sl-to-string($list, $glue: '') {
|
11
11
|
$result: '';
|
12
12
|
$length: length($list);
|
13
13
|
|
14
14
|
@for $i from 1 through $length {
|
15
15
|
$item: nth($list, $i);
|
16
|
-
$result: $result + if(length($item) > 1, to-string($item, $glue), $item + $glue);
|
16
|
+
$result: $result + if(length($item) > 1, sl-to-string($item, $glue), $item + $glue);
|
17
17
|
}
|
18
18
|
|
19
19
|
@return quote(str-slice($result, 1, str-length($glue) * -1 - 1));
|
20
20
|
}
|
21
21
|
|
22
|
-
// @alias to-string
|
22
|
+
// @alias sl-to-string
|
23
23
|
|
24
|
-
@function stringify($list, $glue: '') {
|
25
|
-
@return to-string($list, $glue);
|
24
|
+
@function sl-stringify($list, $glue: '') {
|
25
|
+
@return sl-to-string($list, $glue);
|
26
26
|
}
|
@@ -1,21 +1,24 @@
|
|
1
|
-
// Returns a list of values from
|
1
|
+
// Returns a list of values from `$lists` minus duplicates.
|
2
2
|
//
|
3
3
|
// @ignore Documentation: http://sassylists.com/documentation/#union
|
4
4
|
//
|
5
|
-
// @requires flatten
|
6
|
-
// @requires remove-duplicates
|
5
|
+
// @requires sl-flatten
|
6
|
+
// @requires sl-remove-duplicates
|
7
7
|
//
|
8
8
|
// @param {ArgList} $lists - lists to unify
|
9
9
|
//
|
10
10
|
// @return {List}
|
11
11
|
|
12
|
-
@function union($lists...) {
|
13
|
-
|
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
|
+
|
14
17
|
@return if(length($result) == 1, nth($result, 1), $result);
|
15
18
|
}
|
16
19
|
|
17
|
-
// @alias union
|
20
|
+
// @alias sl-union
|
18
21
|
|
19
|
-
@function merge($lists...) {
|
20
|
-
@return union($lists...);
|
22
|
+
@function sl-merge($lists...) {
|
23
|
+
@return sl-union($lists...);
|
21
24
|
}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
// Apply
|
1
|
+
// Apply `$function` to every item from `$list` passing $args as parameters.
|
2
2
|
//
|
3
3
|
// @ignore Documentation: http://sassylists.com/documentation/#walk
|
4
4
|
//
|
@@ -8,12 +8,12 @@
|
|
8
8
|
//
|
9
9
|
// @throws There is no $function function.
|
10
10
|
//
|
11
|
-
// @return {List |
|
11
|
+
// @return {List | Null}
|
12
12
|
|
13
|
-
@function walk($list, $function, $args...) {
|
13
|
+
@function sl-walk($list, $function, $args...) {
|
14
14
|
@if not function-exists($function) {
|
15
15
|
@warn "There is no `#{$function}` function.";
|
16
|
-
@return
|
16
|
+
@return null;
|
17
17
|
}
|
18
18
|
|
19
19
|
@for $i from 1 through length($list) {
|
@@ -0,0 +1,23 @@
|
|
1
|
+
// Checks whether `$functions` exist in global scope.
|
2
|
+
//
|
3
|
+
// @access private
|
4
|
+
//
|
5
|
+
// @param {ArgList} $functions - list of functions to check for
|
6
|
+
//
|
7
|
+
// @return {Bool} Whether or not there are missing dependencies
|
8
|
+
|
9
|
+
@function sl-missing-dependencies($functions...) {
|
10
|
+
$missing-dependencies: ();
|
11
|
+
|
12
|
+
@each $function in $functions {
|
13
|
+
@if not function-exists($function) {
|
14
|
+
$missing-dependencies: append($missing-dependencies, $function, comma);
|
15
|
+
}
|
16
|
+
}
|
17
|
+
|
18
|
+
@if length($missing-dependencies) > 0 {
|
19
|
+
@warn "Unmet dependencies! The following functions are required: #{$missing-dependencies}.";
|
20
|
+
}
|
21
|
+
|
22
|
+
@return length($missing-dependencies) != 0;
|
23
|
+
}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
// Compares
|
1
|
+
// Compares `$a` and `$b` based on `$order`.
|
2
2
|
//
|
3
3
|
// @access private
|
4
4
|
//
|
@@ -8,12 +8,14 @@
|
|
8
8
|
//
|
9
9
|
// @return {Bool}
|
10
10
|
|
11
|
-
@function str-compare($a, $b, $order) {
|
11
|
+
@function sl-str-compare($a, $b, $order) {
|
12
12
|
@if type-of($a) == "number" and type-of($b) == "number" {
|
13
13
|
@return $a < $b;
|
14
14
|
}
|
15
|
+
|
15
16
|
$a: to-lower-case($a + unquote(""));
|
16
17
|
$b: to-lower-case($b + unquote(""));
|
18
|
+
|
17
19
|
@for $i from 1 through min(str-length($a), str-length($b)) {
|
18
20
|
$char-a: str-slice($a, $i, $i);
|
19
21
|
$char-b: str-slice($b, $i, $i);
|
@@ -21,5 +23,6 @@
|
|
21
23
|
@return index($order, $char-a) < index($order, $char-b);
|
22
24
|
}
|
23
25
|
}
|
26
|
+
|
24
27
|
@return str-length($a) < str-length($b);
|
25
28
|
}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
// Returns truthiness of
|
1
|
+
// Returns truthiness of `$value`.
|
2
2
|
//
|
3
3
|
// @access private
|
4
4
|
//
|
@@ -6,6 +6,6 @@
|
|
6
6
|
//
|
7
7
|
// @return {Bool}
|
8
8
|
|
9
|
-
@function is-true($value) {
|
9
|
+
@function sl-is-true($value) {
|
10
10
|
@return if($value == null, false, $value and $value != null and $value != "" and $value != ());
|
11
11
|
}
|
@@ -4,12 +4,14 @@
|
|
4
4
|
// CodePen: http://codepen.io/HugoGiraudel/pen/loAgq
|
5
5
|
// Repository: https://github.com/Team-Sass/SassyLists/
|
6
6
|
|
7
|
-
@import "SassyLists/helpers/
|
7
|
+
@import "SassyLists/helpers/missing-dependencies";
|
8
8
|
@import "SassyLists/helpers/str-compare";
|
9
|
+
@import "SassyLists/helpers/true";
|
9
10
|
@import "SassyLists/chunk";
|
10
11
|
@import "SassyLists/contain";
|
11
12
|
@import "SassyLists/count-values";
|
12
13
|
@import "SassyLists/debug";
|
14
|
+
@import "SassyLists/every";
|
13
15
|
@import "SassyLists/explode";
|
14
16
|
@import "SassyLists/first";
|
15
17
|
@import "SassyLists/flatten";
|
@@ -31,8 +33,10 @@
|
|
31
33
|
@import "SassyLists/shuffle";
|
32
34
|
@import "SassyLists/slice";
|
33
35
|
@import "SassyLists/sort";
|
36
|
+
@import "SassyLists/some";
|
34
37
|
@import "SassyLists/sum";
|
35
38
|
@import "SassyLists/tail";
|
39
|
+
@import "SassyLists/to-map";
|
36
40
|
@import "SassyLists/to-string";
|
37
41
|
@import "SassyLists/union";
|
38
42
|
@import "SassyLists/walk";
|