ListFunctions 0.1 → 0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/ListFunctions.rb +29 -29
- data/stylesheets/ListFunctions/_chunk.scss +32 -32
- data/stylesheets/ListFunctions/_count-values.scss +32 -32
- data/stylesheets/ListFunctions/_debug.scss +34 -34
- data/stylesheets/ListFunctions/_first.scss +12 -12
- data/stylesheets/ListFunctions/_insert-nth.scss +51 -51
- data/stylesheets/ListFunctions/_is-symmetrical.scss +22 -22
- data/stylesheets/ListFunctions/_last-index.scss +24 -24
- data/stylesheets/ListFunctions/_last.scss +12 -12
- data/stylesheets/ListFunctions/_loop.scss +20 -20
- data/stylesheets/ListFunctions/_prepend.scss +15 -15
- data/stylesheets/ListFunctions/_purge.scss +20 -20
- data/stylesheets/ListFunctions/_remove-duplicates.scss +29 -29
- data/stylesheets/ListFunctions/_remove-nth.scss +22 -22
- data/stylesheets/ListFunctions/_remove.scss +18 -18
- data/stylesheets/ListFunctions/_replace-nth.scss +49 -49
- data/stylesheets/ListFunctions/_replace.scss +31 -31
- data/stylesheets/ListFunctions/_reverse.scss +29 -29
- data/stylesheets/ListFunctions/_slice.scss +59 -59
- data/stylesheets/ListFunctions/_sort.scss +42 -0
- data/stylesheets/ListFunctions/_sum.scss +32 -32
- data/stylesheets/ListFunctions/_to-string.scss +28 -28
- data/stylesheets/_ListFunctions.scss +94 -90
- data/templates/project/sass/ListFunctions/_chunk.scss +32 -32
- data/templates/project/sass/ListFunctions/_count-values.scss +32 -32
- data/templates/project/sass/ListFunctions/_debug.scss +34 -34
- data/templates/project/sass/ListFunctions/_first.scss +12 -12
- data/templates/project/sass/ListFunctions/_insert-nth.scss +51 -51
- data/templates/project/sass/ListFunctions/_is-symmetrical.scss +22 -22
- data/templates/project/sass/ListFunctions/_last-index.scss +24 -24
- data/templates/project/sass/ListFunctions/_last.scss +12 -12
- data/templates/project/sass/ListFunctions/_loop.scss +20 -20
- data/templates/project/sass/ListFunctions/_prepend.scss +15 -15
- data/templates/project/sass/ListFunctions/_purge.scss +20 -20
- data/templates/project/sass/ListFunctions/_remove-duplicates.scss +29 -29
- data/templates/project/sass/ListFunctions/_remove-nth.scss +22 -22
- data/templates/project/sass/ListFunctions/_remove.scss +18 -18
- data/templates/project/sass/ListFunctions/_replace-nth.scss +49 -49
- data/templates/project/sass/ListFunctions/_replace.scss +31 -31
- data/templates/project/sass/ListFunctions/_reverse.scss +29 -29
- data/templates/project/sass/ListFunctions/_slice.scss +59 -59
- data/templates/project/sass/ListFunctions/_sum.scss +32 -32
- data/templates/project/sass/ListFunctions/_to-string.scss +28 -28
- data/templates/project/sass/_ListFunctions.scss +90 -90
- metadata +18 -11
- checksums.yaml +0 -7
@@ -1,21 +1,21 @@
|
|
1
|
-
/**
|
2
|
-
* Shift indexes from $list of $value
|
3
|
-
* -------------------------------------------------------------------------------
|
4
|
-
* @example loop( (a, b, c, d, e) ) => e, a, b, c, d
|
5
|
-
* @example loop( (a, b, c, d, e), 2 ) => d, e, a, b, c
|
6
|
-
* @example loop( (a, b, c, d, e), -2 ) => c, d, e, a, b
|
7
|
-
* -------------------------------------------------------------------------------
|
8
|
-
* @param $list [List] : list
|
9
|
-
* @param $value [Number] : number of position between old and new indexes
|
10
|
-
* -------------------------------------------------------------------------------
|
11
|
-
* @return [List]
|
12
|
-
*/
|
13
|
-
@function loop($list, $value: 1) {
|
14
|
-
$result: ();
|
15
|
-
|
16
|
-
@for $i from 0 to length($list) {
|
17
|
-
$result: append($result, nth($list, ($i - $value) % length($list) + 1));
|
18
|
-
}
|
19
|
-
|
20
|
-
@return $result;
|
1
|
+
/**
|
2
|
+
* Shift indexes from $list of $value
|
3
|
+
* -------------------------------------------------------------------------------
|
4
|
+
* @example loop( (a, b, c, d, e) ) => e, a, b, c, d
|
5
|
+
* @example loop( (a, b, c, d, e), 2 ) => d, e, a, b, c
|
6
|
+
* @example loop( (a, b, c, d, e), -2 ) => c, d, e, a, b
|
7
|
+
* -------------------------------------------------------------------------------
|
8
|
+
* @param $list [List] : list
|
9
|
+
* @param $value [Number] : number of position between old and new indexes
|
10
|
+
* -------------------------------------------------------------------------------
|
11
|
+
* @return [List]
|
12
|
+
*/
|
13
|
+
@function loop($list, $value: 1) {
|
14
|
+
$result: ();
|
15
|
+
|
16
|
+
@for $i from 0 to length($list) {
|
17
|
+
$result: append($result, nth($list, ($i - $value) % length($list) + 1));
|
18
|
+
}
|
19
|
+
|
20
|
+
@return $result;
|
21
21
|
}
|
@@ -1,16 +1,16 @@
|
|
1
|
-
/**
|
2
|
-
* Add $value as first index of $list
|
3
|
-
* -------------------------------------------------------------------------------
|
4
|
-
* @dependence `purge()`
|
5
|
-
* -------------------------------------------------------------------------------
|
6
|
-
* @example prepend( (a, b, c), z ) => z, a, b, c
|
7
|
-
* @example prepend( (a, b, c), y z ) => y z, a, b, c
|
8
|
-
* -------------------------------------------------------------------------------
|
9
|
-
* @param $list [List] : list
|
10
|
-
* @param $value [Literal] : value to prepend to the list
|
11
|
-
* -------------------------------------------------------------------------------
|
12
|
-
* @return [List]
|
13
|
-
*/
|
14
|
-
@function prepend($list, $value) {
|
15
|
-
@return purge(join($value, $list));
|
1
|
+
/**
|
2
|
+
* Add $value as first index of $list
|
3
|
+
* -------------------------------------------------------------------------------
|
4
|
+
* @dependence `purge()`
|
5
|
+
* -------------------------------------------------------------------------------
|
6
|
+
* @example prepend( (a, b, c), z ) => z, a, b, c
|
7
|
+
* @example prepend( (a, b, c), y z ) => y z, a, b, c
|
8
|
+
* -------------------------------------------------------------------------------
|
9
|
+
* @param $list [List] : list
|
10
|
+
* @param $value [Literal] : value to prepend to the list
|
11
|
+
* -------------------------------------------------------------------------------
|
12
|
+
* @return [List]
|
13
|
+
*/
|
14
|
+
@function prepend($list, $value) {
|
15
|
+
@return purge(join($value, $list));
|
16
16
|
}
|
@@ -1,21 +1,21 @@
|
|
1
|
-
/**
|
2
|
-
* Remove all false and null values from $list
|
3
|
-
* -------------------------------------------------------------------------------
|
4
|
-
* @example purge( (a, null, b, false, c, null) ) => a, b, c
|
5
|
-
* @example purge( (a, b, c) ) => a, b, c
|
6
|
-
* -------------------------------------------------------------------------------
|
7
|
-
* @param $list [List] : list
|
8
|
-
* -------------------------------------------------------------------------------
|
9
|
-
* @return [List]
|
10
|
-
*/
|
11
|
-
@function purge($list) {
|
12
|
-
$result: ();
|
13
|
-
|
14
|
-
@each $item in $list {
|
15
|
-
@if $item != null and $item != false and $item != "" {
|
16
|
-
$result: append($result, $item);
|
17
|
-
}
|
18
|
-
}
|
19
|
-
|
20
|
-
@return $result;
|
1
|
+
/**
|
2
|
+
* Remove all false and null values from $list
|
3
|
+
* -------------------------------------------------------------------------------
|
4
|
+
* @example purge( (a, null, b, false, c, null) ) => a, b, c
|
5
|
+
* @example purge( (a, b, c) ) => a, b, c
|
6
|
+
* -------------------------------------------------------------------------------
|
7
|
+
* @param $list [List] : list
|
8
|
+
* -------------------------------------------------------------------------------
|
9
|
+
* @return [List]
|
10
|
+
*/
|
11
|
+
@function purge($list) {
|
12
|
+
$result: ();
|
13
|
+
|
14
|
+
@each $item in $list {
|
15
|
+
@if $item != null and $item != false and $item != "" {
|
16
|
+
$result: append($result, $item);
|
17
|
+
}
|
18
|
+
}
|
19
|
+
|
20
|
+
@return $result;
|
21
21
|
}
|
@@ -1,30 +1,30 @@
|
|
1
|
-
/**
|
2
|
-
* Remove duplicate values from $list
|
3
|
-
* -------------------------------------------------------------------------------
|
4
|
-
* @example remove-duplicates( (a, b, a, c, b, d, c, e) ) => a, b, c, d, e
|
5
|
-
* @example remove-duplicates( (a, b, (c, c, c)) ) => a, b, c
|
6
|
-
* -------------------------------------------------------------------------------
|
7
|
-
* @param $list [List] : list
|
8
|
-
* @param $recursive [Boolean] : enable / disable recursivity
|
9
|
-
* -------------------------------------------------------------------------------
|
10
|
-
* @return [List]
|
11
|
-
*/
|
12
|
-
@function remove-duplicates($list, $recursive: false) {
|
13
|
-
$result: ();
|
14
|
-
|
15
|
-
@each $item in $list {
|
16
|
-
|
17
|
-
@if not index($result, $item) {
|
18
|
-
@if length($item) > 1 and $recursive {
|
19
|
-
$result: append($result, remove-duplicates($item, $recursive));
|
20
|
-
}
|
21
|
-
|
22
|
-
@else {
|
23
|
-
$result: append($result, $item);
|
24
|
-
}
|
25
|
-
}
|
26
|
-
|
27
|
-
}
|
28
|
-
|
29
|
-
@return $result;
|
1
|
+
/**
|
2
|
+
* Remove duplicate values from $list
|
3
|
+
* -------------------------------------------------------------------------------
|
4
|
+
* @example remove-duplicates( (a, b, a, c, b, d, c, e) ) => a, b, c, d, e
|
5
|
+
* @example remove-duplicates( (a, b, (c, c, c)) ) => a, b, c
|
6
|
+
* -------------------------------------------------------------------------------
|
7
|
+
* @param $list [List] : list
|
8
|
+
* @param $recursive [Boolean] : enable / disable recursivity
|
9
|
+
* -------------------------------------------------------------------------------
|
10
|
+
* @return [List]
|
11
|
+
*/
|
12
|
+
@function remove-duplicates($list, $recursive: false) {
|
13
|
+
$result: ();
|
14
|
+
|
15
|
+
@each $item in $list {
|
16
|
+
|
17
|
+
@if not index($result, $item) {
|
18
|
+
@if length($item) > 1 and $recursive {
|
19
|
+
$result: append($result, remove-duplicates($item, $recursive));
|
20
|
+
}
|
21
|
+
|
22
|
+
@else {
|
23
|
+
$result: append($result, $item);
|
24
|
+
}
|
25
|
+
}
|
26
|
+
|
27
|
+
}
|
28
|
+
|
29
|
+
@return $result;
|
30
30
|
}
|
@@ -1,23 +1,23 @@
|
|
1
|
-
/**
|
2
|
-
* Remove value from $list at index $index
|
3
|
-
* -------------------------------------------------------------------------------
|
4
|
-
* @dependence `replace-nth()`
|
5
|
-
* -------------------------------------------------------------------------------
|
6
|
-
* @example remove-nth( (a, b, c), 2 ) => a, c
|
7
|
-
* @example remove-nth( (a, b, c), 0 ) => error
|
8
|
-
* @example remove-nth( (a, b, c), -1 ) => a, b
|
9
|
-
* @example remove-nth( (a, b, c), 10 ) => error
|
10
|
-
* @example remove-nth( (a, b, c), -10 ) => error
|
11
|
-
* -------------------------------------------------------------------------------
|
12
|
-
* @param $list [List] : list
|
13
|
-
* @param $index [Number] : index to remove
|
14
|
-
* -------------------------------------------------------------------------------
|
15
|
-
* @raise [Error] if $index isn't an integer
|
16
|
-
* @raise [Error] if $index is 0
|
17
|
-
* @raise [Error] if abs value of $index is strictly greater then length of $list
|
18
|
-
* -------------------------------------------------------------------------------
|
19
|
-
* @return [List] | false
|
20
|
-
*/
|
21
|
-
@function remove-nth($list, $index) {
|
22
|
-
@return replace-nth($list, $index, "");
|
1
|
+
/**
|
2
|
+
* Remove value from $list at index $index
|
3
|
+
* -------------------------------------------------------------------------------
|
4
|
+
* @dependence `replace-nth()`
|
5
|
+
* -------------------------------------------------------------------------------
|
6
|
+
* @example remove-nth( (a, b, c), 2 ) => a, c
|
7
|
+
* @example remove-nth( (a, b, c), 0 ) => error
|
8
|
+
* @example remove-nth( (a, b, c), -1 ) => a, b
|
9
|
+
* @example remove-nth( (a, b, c), 10 ) => error
|
10
|
+
* @example remove-nth( (a, b, c), -10 ) => error
|
11
|
+
* -------------------------------------------------------------------------------
|
12
|
+
* @param $list [List] : list
|
13
|
+
* @param $index [Number] : index to remove
|
14
|
+
* -------------------------------------------------------------------------------
|
15
|
+
* @raise [Error] if $index isn't an integer
|
16
|
+
* @raise [Error] if $index is 0
|
17
|
+
* @raise [Error] if abs value of $index is strictly greater then length of $list
|
18
|
+
* -------------------------------------------------------------------------------
|
19
|
+
* @return [List] | false
|
20
|
+
*/
|
21
|
+
@function remove-nth($list, $index) {
|
22
|
+
@return replace-nth($list, $index, "");
|
23
23
|
}
|
@@ -1,19 +1,19 @@
|
|
1
|
-
/**
|
2
|
-
* Remove value(s) $value from $list
|
3
|
-
* -------------------------------------------------------------------------------
|
4
|
-
* @dependence `replace()`
|
5
|
-
* -------------------------------------------------------------------------------
|
6
|
-
* @example remove( (a, b, c), b ) => a, c
|
7
|
-
* @example remove( (a, b, c), z ) => a, b, c
|
8
|
-
* @example remove( (a, b, c b), b ) => a, c b
|
9
|
-
* @example remove( (a, b, c b), b, true ) => a, c
|
10
|
-
* -------------------------------------------------------------------------------
|
11
|
-
* @param $list [List] : list
|
12
|
-
* @param $value [Literal] : value to remove
|
13
|
-
* @param $recursive [Boolean] : enable / disable recursivity
|
14
|
-
* -------------------------------------------------------------------------------
|
15
|
-
* @return [List]
|
16
|
-
*/
|
17
|
-
@function remove($list, $value, $recursive: false) {
|
18
|
-
@return replace($list, $value, "", $recursive);
|
1
|
+
/**
|
2
|
+
* Remove value(s) $value from $list
|
3
|
+
* -------------------------------------------------------------------------------
|
4
|
+
* @dependence `replace()`
|
5
|
+
* -------------------------------------------------------------------------------
|
6
|
+
* @example remove( (a, b, c), b ) => a, c
|
7
|
+
* @example remove( (a, b, c), z ) => a, b, c
|
8
|
+
* @example remove( (a, b, c b), b ) => a, c b
|
9
|
+
* @example remove( (a, b, c b), b, true ) => a, c
|
10
|
+
* -------------------------------------------------------------------------------
|
11
|
+
* @param $list [List] : list
|
12
|
+
* @param $value [Literal] : value to remove
|
13
|
+
* @param $recursive [Boolean] : enable / disable recursivity
|
14
|
+
* -------------------------------------------------------------------------------
|
15
|
+
* @return [List]
|
16
|
+
*/
|
17
|
+
@function remove($list, $value, $recursive: false) {
|
18
|
+
@return replace($list, $value, "", $recursive);
|
19
19
|
}
|
@@ -1,50 +1,50 @@
|
|
1
|
-
/**
|
2
|
-
* Replace value at $index from $list by $value
|
3
|
-
* -------------------------------------------------------------------------------
|
4
|
-
* @dependence `purge()`
|
5
|
-
* -------------------------------------------------------------------------------
|
6
|
-
* @example replace-nth( (a, b, c), 2, z ) => a, z, c
|
7
|
-
* @example replace-nth( (a, b, c), 0, z ) => error
|
8
|
-
* @example replace-nth( (a, b, c), -1, z ) => a, b, z
|
9
|
-
* @example replace-nth( (a, b, c), 10, z ) => error
|
10
|
-
* @example replace-nth( (a, b, c), -10, z ) => error
|
11
|
-
* -------------------------------------------------------------------------------
|
12
|
-
* @param $list [List] : list
|
13
|
-
* @param $index [Number] : index to update
|
14
|
-
* @param $value [Literal] : new value for index $index
|
15
|
-
* -------------------------------------------------------------------------------
|
16
|
-
* @raise [Error] if $index isn't an integer
|
17
|
-
* @raise [Error] if $index is 0
|
18
|
-
* @raise [Error] if abs value of $index is strictly greater than length of $list
|
19
|
-
* -------------------------------------------------------------------------------
|
20
|
-
* @return [List] | false
|
21
|
-
*/
|
22
|
-
@function replace-nth($list, $index, $value) {
|
23
|
-
$result: false;
|
24
|
-
|
25
|
-
@if type-of($index) != number {
|
26
|
-
@warn "$index: #{quote($index)} is not a number for `replace-nth`/`remove-nth`.";
|
27
|
-
@return $result;
|
28
|
-
}
|
29
|
-
|
30
|
-
@else if $index == 0 {
|
31
|
-
@warn "List index 0 must be a non-zero integer for `replace-nth`/`remove-nth`.";
|
32
|
-
@return $result;
|
33
|
-
}
|
34
|
-
|
35
|
-
@else if abs($index) > length($list) {
|
36
|
-
@warn "List index is #{$index} but list is only #{length($list)} item long for `replace-nth`/`remove-nth`.";
|
37
|
-
@return $result;
|
38
|
-
}
|
39
|
-
|
40
|
-
@else {
|
41
|
-
$result: ();
|
42
|
-
$index: if($index < 0, length($list) + $index + 1, $index);
|
43
|
-
|
44
|
-
@for $i from 1 through length($list) {
|
45
|
-
$result: append($result, if($i == $index, $value, nth($list, $i)));
|
46
|
-
}
|
47
|
-
}
|
48
|
-
|
49
|
-
@return purge($result);
|
1
|
+
/**
|
2
|
+
* Replace value at $index from $list by $value
|
3
|
+
* -------------------------------------------------------------------------------
|
4
|
+
* @dependence `purge()`
|
5
|
+
* -------------------------------------------------------------------------------
|
6
|
+
* @example replace-nth( (a, b, c), 2, z ) => a, z, c
|
7
|
+
* @example replace-nth( (a, b, c), 0, z ) => error
|
8
|
+
* @example replace-nth( (a, b, c), -1, z ) => a, b, z
|
9
|
+
* @example replace-nth( (a, b, c), 10, z ) => error
|
10
|
+
* @example replace-nth( (a, b, c), -10, z ) => error
|
11
|
+
* -------------------------------------------------------------------------------
|
12
|
+
* @param $list [List] : list
|
13
|
+
* @param $index [Number] : index to update
|
14
|
+
* @param $value [Literal] : new value for index $index
|
15
|
+
* -------------------------------------------------------------------------------
|
16
|
+
* @raise [Error] if $index isn't an integer
|
17
|
+
* @raise [Error] if $index is 0
|
18
|
+
* @raise [Error] if abs value of $index is strictly greater than length of $list
|
19
|
+
* -------------------------------------------------------------------------------
|
20
|
+
* @return [List] | false
|
21
|
+
*/
|
22
|
+
@function replace-nth($list, $index, $value) {
|
23
|
+
$result: false;
|
24
|
+
|
25
|
+
@if type-of($index) != number {
|
26
|
+
@warn "$index: #{quote($index)} is not a number for `replace-nth`/`remove-nth`.";
|
27
|
+
@return $result;
|
28
|
+
}
|
29
|
+
|
30
|
+
@else if $index == 0 {
|
31
|
+
@warn "List index 0 must be a non-zero integer for `replace-nth`/`remove-nth`.";
|
32
|
+
@return $result;
|
33
|
+
}
|
34
|
+
|
35
|
+
@else if abs($index) > length($list) {
|
36
|
+
@warn "List index is #{$index} but list is only #{length($list)} item long for `replace-nth`/`remove-nth`.";
|
37
|
+
@return $result;
|
38
|
+
}
|
39
|
+
|
40
|
+
@else {
|
41
|
+
$result: ();
|
42
|
+
$index: if($index < 0, length($list) + $index + 1, $index);
|
43
|
+
|
44
|
+
@for $i from 1 through length($list) {
|
45
|
+
$result: append($result, if($i == $index, $value, nth($list, $i)));
|
46
|
+
}
|
47
|
+
}
|
48
|
+
|
49
|
+
@return purge($result);
|
50
50
|
}
|
@@ -1,32 +1,32 @@
|
|
1
|
-
/**
|
2
|
-
* Replace $old-value by $new-value in $list
|
3
|
-
* -------------------------------------------------------------------------------
|
4
|
-
* @dependence `purge()`
|
5
|
-
* -------------------------------------------------------------------------------
|
6
|
-
* @example replace( (a, b, c), b, z ) => a, z, c
|
7
|
-
* @example replace( (a, b, c), y, z ) => a, b, c
|
8
|
-
* @example replace( (a, b, c a), a, z ) => z, b, c z
|
9
|
-
* @example replace( (a, b, c a), a, z, true ) => z, b, c z
|
10
|
-
* -------------------------------------------------------------------------------
|
11
|
-
* @param $list [List] : list
|
12
|
-
* @param $old-value [Literal] : value to replace
|
13
|
-
* @param $new-value [Literal] : new value for $old-value
|
14
|
-
* @param $recursive [Boolean] : enable / disable recursivity
|
15
|
-
* -------------------------------------------------------------------------------
|
16
|
-
* @return [List]
|
17
|
-
*/
|
18
|
-
@function replace($list, $old-value, $new-value, $recursive: false) {
|
19
|
-
$result: ();
|
20
|
-
|
21
|
-
@each $item in $list {
|
22
|
-
@if length($item) > 1 and $recursive {
|
23
|
-
$result: append($result, replace($item, $old-value, $new-value, $recursive));
|
24
|
-
}
|
25
|
-
|
26
|
-
@else {
|
27
|
-
$result: append($result, if($item == $old-value, $new-value, $item));
|
28
|
-
}
|
29
|
-
}
|
30
|
-
|
31
|
-
@return purge($result);
|
1
|
+
/**
|
2
|
+
* Replace $old-value by $new-value in $list
|
3
|
+
* -------------------------------------------------------------------------------
|
4
|
+
* @dependence `purge()`
|
5
|
+
* -------------------------------------------------------------------------------
|
6
|
+
* @example replace( (a, b, c), b, z ) => a, z, c
|
7
|
+
* @example replace( (a, b, c), y, z ) => a, b, c
|
8
|
+
* @example replace( (a, b, c a), a, z ) => z, b, c z
|
9
|
+
* @example replace( (a, b, c a), a, z, true ) => z, b, c z
|
10
|
+
* -------------------------------------------------------------------------------
|
11
|
+
* @param $list [List] : list
|
12
|
+
* @param $old-value [Literal] : value to replace
|
13
|
+
* @param $new-value [Literal] : new value for $old-value
|
14
|
+
* @param $recursive [Boolean] : enable / disable recursivity
|
15
|
+
* -------------------------------------------------------------------------------
|
16
|
+
* @return [List]
|
17
|
+
*/
|
18
|
+
@function replace($list, $old-value, $new-value, $recursive: false) {
|
19
|
+
$result: ();
|
20
|
+
|
21
|
+
@each $item in $list {
|
22
|
+
@if length($item) > 1 and $recursive {
|
23
|
+
$result: append($result, replace($item, $old-value, $new-value, $recursive));
|
24
|
+
}
|
25
|
+
|
26
|
+
@else {
|
27
|
+
$result: append($result, if($item == $old-value, $new-value, $item));
|
28
|
+
}
|
29
|
+
}
|
30
|
+
|
31
|
+
@return purge($result);
|
32
32
|
}
|
@@ -1,30 +1,30 @@
|
|
1
|
-
/**
|
2
|
-
* Reverses the order of $list
|
3
|
-
* -------------------------------------------------------------------------------
|
4
|
-
* @example reverse( (a, b, c) ) => c, b, a
|
5
|
-
* @example reverse( (a, b, c a) ) => c a, b, a
|
6
|
-
* @example reverse( (a, b, c a), true ) => a c, b, a
|
7
|
-
* @example reverse( a ) => a
|
8
|
-
* -------------------------------------------------------------------------------
|
9
|
-
* @param $list [List] : list
|
10
|
-
* @param $recursive [Boolean] : enable / disable recursivity
|
11
|
-
* -------------------------------------------------------------------------------
|
12
|
-
* @return [List]
|
13
|
-
*/
|
14
|
-
@function reverse($list, $recursive: false) {
|
15
|
-
$result: ();
|
16
|
-
|
17
|
-
@for $i from length($list) * -1 through -1 {
|
18
|
-
$item: nth($list, abs($i));
|
19
|
-
|
20
|
-
@if length($item) > 1 and $recursive {
|
21
|
-
$result: append($result, reverse($item, $recursive));
|
22
|
-
}
|
23
|
-
|
24
|
-
@else {
|
25
|
-
$result: append($result, $item);
|
26
|
-
}
|
27
|
-
}
|
28
|
-
|
29
|
-
@return $result;
|
1
|
+
/**
|
2
|
+
* Reverses the order of $list
|
3
|
+
* -------------------------------------------------------------------------------
|
4
|
+
* @example reverse( (a, b, c) ) => c, b, a
|
5
|
+
* @example reverse( (a, b, c a) ) => c a, b, a
|
6
|
+
* @example reverse( (a, b, c a), true ) => a c, b, a
|
7
|
+
* @example reverse( a ) => a
|
8
|
+
* -------------------------------------------------------------------------------
|
9
|
+
* @param $list [List] : list
|
10
|
+
* @param $recursive [Boolean] : enable / disable recursivity
|
11
|
+
* -------------------------------------------------------------------------------
|
12
|
+
* @return [List]
|
13
|
+
*/
|
14
|
+
@function reverse($list, $recursive: false) {
|
15
|
+
$result: ();
|
16
|
+
|
17
|
+
@for $i from length($list) * -1 through -1 {
|
18
|
+
$item: nth($list, abs($i));
|
19
|
+
|
20
|
+
@if length($item) > 1 and $recursive {
|
21
|
+
$result: append($result, reverse($item, $recursive));
|
22
|
+
}
|
23
|
+
|
24
|
+
@else {
|
25
|
+
$result: append($result, $item);
|
26
|
+
}
|
27
|
+
}
|
28
|
+
|
29
|
+
@return $result;
|
30
30
|
}
|