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,96 +1,96 @@
|
|
1
|
-
// Returns `$list` as a string, prettified if `$pre` is set to true.
|
2
|
-
//
|
3
|
-
// @ignore Documentation: http://sassylists.com/documentation
|
4
|
-
//
|
5
|
-
// @param {List} $list - list to debug
|
6
|
-
// @param {Bool} $pre (false) - enable/disable variables type and proper indentation
|
7
|
-
// @param {Number} $level (1) - internal variable for recursion
|
8
|
-
//
|
9
|
-
// @return {String}
|
10
|
-
|
11
|
-
@function sl-debug($list, $pre: false, $level: 1) {
|
12
|
-
@if length($list) == 0 {
|
13
|
-
@return "( )";
|
14
|
-
}
|
15
|
-
|
16
|
-
@if length($list) == 1 {
|
17
|
-
@return if($pre, "(" + type-of($list) + ") ", "") + $list;
|
18
|
-
}
|
19
|
-
|
20
|
-
$tab: " ";
|
21
|
-
$indent: "";
|
22
|
-
$break: if($pre, "\A ", "");
|
23
|
-
$length: length($list);
|
24
|
-
|
25
|
-
@for $i from 1 to $level {
|
26
|
-
$indent: $indent + $tab;
|
27
|
-
}
|
28
|
-
|
29
|
-
$result: "[" + $break;
|
30
|
-
|
31
|
-
@for $i from 1 through $length {
|
32
|
-
$item: nth($list, $i);
|
33
|
-
$result: $result + if($pre, $indent + $tab, " ");
|
34
|
-
|
35
|
-
@if length($item) > 1 {
|
36
|
-
$result: $result
|
37
|
-
+ if($pre, "(list: " + length($item) + ") ", "")
|
38
|
-
+ sl-debug($item, $pre, $level + 1);
|
39
|
-
}
|
40
|
-
|
41
|
-
@else {
|
42
|
-
@if $pre {
|
43
|
-
$result: $result + "(" + type-of($item) + ") ";
|
44
|
-
}
|
45
|
-
|
46
|
-
@if length($item) == 0 {
|
47
|
-
$result: $result + "( )";
|
48
|
-
}
|
49
|
-
|
50
|
-
@else if type-of($item) == "string" {
|
51
|
-
$result: $result + quote($item);
|
52
|
-
}
|
53
|
-
|
54
|
-
@else if $item == null {
|
55
|
-
$result: $result + "null";
|
56
|
-
}
|
57
|
-
|
58
|
-
@else {
|
59
|
-
$result: $result + $item;
|
60
|
-
}
|
61
|
-
}
|
62
|
-
|
63
|
-
@if $i != $length {
|
64
|
-
$result: $result + "," + $break;
|
65
|
-
}
|
66
|
-
}
|
67
|
-
|
68
|
-
$result: $result + $break + if($pre, if($level > 1, $indent, ""), " ") + "]";
|
69
|
-
|
70
|
-
@return quote($result);
|
71
|
-
}
|
72
|
-
|
73
|
-
// Mixin displaying clean debug
|
74
|
-
//
|
75
|
-
// @param {List} $list - list
|
76
|
-
//
|
77
|
-
// @requires {function} sl-debug
|
78
|
-
|
79
|
-
@mixin sl-debug($list) {
|
80
|
-
body:before {
|
81
|
-
content: sl-debug($list, true) !important;
|
82
|
-
|
83
|
-
display: block !important;
|
84
|
-
margin: 1em !important;
|
85
|
-
padding: .5em !important;
|
86
|
-
|
87
|
-
background: #EFEFEF !important;
|
88
|
-
border: 1px solid #DDD !important;
|
89
|
-
border-radius: .2em !important;
|
90
|
-
|
91
|
-
color: #333 !important;
|
92
|
-
font: .75em/1.5 "Courier New", monospace !important;
|
93
|
-
text-shadow: 0 1px white !important;
|
94
|
-
white-space: pre-wrap !important;
|
95
|
-
}
|
96
|
-
}
|
1
|
+
// Returns `$list` as a string, prettified if `$pre` is set to true.
|
2
|
+
//
|
3
|
+
// @ignore Documentation: http://sassylists.com/documentation.html#sl-debug
|
4
|
+
//
|
5
|
+
// @param {List} $list - list to debug
|
6
|
+
// @param {Bool} $pre (false) - enable/disable variables type and proper indentation
|
7
|
+
// @param {Number} $level (1) - internal variable for recursion
|
8
|
+
//
|
9
|
+
// @return {String}
|
10
|
+
|
11
|
+
@function sl-debug($list, $pre: false, $level: 1) {
|
12
|
+
@if length($list) == 0 {
|
13
|
+
@return "( )";
|
14
|
+
}
|
15
|
+
|
16
|
+
@if length($list) == 1 {
|
17
|
+
@return if($pre, "(" + type-of($list) + ") ", "") + $list;
|
18
|
+
}
|
19
|
+
|
20
|
+
$tab: " ";
|
21
|
+
$indent: "";
|
22
|
+
$break: if($pre, "\A ", "");
|
23
|
+
$length: length($list);
|
24
|
+
|
25
|
+
@for $i from 1 to $level {
|
26
|
+
$indent: $indent + $tab;
|
27
|
+
}
|
28
|
+
|
29
|
+
$result: "[" + $break;
|
30
|
+
|
31
|
+
@for $i from 1 through $length {
|
32
|
+
$item: nth($list, $i);
|
33
|
+
$result: $result + if($pre, $indent + $tab, " ");
|
34
|
+
|
35
|
+
@if length($item) > 1 {
|
36
|
+
$result: $result
|
37
|
+
+ if($pre, "(list: " + length($item) + ") ", "")
|
38
|
+
+ sl-debug($item, $pre, $level + 1);
|
39
|
+
}
|
40
|
+
|
41
|
+
@else {
|
42
|
+
@if $pre {
|
43
|
+
$result: $result + "(" + type-of($item) + ") ";
|
44
|
+
}
|
45
|
+
|
46
|
+
@if length($item) == 0 {
|
47
|
+
$result: $result + "( )";
|
48
|
+
}
|
49
|
+
|
50
|
+
@else if type-of($item) == "string" {
|
51
|
+
$result: $result + quote($item);
|
52
|
+
}
|
53
|
+
|
54
|
+
@else if $item == null {
|
55
|
+
$result: $result + "null";
|
56
|
+
}
|
57
|
+
|
58
|
+
@else {
|
59
|
+
$result: $result + $item;
|
60
|
+
}
|
61
|
+
}
|
62
|
+
|
63
|
+
@if $i != $length {
|
64
|
+
$result: $result + "," + $break;
|
65
|
+
}
|
66
|
+
}
|
67
|
+
|
68
|
+
$result: $result + $break + if($pre, if($level > 1, $indent, ""), " ") + "]";
|
69
|
+
|
70
|
+
@return quote($result);
|
71
|
+
}
|
72
|
+
|
73
|
+
// Mixin displaying clean debug
|
74
|
+
//
|
75
|
+
// @param {List} $list - list
|
76
|
+
//
|
77
|
+
// @requires {function} sl-debug
|
78
|
+
|
79
|
+
@mixin sl-debug($list) {
|
80
|
+
body:before {
|
81
|
+
content: sl-debug($list, true) !important;
|
82
|
+
|
83
|
+
display: block !important;
|
84
|
+
margin: 1em !important;
|
85
|
+
padding: .5em !important;
|
86
|
+
|
87
|
+
background: #EFEFEF !important;
|
88
|
+
border: 1px solid #DDD !important;
|
89
|
+
border-radius: .2em !important;
|
90
|
+
|
91
|
+
color: #333 !important;
|
92
|
+
font: .75em/1.5 "Courier New", monospace !important;
|
93
|
+
text-shadow: 0 1px white !important;
|
94
|
+
white-space: pre-wrap !important;
|
95
|
+
}
|
96
|
+
}
|
@@ -1,17 +1,17 @@
|
|
1
|
-
// Tests whether all 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-every($list, $function, $args...) {
|
10
|
-
@each $item in $list {
|
11
|
-
@if not call($function, $item, $args...) {
|
12
|
-
@return false;
|
13
|
-
}
|
14
|
-
}
|
15
|
-
|
16
|
-
@return true;
|
17
|
-
}
|
1
|
+
// Tests whether all 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-every($list, $function, $args...) {
|
10
|
+
@each $item in $list {
|
11
|
+
@if not call($function, $item, $args...) {
|
12
|
+
@return false;
|
13
|
+
}
|
14
|
+
}
|
15
|
+
|
16
|
+
@return true;
|
17
|
+
}
|
@@ -1,53 +1,53 @@
|
|
1
|
-
//
|
2
|
-
//
|
3
|
-
// @ignore Documentation: http://sassylists.com/documentation
|
4
|
-
//
|
5
|
-
// @param {String} $string - string to explode
|
6
|
-
// @param {String} $separator ('') - string to use as a delimiter
|
7
|
-
//
|
8
|
-
// @throws $string is not a string for `sl-explode`.
|
9
|
-
// @throws $delimiter is not a string for `sl-explode`.
|
10
|
-
//
|
11
|
-
// @return {List | Null}
|
12
|
-
|
13
|
-
@function sl-explode($string, $delimiter: '') {
|
14
|
-
@if type-of($string) != "string" {
|
15
|
-
@warn "`sl-explode` function expecting a string; #{type-of($string)} given.";
|
16
|
-
@return null;
|
17
|
-
}
|
18
|
-
|
19
|
-
@if type-of($delimiter) != "string" {
|
20
|
-
@warn "`sl-explode` function expecting a string; #{type-of($delimiter)} given.";
|
21
|
-
@return null;
|
22
|
-
}
|
23
|
-
|
24
|
-
$result: ();
|
25
|
-
$length: str-length($string);
|
26
|
-
|
27
|
-
@if str-length($delimiter) == 0 {
|
28
|
-
@for $i from 1 through $length {
|
29
|
-
$result: append($result, str-slice($string, $i, $i));
|
30
|
-
}
|
31
|
-
|
32
|
-
@return $result;
|
33
|
-
}
|
34
|
-
|
35
|
-
$running: true;
|
36
|
-
$remaining: $string;
|
37
|
-
|
38
|
-
@while $running {
|
39
|
-
$index: str-index($remaining, $delimiter);
|
40
|
-
|
41
|
-
@if not $index or $index == 0 {
|
42
|
-
$running: false;
|
43
|
-
}
|
44
|
-
|
45
|
-
@else {
|
46
|
-
$slice: str-slice($remaining, 1, $index - 1);
|
47
|
-
$result: append($result, $slice);
|
48
|
-
$remaining: str-slice($remaining, $index + str-length($delimiter));
|
49
|
-
}
|
50
|
-
}
|
51
|
-
|
52
|
-
@return append($result, $remaining);
|
1
|
+
// Explodes `$string` into a list using `$delimiter` as a delimiter.
|
2
|
+
//
|
3
|
+
// @ignore Documentation: http://sassylists.com/documentation.html#sl-explode
|
4
|
+
//
|
5
|
+
// @param {String} $string - string to explode
|
6
|
+
// @param {String} $separator ('') - string to use as a delimiter
|
7
|
+
//
|
8
|
+
// @throws $string is not a string for `sl-explode`.
|
9
|
+
// @throws $delimiter is not a string for `sl-explode`.
|
10
|
+
//
|
11
|
+
// @return {List | Null}
|
12
|
+
|
13
|
+
@function sl-explode($string, $delimiter: '') {
|
14
|
+
@if type-of($string) != "string" {
|
15
|
+
@warn "`sl-explode` function expecting a string; #{type-of($string)} given.";
|
16
|
+
@return null;
|
17
|
+
}
|
18
|
+
|
19
|
+
@if type-of($delimiter) != "string" {
|
20
|
+
@warn "`sl-explode` function expecting a string; #{type-of($delimiter)} given.";
|
21
|
+
@return null;
|
22
|
+
}
|
23
|
+
|
24
|
+
$result: ();
|
25
|
+
$length: str-length($string);
|
26
|
+
|
27
|
+
@if str-length($delimiter) == 0 {
|
28
|
+
@for $i from 1 through $length {
|
29
|
+
$result: append($result, str-slice($string, $i, $i));
|
30
|
+
}
|
31
|
+
|
32
|
+
@return $result;
|
33
|
+
}
|
34
|
+
|
35
|
+
$running: true;
|
36
|
+
$remaining: $string;
|
37
|
+
|
38
|
+
@while $running {
|
39
|
+
$index: str-index($remaining, $delimiter);
|
40
|
+
|
41
|
+
@if not $index or $index == 0 {
|
42
|
+
$running: false;
|
43
|
+
}
|
44
|
+
|
45
|
+
@else {
|
46
|
+
$slice: str-slice($remaining, 1, $index - 1);
|
47
|
+
$result: append($result, $slice);
|
48
|
+
$remaining: str-slice($remaining, $index + str-length($delimiter));
|
49
|
+
}
|
50
|
+
}
|
51
|
+
|
52
|
+
@return append($result, $remaining);
|
53
53
|
}
|
@@ -1,24 +1,24 @@
|
|
1
|
-
// Returns first element of `$list`.
|
2
|
-
//
|
3
|
-
// @ignore Documentation: http://sassylists.com/documentation
|
4
|
-
//
|
5
|
-
// @param {List} $list - list to retrieve first item from
|
6
|
-
//
|
7
|
-
// @throws Cannot find first item of empty list.
|
8
|
-
//
|
9
|
-
// @return {*}
|
10
|
-
|
11
|
-
@function sl-first($list) {
|
12
|
-
@if length($list) == 0 {
|
13
|
-
@warn "Cannot find first item of empty list.";
|
14
|
-
@return null;
|
15
|
-
}
|
16
|
-
|
17
|
-
@return nth($list, 1);
|
18
|
-
}
|
19
|
-
|
20
|
-
// @alias sl-first
|
21
|
-
|
22
|
-
@function sl-head($list) {
|
23
|
-
@return sl-first($list);
|
1
|
+
// Returns first element of `$list`.
|
2
|
+
//
|
3
|
+
// @ignore Documentation: http://sassylists.com/documentation.html#sl-first
|
4
|
+
//
|
5
|
+
// @param {List} $list - list to retrieve first item from
|
6
|
+
//
|
7
|
+
// @throws Cannot find first item of empty list.
|
8
|
+
//
|
9
|
+
// @return {*}
|
10
|
+
|
11
|
+
@function sl-first($list) {
|
12
|
+
@if length($list) == 0 {
|
13
|
+
@warn "Cannot find first item of empty list.";
|
14
|
+
@return null;
|
15
|
+
}
|
16
|
+
|
17
|
+
@return nth($list, 1);
|
18
|
+
}
|
19
|
+
|
20
|
+
// @alias sl-first
|
21
|
+
|
22
|
+
@function sl-head($list) {
|
23
|
+
@return sl-first($list);
|
24
24
|
}
|
@@ -1,36 +1,36 @@
|
|
1
|
-
// Turns multidimensional `$list` into a one-level list.
|
2
|
-
//
|
3
|
-
// @ignore Documentation: http://sassylists.com/documentation.html#flatten
|
4
|
-
//
|
5
|
-
// @param {List} $list - list to flatten
|
6
|
-
//
|
7
|
-
// @return {List}
|
8
|
-
|
9
|
-
@function sl-flatten($list) {
|
10
|
-
$result: ();
|
11
|
-
|
12
|
-
@if length($list) == 1 {
|
13
|
-
@return $list;
|
14
|
-
}
|
15
|
-
|
16
|
-
@each $item in $list {
|
17
|
-
@if length($item) > 1 {
|
18
|
-
$flatten: sl-flatten($item);
|
19
|
-
@each $i in $flatten {
|
20
|
-
$result: append($result, $i, list-separator($list));
|
21
|
-
}
|
22
|
-
}
|
23
|
-
|
24
|
-
@else {
|
25
|
-
$result: append($result, $item, list-separator($list));
|
26
|
-
}
|
27
|
-
}
|
28
|
-
|
29
|
-
@return $result;
|
30
|
-
}
|
31
|
-
|
32
|
-
// @alias sl-flatten
|
33
|
-
|
34
|
-
@function sl-unfold($list) {
|
35
|
-
@return sl-flatten($list);
|
1
|
+
// Turns multidimensional `$list` into a one-level list.
|
2
|
+
//
|
3
|
+
// @ignore Documentation: http://sassylists.com/documentation.html#flatten
|
4
|
+
//
|
5
|
+
// @param {List} $list - list to flatten
|
6
|
+
//
|
7
|
+
// @return {List}
|
8
|
+
|
9
|
+
@function sl-flatten($list) {
|
10
|
+
$result: ();
|
11
|
+
|
12
|
+
@if length($list) == 1 {
|
13
|
+
@return $list;
|
14
|
+
}
|
15
|
+
|
16
|
+
@each $item in $list {
|
17
|
+
@if length($item) > 1 {
|
18
|
+
$flatten: sl-flatten($item);
|
19
|
+
@each $i in $flatten {
|
20
|
+
$result: append($result, $i, list-separator($list));
|
21
|
+
}
|
22
|
+
}
|
23
|
+
|
24
|
+
@else {
|
25
|
+
$result: append($result, $item, list-separator($list));
|
26
|
+
}
|
27
|
+
}
|
28
|
+
|
29
|
+
@return $result;
|
30
|
+
}
|
31
|
+
|
32
|
+
// @alias sl-flatten
|
33
|
+
|
34
|
+
@function sl-unfold($list) {
|
35
|
+
@return sl-flatten($list);
|
36
36
|
}
|
@@ -1,48 +1,48 @@
|
|
1
|
-
// Adds `$value` at `$index` in `$list`.
|
2
|
-
//
|
3
|
-
// @ignore Documentation: http://sassylists.com/documentation
|
4
|
-
//
|
5
|
-
// @requires sl-is-true
|
6
|
-
//
|
7
|
-
// @param {List} $list - list to update
|
8
|
-
// @param {Number} $index - index to add
|
9
|
-
// @param {*} $value - value to add
|
10
|
-
//
|
11
|
-
// @throws List index $index is not a number for `sl-insert-nth`.
|
12
|
-
// @throws List index $index must be a non-zero integer for `sl-insert-nth`.
|
13
|
-
//
|
14
|
-
// @return {List | Null}
|
15
|
-
|
16
|
-
@function sl-insert-nth($list, $index, $value) {
|
17
|
-
@if sl-missing-dependencies(sl-is-true) == true { @return null; }
|
18
|
-
|
19
|
-
$length: length($list);
|
20
|
-
|
21
|
-
@if type-of($index) != number {
|
22
|
-
@warn "List index #{$index} is not a number for `sl-insert-nth`.";
|
23
|
-
@return null;
|
24
|
-
}
|
25
|
-
|
26
|
-
@if $index < 1 {
|
27
|
-
@warn "List index #{$index} must be a non-zero integer for `sl-insert-nth`.";
|
28
|
-
@return null;
|
29
|
-
}
|
30
|
-
|
31
|
-
@if $index > $length {
|
32
|
-
@return append($list, $value, list-separator($list));
|
33
|
-
}
|
34
|
-
|
35
|
-
$result: ();
|
36
|
-
|
37
|
-
@for $i from 1 through $length {
|
38
|
-
@if $i == $index {
|
39
|
-
@if sl-is-true($value) {
|
40
|
-
$result: append($result, $value, list-separator($list));
|
41
|
-
}
|
42
|
-
}
|
43
|
-
|
44
|
-
$result: append($result, nth($list, $i), list-separator($list));
|
45
|
-
}
|
46
|
-
|
47
|
-
@return $result;
|
48
|
-
}
|
1
|
+
// Adds `$value` at `$index` in `$list`.
|
2
|
+
//
|
3
|
+
// @ignore Documentation: http://sassylists.com/documentation.html#sl-insert-nth
|
4
|
+
//
|
5
|
+
// @requires sl-is-true
|
6
|
+
//
|
7
|
+
// @param {List} $list - list to update
|
8
|
+
// @param {Number} $index - index to add
|
9
|
+
// @param {*} $value - value to add
|
10
|
+
//
|
11
|
+
// @throws List index $index is not a number for `sl-insert-nth`.
|
12
|
+
// @throws List index $index must be a non-zero integer for `sl-insert-nth`.
|
13
|
+
//
|
14
|
+
// @return {List | Null}
|
15
|
+
|
16
|
+
@function sl-insert-nth($list, $index, $value) {
|
17
|
+
@if sl-missing-dependencies(sl-is-true) == true { @return null; }
|
18
|
+
|
19
|
+
$length: length($list);
|
20
|
+
|
21
|
+
@if type-of($index) != number {
|
22
|
+
@warn "List index #{$index} is not a number for `sl-insert-nth`.";
|
23
|
+
@return null;
|
24
|
+
}
|
25
|
+
|
26
|
+
@if $index < 1 {
|
27
|
+
@warn "List index #{$index} must be a non-zero integer for `sl-insert-nth`.";
|
28
|
+
@return null;
|
29
|
+
}
|
30
|
+
|
31
|
+
@if $index > $length {
|
32
|
+
@return append($list, $value, list-separator($list));
|
33
|
+
}
|
34
|
+
|
35
|
+
$result: ();
|
36
|
+
|
37
|
+
@for $i from 1 through $length {
|
38
|
+
@if $i == $index {
|
39
|
+
@if sl-is-true($value) {
|
40
|
+
$result: append($result, $value, list-separator($list));
|
41
|
+
}
|
42
|
+
}
|
43
|
+
|
44
|
+
$result: append($result, nth($list, $i), list-separator($list));
|
45
|
+
}
|
46
|
+
|
47
|
+
@return $result;
|
48
|
+
}
|
@@ -1,31 +1,31 @@
|
|
1
|
-
// Returns a list of shared value from `$list` and `$lists` minus duplicates.
|
2
|
-
//
|
3
|
-
// @ignore Documentation: http://sassylists.com/documentation
|
4
|
-
//
|
5
|
-
// @requires sl-remove-duplicates
|
6
|
-
//
|
7
|
-
// @param {List} $list - first list
|
8
|
-
// @param {ArgList} $lists - other lists
|
9
|
-
//
|
10
|
-
// @return {List}
|
11
|
-
|
12
|
-
@function sl-intersection($list, $lists...) {
|
13
|
-
@if sl-missing-dependencies(sl-remove-duplicates) == true { @return null; }
|
14
|
-
|
15
|
-
$result: $list;
|
16
|
-
|
17
|
-
@each $list in $lists {
|
18
|
-
$temp: ();
|
19
|
-
|
20
|
-
@each $item in $result {
|
21
|
-
@if not not index($list, $item) {
|
22
|
-
$temp: append($temp, $item, list-separator($list));
|
23
|
-
}
|
24
|
-
}
|
25
|
-
|
26
|
-
$result: $temp;
|
27
|
-
}
|
28
|
-
|
29
|
-
$result: sl-remove-duplicates($result);
|
30
|
-
@return if(length($result) == 1, nth($result, 1), $result);
|
1
|
+
// Returns a list of shared value from `$list` and `$lists` minus duplicates.
|
2
|
+
//
|
3
|
+
// @ignore Documentation: http://sassylists.com/documentation.html#sl-intersection
|
4
|
+
//
|
5
|
+
// @requires sl-remove-duplicates
|
6
|
+
//
|
7
|
+
// @param {List} $list - first list
|
8
|
+
// @param {ArgList} $lists - other lists
|
9
|
+
//
|
10
|
+
// @return {List}
|
11
|
+
|
12
|
+
@function sl-intersection($list, $lists...) {
|
13
|
+
@if sl-missing-dependencies(sl-remove-duplicates) == true { @return null; }
|
14
|
+
|
15
|
+
$result: $list;
|
16
|
+
|
17
|
+
@each $list in $lists {
|
18
|
+
$temp: ();
|
19
|
+
|
20
|
+
@each $item in $result {
|
21
|
+
@if not not index($list, $item) {
|
22
|
+
$temp: append($temp, $item, list-separator($list));
|
23
|
+
}
|
24
|
+
}
|
25
|
+
|
26
|
+
$result: $temp;
|
27
|
+
}
|
28
|
+
|
29
|
+
$result: sl-remove-duplicates($result);
|
30
|
+
@return if(length($result) == 1, nth($result, 1), $result);
|
31
31
|
}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
// Tests whether `$list` is empty.
|
2
|
+
//
|
3
|
+
// @ignore Documentation: http://sassylists.com/documentation.html#sl-is-empty
|
4
|
+
//
|
5
|
+
// @param {List} $list - list to run test against
|
6
|
+
//
|
7
|
+
// @return {Bool}
|
8
|
+
|
9
|
+
@function sl-is-empty($list) {
|
10
|
+
@return length($list) == 0;
|
11
|
+
}
|
12
|
+
|
13
|
+
// @requires sl-is-empty
|
14
|
+
// @alias sl-is-empty
|
15
|
+
|
16
|
+
@function sl-empty($list) {
|
17
|
+
@return sl-is-empty($list);
|
18
|
+
}
|
@@ -1,21 +1,21 @@
|
|
1
|
-
// Checks whether `$list` is symmetrical.
|
2
|
-
//
|
3
|
-
// @ignore Documentation: http://sassylists.com/documentation
|
4
|
-
//
|
5
|
-
// @requires sl-reverse
|
6
|
-
//
|
7
|
-
// @param {List} $list - list to check
|
8
|
-
//
|
9
|
-
// @return {Bool}
|
10
|
-
|
11
|
-
@function sl-is-symmetrical($list) {
|
12
|
-
@if sl-missing-dependencies(sl-reverse) == true { @return null; }
|
13
|
-
|
14
|
-
@return $list == sl-reverse($list);
|
15
|
-
}
|
16
|
-
|
17
|
-
// @alias sl-is-symmetrical
|
18
|
-
|
19
|
-
@function sl-is-mirror($list) {
|
20
|
-
@return sl-is-symmetrical($list);
|
1
|
+
// Checks whether `$list` is symmetrical.
|
2
|
+
//
|
3
|
+
// @ignore Documentation: http://sassylists.com/documentation.html#sl-is-symmetrical
|
4
|
+
//
|
5
|
+
// @requires sl-reverse
|
6
|
+
//
|
7
|
+
// @param {List} $list - list to check
|
8
|
+
//
|
9
|
+
// @return {Bool}
|
10
|
+
|
11
|
+
@function sl-is-symmetrical($list) {
|
12
|
+
@if sl-missing-dependencies(sl-reverse) == true { @return null; }
|
13
|
+
|
14
|
+
@return $list == sl-reverse($list);
|
15
|
+
}
|
16
|
+
|
17
|
+
// @alias sl-is-symmetrical
|
18
|
+
|
19
|
+
@function sl-is-mirror($list) {
|
20
|
+
@return sl-is-symmetrical($list);
|
21
21
|
}
|