SassyLists 2.0.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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,20 +1,20 @@
|
|
1
|
-
// Returns last index of `$value` in `$list`.
|
2
|
-
//
|
3
|
-
// @ignore Documentation: http://sassylists.com/documentation
|
4
|
-
//
|
5
|
-
// @param {List} $list - list to search
|
6
|
-
// @param {*} $value - value to be searched for
|
7
|
-
//
|
8
|
-
// @return {Number | Null}
|
9
|
-
|
10
|
-
@function sl-last-index($list, $value) {
|
11
|
-
$length: length($list);
|
12
|
-
|
13
|
-
@for $i from $length through 1 {
|
14
|
-
@if nth($list, $i) == $value {
|
15
|
-
@return $i;
|
16
|
-
}
|
17
|
-
}
|
18
|
-
|
19
|
-
@return null;
|
20
|
-
}
|
1
|
+
// Returns last index of `$value` in `$list`.
|
2
|
+
//
|
3
|
+
// @ignore Documentation: http://sassylists.com/documentation.html#sl-last-index
|
4
|
+
//
|
5
|
+
// @param {List} $list - list to search
|
6
|
+
// @param {*} $value - value to be searched for
|
7
|
+
//
|
8
|
+
// @return {Number | Null}
|
9
|
+
|
10
|
+
@function sl-last-index($list, $value) {
|
11
|
+
$length: length($list);
|
12
|
+
|
13
|
+
@for $i from $length through 1 {
|
14
|
+
@if nth($list, $i) == $value {
|
15
|
+
@return $i;
|
16
|
+
}
|
17
|
+
}
|
18
|
+
|
19
|
+
@return null;
|
20
|
+
}
|
@@ -1,18 +1,18 @@
|
|
1
|
-
// Returns last element of `$list`.
|
2
|
-
//
|
3
|
-
// @ignore Documentation: http://sassylists.com/documentation
|
4
|
-
//
|
5
|
-
// @param {List} $list - list to retrieve last value from
|
6
|
-
//
|
7
|
-
// @throws Cannot find last item of empty list.
|
8
|
-
//
|
9
|
-
// @return {*}
|
10
|
-
|
11
|
-
@function sl-last($list) {
|
12
|
-
@if length($list) == 0 {
|
13
|
-
@warn "Cannot find last item of empty list.";
|
14
|
-
@return null;
|
15
|
-
}
|
16
|
-
|
17
|
-
@return nth($list, -1);
|
1
|
+
// Returns last element of `$list`.
|
2
|
+
//
|
3
|
+
// @ignore Documentation: http://sassylists.com/documentation.html#sl-last
|
4
|
+
//
|
5
|
+
// @param {List} $list - list to retrieve last value from
|
6
|
+
//
|
7
|
+
// @throws Cannot find last item of empty list.
|
8
|
+
//
|
9
|
+
// @return {*}
|
10
|
+
|
11
|
+
@function sl-last($list) {
|
12
|
+
@if length($list) == 0 {
|
13
|
+
@warn "Cannot find last item of empty list.";
|
14
|
+
@return null;
|
15
|
+
}
|
16
|
+
|
17
|
+
@return nth($list, -1);
|
18
18
|
}
|
@@ -1,38 +1,38 @@
|
|
1
|
-
// Shift indexes from `$list` of `$value`.
|
2
|
-
//
|
3
|
-
// @author Ana Tudor
|
4
|
-
//
|
5
|
-
// @ignore Documentation: http://sassylists.com/documentation
|
6
|
-
//
|
7
|
-
// @param {List} $list - list to update
|
8
|
-
// @param {Number} $value (1) - number of position between old and new indexes
|
9
|
-
//
|
10
|
-
// @throws $value is not a number for `loop`.
|
11
|
-
//
|
12
|
-
// @return {List | Null}
|
13
|
-
|
14
|
-
@function sl-loop($list, $value: 1) {
|
15
|
-
@if type-of($value) != "number" {
|
16
|
-
@warn "#{$value} is not a number for `sl-loop`.";
|
17
|
-
@return null;
|
18
|
-
}
|
19
|
-
|
20
|
-
@if length($list) < 2 {
|
21
|
-
@return $list;
|
22
|
-
}
|
23
|
-
|
24
|
-
$result: ();
|
25
|
-
$length: length($list);
|
26
|
-
|
27
|
-
@for $i from 0 to $length {
|
28
|
-
$result: append($result, nth($list, ($i - $value) % $length + 1), list-separator($list));
|
29
|
-
}
|
30
|
-
|
31
|
-
@return $result;
|
32
|
-
}
|
33
|
-
|
34
|
-
// @alias sl-loop
|
35
|
-
|
36
|
-
@function sl-shift-indexes($list, $value: 1) {
|
37
|
-
@return sl-loop($list, $value);
|
1
|
+
// Shift indexes from `$list` of `$value`.
|
2
|
+
//
|
3
|
+
// @author Ana Tudor
|
4
|
+
//
|
5
|
+
// @ignore Documentation: http://sassylists.com/documentation.html#sl-loop
|
6
|
+
//
|
7
|
+
// @param {List} $list - list to update
|
8
|
+
// @param {Number} $value (1) - number of position between old and new indexes
|
9
|
+
//
|
10
|
+
// @throws $value is not a number for `loop`.
|
11
|
+
//
|
12
|
+
// @return {List | Null}
|
13
|
+
|
14
|
+
@function sl-loop($list, $value: 1) {
|
15
|
+
@if type-of($value) != "number" {
|
16
|
+
@warn "#{$value} is not a number for `sl-loop`.";
|
17
|
+
@return null;
|
18
|
+
}
|
19
|
+
|
20
|
+
@if length($list) < 2 {
|
21
|
+
@return $list;
|
22
|
+
}
|
23
|
+
|
24
|
+
$result: ();
|
25
|
+
$length: length($list);
|
26
|
+
|
27
|
+
@for $i from 0 to $length {
|
28
|
+
$result: append($result, nth($list, ($i - $value) % $length + 1), list-separator($list));
|
29
|
+
}
|
30
|
+
|
31
|
+
@return $result;
|
32
|
+
}
|
33
|
+
|
34
|
+
// @alias sl-loop
|
35
|
+
|
36
|
+
@function sl-shift-indexes($list, $value: 1) {
|
37
|
+
@return sl-loop($list, $value);
|
38
38
|
}
|
@@ -1,22 +1,22 @@
|
|
1
|
-
// Adds `$value` as first index of `$list`.
|
2
|
-
//
|
3
|
-
// @ignore Documentation: http://sassylists.com/documentation
|
4
|
-
//
|
5
|
-
// @requires sl-is-true
|
6
|
-
//
|
7
|
-
// @param {List} $list - list to preprend value to
|
8
|
-
// @param {*} $value - value to prepend to the list
|
9
|
-
//
|
10
|
-
// @return {List}
|
11
|
-
|
12
|
-
@function sl-prepend($list, $value) {
|
13
|
-
@if missing-dependencies(sl-is-true) == true { @return null; }
|
14
|
-
|
15
|
-
@if sl-is-true($value) {
|
16
|
-
@return join($value, $list, list-separator($list));
|
17
|
-
}
|
18
|
-
|
19
|
-
@else {
|
20
|
-
@return $list;
|
21
|
-
}
|
22
|
-
}
|
1
|
+
// Adds `$value` as first index of `$list`.
|
2
|
+
//
|
3
|
+
// @ignore Documentation: http://sassylists.com/documentation.html#sl-prepend
|
4
|
+
//
|
5
|
+
// @requires sl-is-true
|
6
|
+
//
|
7
|
+
// @param {List} $list - list to preprend value to
|
8
|
+
// @param {*} $value - value to prepend to the list
|
9
|
+
//
|
10
|
+
// @return {List}
|
11
|
+
|
12
|
+
@function sl-prepend($list, $value) {
|
13
|
+
@if missing-dependencies(sl-is-true) == true { @return null; }
|
14
|
+
|
15
|
+
@if sl-is-true($value) {
|
16
|
+
@return join($value, $list, list-separator($list));
|
17
|
+
}
|
18
|
+
|
19
|
+
@else {
|
20
|
+
@return $list;
|
21
|
+
}
|
22
|
+
}
|
@@ -1,29 +1,29 @@
|
|
1
|
-
// Removes all false and null values from `$list`.
|
2
|
-
//
|
3
|
-
// @ignore Documentation: http://sassylists.com/documentation.html#purge
|
4
|
-
//
|
5
|
-
// @requires sl-is-true
|
6
|
-
//
|
7
|
-
// @param {List} $list - list to purge
|
8
|
-
//
|
9
|
-
// @return {List}
|
10
|
-
|
11
|
-
@function sl-purge($list) {
|
12
|
-
@if sl-missing-dependencies(sl-is-true) == true { @return null; }
|
13
|
-
|
14
|
-
$result: ();
|
15
|
-
|
16
|
-
@each $item in $list {
|
17
|
-
@if sl-is-true($item) {
|
18
|
-
$result: append($result, $item, list-separator($list));
|
19
|
-
}
|
20
|
-
}
|
21
|
-
|
22
|
-
@return $result;
|
23
|
-
}
|
24
|
-
|
25
|
-
// @alias sl-purge
|
26
|
-
|
27
|
-
@function sl-clean($list) {
|
28
|
-
@return sl-purge($list);
|
29
|
-
}
|
1
|
+
// Removes all false and null values from `$list`.
|
2
|
+
//
|
3
|
+
// @ignore Documentation: http://sassylists.com/documentation.html#purge
|
4
|
+
//
|
5
|
+
// @requires sl-is-true
|
6
|
+
//
|
7
|
+
// @param {List} $list - list to purge
|
8
|
+
//
|
9
|
+
// @return {List}
|
10
|
+
|
11
|
+
@function sl-purge($list) {
|
12
|
+
@if sl-missing-dependencies(sl-is-true) == true { @return null; }
|
13
|
+
|
14
|
+
$result: ();
|
15
|
+
|
16
|
+
@each $item in $list {
|
17
|
+
@if sl-is-true($item) {
|
18
|
+
$result: append($result, $item, list-separator($list));
|
19
|
+
}
|
20
|
+
}
|
21
|
+
|
22
|
+
@return $result;
|
23
|
+
}
|
24
|
+
|
25
|
+
// @alias sl-purge
|
26
|
+
|
27
|
+
@function sl-clean($list) {
|
28
|
+
@return sl-purge($list);
|
29
|
+
}
|
@@ -1,30 +1,30 @@
|
|
1
|
-
// Returns a random value of `$list`.
|
2
|
-
//
|
3
|
-
// @ignore Documentation: http://sassylists.com/documentation.html#random-value
|
4
|
-
//
|
5
|
-
// @param {List} $list - list to random value from
|
6
|
-
//
|
7
|
-
// @throws Cannot find a random value in an empty list.
|
8
|
-
//
|
9
|
-
// @return {*}
|
10
|
-
|
11
|
-
@function sl-random-value($list) {
|
12
|
-
@if length($list) == 0 {
|
13
|
-
@warn "Cannot find a random value in an empty list.";
|
14
|
-
@return null;
|
15
|
-
}
|
16
|
-
|
17
|
-
@return nth($list, random(length($list)));
|
18
|
-
}
|
19
|
-
|
20
|
-
// @alias sl-random-value
|
21
|
-
|
22
|
-
@function sl-roll($list) {
|
23
|
-
@return sl-random-value($list);
|
24
|
-
}
|
25
|
-
|
26
|
-
// @alias sl-random-value
|
27
|
-
|
28
|
-
@function sl-luck($list) {
|
29
|
-
@return sl-random-value($list);
|
1
|
+
// Returns a random value of `$list`.
|
2
|
+
//
|
3
|
+
// @ignore Documentation: http://sassylists.com/documentation.html#random-value
|
4
|
+
//
|
5
|
+
// @param {List} $list - list to random value from
|
6
|
+
//
|
7
|
+
// @throws Cannot find a random value in an empty list.
|
8
|
+
//
|
9
|
+
// @return {*}
|
10
|
+
|
11
|
+
@function sl-random-value($list) {
|
12
|
+
@if length($list) == 0 {
|
13
|
+
@warn "Cannot find a random value in an empty list.";
|
14
|
+
@return null;
|
15
|
+
}
|
16
|
+
|
17
|
+
@return nth($list, random(length($list)));
|
18
|
+
}
|
19
|
+
|
20
|
+
// @alias sl-random-value
|
21
|
+
|
22
|
+
@function sl-roll($list) {
|
23
|
+
@return sl-random-value($list);
|
24
|
+
}
|
25
|
+
|
26
|
+
// @alias sl-random-value
|
27
|
+
|
28
|
+
@function sl-luck($list) {
|
29
|
+
@return sl-random-value($list);
|
30
30
|
}
|
@@ -1,25 +1,25 @@
|
|
1
|
-
// Removes duplicate values from `$list`.
|
2
|
-
//
|
3
|
-
// @ignore Documentation: http://sassylists.com/documentation
|
4
|
-
//
|
5
|
-
// @param {List} $list - list to remove duplicates from
|
6
|
-
//
|
7
|
-
// @return {List}
|
8
|
-
|
9
|
-
@function sl-remove-duplicates($list) {
|
10
|
-
$result: ();
|
11
|
-
|
12
|
-
@each $item in $list {
|
13
|
-
@if not index($result, $item) {
|
14
|
-
$result: append($result, $item, list-separator($list));
|
15
|
-
}
|
16
|
-
}
|
17
|
-
|
18
|
-
@return $result;
|
19
|
-
}
|
20
|
-
|
21
|
-
// @alias sl-remove-duplicates
|
22
|
-
|
23
|
-
@function sl-unique($list, $recursive: false) {
|
24
|
-
@return sl-remove-duplicates($list, $recursive);
|
1
|
+
// Removes duplicate values from `$list`.
|
2
|
+
//
|
3
|
+
// @ignore Documentation: http://sassylists.com/documentation.html#sl-remove-duplicates
|
4
|
+
//
|
5
|
+
// @param {List} $list - list to remove duplicates from
|
6
|
+
//
|
7
|
+
// @return {List}
|
8
|
+
|
9
|
+
@function sl-remove-duplicates($list) {
|
10
|
+
$result: ();
|
11
|
+
|
12
|
+
@each $item in $list {
|
13
|
+
@if not index($result, $item) {
|
14
|
+
$result: append($result, $item, list-separator($list));
|
15
|
+
}
|
16
|
+
}
|
17
|
+
|
18
|
+
@return $result;
|
19
|
+
}
|
20
|
+
|
21
|
+
// @alias sl-remove-duplicates
|
22
|
+
|
23
|
+
@function sl-unique($list, $recursive: false) {
|
24
|
+
@return sl-remove-duplicates($list, $recursive);
|
25
25
|
}
|
@@ -1,22 +1,22 @@
|
|
1
|
-
// Removes value from `$list` at index `$index`.
|
2
|
-
//
|
3
|
-
// @ignore Documentation: http://sassylists.com/documentation
|
4
|
-
//
|
5
|
-
// @requires sl-replace-nth
|
6
|
-
//
|
7
|
-
// @param {List} $list - list to remove value from
|
8
|
-
// @param {Number} $index - index to remove
|
9
|
-
//
|
10
|
-
// @return {List | Null}
|
11
|
-
|
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, "");
|
16
|
-
}
|
17
|
-
|
18
|
-
// @alias sl-remove-nth
|
19
|
-
|
20
|
-
@function sl-without-nth($list, $index) {
|
21
|
-
@return sl-remove-nth($list, $index);
|
1
|
+
// Removes value from `$list` at index `$index`.
|
2
|
+
//
|
3
|
+
// @ignore Documentation: http://sassylists.com/documentation.html#sl-remove-nth
|
4
|
+
//
|
5
|
+
// @requires sl-replace-nth
|
6
|
+
//
|
7
|
+
// @param {List} $list - list to remove value from
|
8
|
+
// @param {Number} $index - index to remove
|
9
|
+
//
|
10
|
+
// @return {List | Null}
|
11
|
+
|
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, "");
|
16
|
+
}
|
17
|
+
|
18
|
+
// @alias sl-remove-nth
|
19
|
+
|
20
|
+
@function sl-without-nth($list, $index) {
|
21
|
+
@return sl-remove-nth($list, $index);
|
22
22
|
}
|
@@ -1,23 +1,23 @@
|
|
1
|
-
// Removes value(s) `$value` from `$list`.
|
2
|
-
//
|
3
|
-
// @ignore Documentation: http://sassylists.com/documentation
|
4
|
-
//
|
5
|
-
// @requires sl-replace
|
6
|
-
//
|
7
|
-
// @param {List} $list - list to update
|
8
|
-
// @param {*} $value - value to remove
|
9
|
-
// @param {Bool} $recursive - enable/disable recursion
|
10
|
-
//
|
11
|
-
// @return {List}
|
12
|
-
|
13
|
-
@function sl-remove($list, $value) {
|
14
|
-
@if sl-missing-dependencies(sl-replace) == true { @return null; }
|
15
|
-
|
16
|
-
@return sl-replace($list, $value, null);
|
17
|
-
}
|
18
|
-
|
19
|
-
// @alias sl-remove
|
20
|
-
|
21
|
-
@function sl-without($list, $value) {
|
22
|
-
@return sl-remove($list, $value);
|
1
|
+
// Removes value(s) `$value` from `$list`.
|
2
|
+
//
|
3
|
+
// @ignore Documentation: http://sassylists.com/documentation.html#sl-remove
|
4
|
+
//
|
5
|
+
// @requires sl-replace
|
6
|
+
//
|
7
|
+
// @param {List} $list - list to update
|
8
|
+
// @param {*} $value - value to remove
|
9
|
+
// @param {Bool} $recursive - enable/disable recursion
|
10
|
+
//
|
11
|
+
// @return {List}
|
12
|
+
|
13
|
+
@function sl-remove($list, $value) {
|
14
|
+
@if sl-missing-dependencies(sl-replace) == true { @return null; }
|
15
|
+
|
16
|
+
@return sl-replace($list, $value, null);
|
17
|
+
}
|
18
|
+
|
19
|
+
// @alias sl-remove
|
20
|
+
|
21
|
+
@function sl-without($list, $value) {
|
22
|
+
@return sl-remove($list, $value);
|
23
23
|
}
|
@@ -1,26 +1,26 @@
|
|
1
|
-
// Replaces value at `$index` from `$list` by `$value`.
|
2
|
-
//
|
3
|
-
// @ignore Documentation: http://sassylists.com/documentation
|
4
|
-
//
|
5
|
-
// @requires sl-purge
|
6
|
-
// @requires sl-is-true
|
7
|
-
//
|
8
|
-
// @param {List} $list - list to update
|
9
|
-
// @param {Number} $index - index to update
|
10
|
-
// @param {*} $value - new value for index
|
11
|
-
//
|
12
|
-
// @throws Invalid index $index for `sl-replace-nth`.
|
13
|
-
//
|
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; }
|
18
|
-
|
19
|
-
@if type-of($index) != "number" or $index == 0 or abs($index) > length($list) {
|
20
|
-
@warn "Invalid index (#{$index}) for `sl-replace-nth`.";
|
21
|
-
@return null;
|
22
|
-
}
|
23
|
-
|
24
|
-
$list: set-nth($list, $index, $value);
|
25
|
-
@return if(not sl-is-true($value), sl-purge($list), $list);
|
26
|
-
}
|
1
|
+
// Replaces value at `$index` from `$list` by `$value`.
|
2
|
+
//
|
3
|
+
// @ignore Documentation: http://sassylists.com/documentation.html#sl-replace-nth
|
4
|
+
//
|
5
|
+
// @requires sl-purge
|
6
|
+
// @requires sl-is-true
|
7
|
+
//
|
8
|
+
// @param {List} $list - list to update
|
9
|
+
// @param {Number} $index - index to update
|
10
|
+
// @param {*} $value - new value for index
|
11
|
+
//
|
12
|
+
// @throws Invalid index $index for `sl-replace-nth`.
|
13
|
+
//
|
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; }
|
18
|
+
|
19
|
+
@if type-of($index) != "number" or $index == 0 or abs($index) > length($list) {
|
20
|
+
@warn "Invalid index (#{$index}) for `sl-replace-nth`.";
|
21
|
+
@return null;
|
22
|
+
}
|
23
|
+
|
24
|
+
$list: set-nth($list, $index, $value);
|
25
|
+
@return if(not sl-is-true($value), sl-purge($list), $list);
|
26
|
+
}
|
@@ -1,33 +1,33 @@
|
|
1
|
-
// Replaces `$old` by `$new` in `$list`.
|
2
|
-
//
|
3
|
-
// @ignore Documentation: http://sassylists.com/documentation.html#replace
|
4
|
-
//
|
5
|
-
// @requires sl-is-true
|
6
|
-
// @requires sl-purge
|
7
|
-
//
|
8
|
-
// @param {List} $list - list to update
|
9
|
-
// @param {*} $old - value to replace
|
10
|
-
// @param {*} $value - new value for $old
|
11
|
-
//
|
12
|
-
// @return {List}
|
13
|
-
|
14
|
-
@function sl-replace($list, $old, $value) {
|
15
|
-
@if sl-missing-dependencies(sl-is-true, sl-purge) == true { @return null; }
|
16
|
-
|
17
|
-
$running: true;
|
18
|
-
|
19
|
-
@while $running {
|
20
|
-
$index: index($list, $old);
|
21
|
-
|
22
|
-
@if not $index {
|
23
|
-
$running: false;
|
24
|
-
}
|
25
|
-
|
26
|
-
@else {
|
27
|
-
$list: set-nth($list, $index, $value);
|
28
|
-
}
|
29
|
-
|
30
|
-
}
|
31
|
-
|
32
|
-
@return if(not sl-is-true($value), sl-purge($list), $list);
|
1
|
+
// Replaces `$old` by `$new` in `$list`.
|
2
|
+
//
|
3
|
+
// @ignore Documentation: http://sassylists.com/documentation.html#replace
|
4
|
+
//
|
5
|
+
// @requires sl-is-true
|
6
|
+
// @requires sl-purge
|
7
|
+
//
|
8
|
+
// @param {List} $list - list to update
|
9
|
+
// @param {*} $old - value to replace
|
10
|
+
// @param {*} $value - new value for $old
|
11
|
+
//
|
12
|
+
// @return {List}
|
13
|
+
|
14
|
+
@function sl-replace($list, $old, $value) {
|
15
|
+
@if sl-missing-dependencies(sl-is-true, sl-purge) == true { @return null; }
|
16
|
+
|
17
|
+
$running: true;
|
18
|
+
|
19
|
+
@while $running {
|
20
|
+
$index: index($list, $old);
|
21
|
+
|
22
|
+
@if not $index {
|
23
|
+
$running: false;
|
24
|
+
}
|
25
|
+
|
26
|
+
@else {
|
27
|
+
$list: set-nth($list, $index, $value);
|
28
|
+
}
|
29
|
+
|
30
|
+
}
|
31
|
+
|
32
|
+
@return if(not sl-is-true($value), sl-purge($list), $list);
|
33
33
|
}
|
@@ -1,30 +1,30 @@
|
|
1
|
-
// Reverses the order of `$list`.
|
2
|
-
//
|
3
|
-
// @ignore Documentation: http://sassylists.com/documentation
|
4
|
-
//
|
5
|
-
// @param {List} $list - list to reverse
|
6
|
-
//
|
7
|
-
// @return {List}
|
8
|
-
|
9
|
-
@function sl-reverse($list) {
|
10
|
-
$length: length($list);
|
11
|
-
$end: floor($length/2);
|
12
|
-
|
13
|
-
@if $length < 2 {
|
14
|
-
@return $list;
|
15
|
-
}
|
16
|
-
|
17
|
-
@for $i from 1 through $end {
|
18
|
-
$tmp: nth($list, $i);
|
19
|
-
$list: set-nth($list, $i, nth($list, -$i));
|
20
|
-
$list: set-nth($list, -$i, $tmp);
|
21
|
-
}
|
22
|
-
|
23
|
-
@return $list;
|
24
|
-
}
|
25
|
-
|
26
|
-
// @alias sl-reverse
|
27
|
-
|
28
|
-
@function sl-mirror($list) {
|
29
|
-
@return sl-reverse($list);
|
1
|
+
// Reverses the order of `$list`.
|
2
|
+
//
|
3
|
+
// @ignore Documentation: http://sassylists.com/documentation.html#sl-reverse
|
4
|
+
//
|
5
|
+
// @param {List} $list - list to reverse
|
6
|
+
//
|
7
|
+
// @return {List}
|
8
|
+
|
9
|
+
@function sl-reverse($list) {
|
10
|
+
$length: length($list);
|
11
|
+
$end: floor($length/2);
|
12
|
+
|
13
|
+
@if $length < 2 {
|
14
|
+
@return $list;
|
15
|
+
}
|
16
|
+
|
17
|
+
@for $i from 1 through $end {
|
18
|
+
$tmp: nth($list, $i);
|
19
|
+
$list: set-nth($list, $i, nth($list, -$i));
|
20
|
+
$list: set-nth($list, -$i, $tmp);
|
21
|
+
}
|
22
|
+
|
23
|
+
@return $list;
|
24
|
+
}
|
25
|
+
|
26
|
+
// @alias sl-reverse
|
27
|
+
|
28
|
+
@function sl-mirror($list) {
|
29
|
+
@return sl-reverse($list);
|
30
30
|
}
|