SassyLists 0.4.9 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. data/CHANGELOG.md +8 -0
  2. data/lib/SassyLists.rb +2 -2
  3. data/stylesheets/SassyLists/_chunk.scss +27 -32
  4. data/stylesheets/SassyLists/_contain.scss +2 -5
  5. data/stylesheets/SassyLists/_count-values.scss +9 -22
  6. data/stylesheets/SassyLists/_debug.scss +64 -66
  7. data/stylesheets/SassyLists/_explode.scss +49 -0
  8. data/stylesheets/SassyLists/_first.scss +10 -5
  9. data/stylesheets/SassyLists/_flatten.scss +16 -13
  10. data/stylesheets/SassyLists/_insert-nth.scss +22 -25
  11. data/stylesheets/SassyLists/_intersection.scss +12 -13
  12. data/stylesheets/SassyLists/_is-symmetrical.scss +2 -7
  13. data/stylesheets/SassyLists/_last-index.scss +7 -9
  14. data/stylesheets/SassyLists/_last.scss +10 -5
  15. data/stylesheets/SassyLists/_loop.scss +19 -12
  16. data/stylesheets/SassyLists/_prepend.scss +7 -8
  17. data/stylesheets/SassyLists/_purge.scss +8 -9
  18. data/stylesheets/SassyLists/_random-value.scss +12 -7
  19. data/stylesheets/SassyLists/_remove-duplicates.scss +8 -17
  20. data/stylesheets/SassyLists/_remove-nth.scss +2 -12
  21. data/stylesheets/SassyLists/_remove.scss +4 -9
  22. data/stylesheets/SassyLists/_replace-nth.scss +7 -29
  23. data/stylesheets/SassyLists/_replace.scss +14 -23
  24. data/stylesheets/SassyLists/_reverse.scss +14 -20
  25. data/stylesheets/SassyLists/_shuffle.scss +14 -10
  26. data/stylesheets/SassyLists/_slice.scss +25 -33
  27. data/stylesheets/SassyLists/_sort.scss +25 -39
  28. data/stylesheets/SassyLists/_sum.scss +12 -17
  29. data/stylesheets/SassyLists/_to-string.scss +10 -21
  30. data/stylesheets/SassyLists/_union.scss +3 -2
  31. data/stylesheets/SassyLists/helpers/_str-compare.scss +27 -0
  32. data/stylesheets/SassyLists/helpers/_true.scss +15 -0
  33. data/stylesheets/_SassyLists.scss +3 -0
  34. metadata +5 -2
@@ -4,27 +4,34 @@
4
4
  // -------------------------------------------------------------------------------
5
5
  // @alias `shift-indexes()`
6
6
  // -------------------------------------------------------------------------------
7
- // @example loop(a b c d e) => e, a, b, c, d
8
- // @example loop(a b c d e, 2) => d, e, a, b, c
9
- // @example loop(a b c d e, -2) => c, d, e, a, b
10
- // -------------------------------------------------------------------------------
11
7
  // @param $list [List] : list
12
8
  // @param $value [Number] : number of position between old and new indexes
13
9
  // -------------------------------------------------------------------------------
14
- // @return [List]
10
+ // @raise [Error] if $value isn't an integer
11
+ // -------------------------------------------------------------------------------
12
+ // @return [List] | false
15
13
 
16
14
  @function loop($list, $value: 1) {
17
- $result: ();
18
- $length: length($list);
15
+ @if type-of($value) != "number" {
16
+ @warn "#{$value} is not a number for `loop`.";
17
+ @return false;
18
+ }
19
+
20
+ @if length($list) < 2 {
21
+ @return $list;
22
+ }
23
+
24
+ $result: ();
25
+ $length: length($list);
19
26
 
20
- @for $i from 0 to $length {
21
- $result: append($result, nth($list, ($i - $value) % $length + 1));
22
- }
27
+ @for $i from 0 to $length {
28
+ $result: append($result, nth($list, ($i - $value) % $length + 1), list-separator($list));
29
+ }
23
30
 
24
- @return $result;
31
+ @return $result;
25
32
  }
26
33
 
27
34
  // Alias
28
35
  @function shift-indexes($list, $value: 1) {
29
- @return loop($list, $value);
36
+ @return loop($list, $value);
30
37
  }
@@ -2,8 +2,7 @@
2
2
  // -------------------------------------------------------------------------------
3
3
  // @documentation http://sassylists.com/documentation/#prepend
4
4
  // -------------------------------------------------------------------------------
5
- // @example prepend(a b c, z) => z, a, b, c
6
- // @example prepend(a b c, y z) => y z, a, b, c
5
+ // @dependence `is-true()`
7
6
  // -------------------------------------------------------------------------------
8
7
  // @param $list [List] : list
9
8
  // @param $value [Literal] : value to prepend to the list
@@ -11,11 +10,11 @@
11
10
  // @return [List]
12
11
 
13
12
  @function prepend($list, $value) {
14
- @if $value and $value != "" and $value != () {
15
- @return join($value, $list);
16
- }
13
+ @if is-true($value) {
14
+ @return join($value, $list, list-separator($list));
15
+ }
17
16
 
18
- @else {
19
- @return $list;
20
- }
17
+ @else {
18
+ @return $list;
19
+ }
21
20
  }
@@ -4,26 +4,25 @@
4
4
  // -------------------------------------------------------------------------------
5
5
  // @alias `clean()`
6
6
  // -------------------------------------------------------------------------------
7
- // @example purge(a null b false c) => a, b, c
8
- // @example purge(a b c '') => a, b, c
7
+ // @dependence `is-true()`
9
8
  // -------------------------------------------------------------------------------
10
9
  // @param $list [List] : list
11
10
  // -------------------------------------------------------------------------------
12
11
  // @return [List]
13
12
 
14
13
  @function purge($list) {
15
- $result: ();
14
+ $result: ();
16
15
 
17
- @each $item in $list {
18
- @if $item and $item != "" and $item != () {
19
- $result: append($result, $item);
20
- }
16
+ @each $item in $list {
17
+ @if is-true($item) {
18
+ $result: append($result, $item, list-separator($list));
21
19
  }
20
+ }
22
21
 
23
- @return $result;
22
+ @return $result;
24
23
  }
25
24
 
26
25
  // Alias
27
26
  @function clean($list) {
28
- @return purge($list);
27
+ @return purge($list);
29
28
  }
@@ -5,23 +5,28 @@
5
5
  // @alias `roll()`
6
6
  // @alias `luck()`
7
7
  // -------------------------------------------------------------------------------
8
- // @dependence `rand()` (Ruby)
9
- // -------------------------------------------------------------------------------
10
- // @example random-value(a b c d e) => c
8
+ // @dependence `random()` (Ruby)
11
9
  // -------------------------------------------------------------------------------
12
10
  // @param $list [List] : List
13
11
  // -------------------------------------------------------------------------------
14
- // @return [Literal]
12
+ // @raise [Error] if $list is empty
13
+ // -------------------------------------------------------------------------------
14
+ // @return [Literal] | false
15
15
 
16
16
  @function random-value($list) {
17
- @return nth($list, random(length($list)) + 1);
17
+ @if length($list) == 0 {
18
+ @warn "Cannot find a random value in an empty list.";
19
+ @return false;
20
+ }
21
+
22
+ @return nth($list, random(length($list)) + 1);
18
23
  }
19
24
 
20
25
  // Aliases
21
26
  @function roll($list) {
22
- @return random-value($list);
27
+ @return random-value($list);
23
28
  }
24
29
 
25
30
  @function luck($list) {
26
- @return random-value($list);
31
+ @return random-value($list);
27
32
  }
@@ -4,33 +4,24 @@
4
4
  // -------------------------------------------------------------------------------
5
5
  // @alias `unique()`
6
6
  // -------------------------------------------------------------------------------
7
- // @example remove-duplicates(a b a c b d c e) => a, b, c, d, e
8
- // @example remove-duplicates(a b (c c c), true) => a, b, c
9
- // -------------------------------------------------------------------------------
10
7
  // @param $list [List] : list
11
8
  // @param $recursive [Boolean] : enable / disable recursivity
12
9
  // -------------------------------------------------------------------------------
13
10
  // @return [List]
14
11
 
15
- @function remove-duplicates($list, $recursive: false) {
16
- $result: ();
17
-
18
- @each $item in $list {
19
- @if not index($result, $item) {
20
- @if length($item) > 1 and $recursive {
21
- $result: append($result, remove-duplicates($item, $recursive));
22
- }
12
+ @function remove-duplicates($list) {
13
+ $result: ();
23
14
 
24
- @else {
25
- $result: append($result, $item);
26
- }
27
- }
15
+ @each $item in $list {
16
+ @if not index($result, $item) {
17
+ $result: append($result, $item, list-separator($list));
28
18
  }
19
+ }
29
20
 
30
- @return $result;
21
+ @return $result;
31
22
  }
32
23
 
33
24
  // Alias
34
25
  @function unique($list, $recursive: false) {
35
- @return remove-duplicates($list, $recursive);
26
+ @return remove-duplicates($list, $recursive);
36
27
  }
@@ -6,26 +6,16 @@
6
6
  // -------------------------------------------------------------------------------
7
7
  // @dependence `replace-nth()`
8
8
  // -------------------------------------------------------------------------------
9
- // @example remove-nth(a b c, 2) => a, c
10
- // @example remove-nth(a b c, 0) => error
11
- // @example remove-nth(a b c, -1) => a, b
12
- // @example remove-nth(a b c, 10) => error
13
- // @example remove-nth(a b c, -10) => error
14
- // -------------------------------------------------------------------------------
15
9
  // @param $list [List] : list
16
10
  // @param $index [Number] : index to remove
17
11
  // -------------------------------------------------------------------------------
18
- // @raise [Error] if $index isn't an integer
19
- // @raise [Error] if $index is 0
20
- // @raise [Error] if abs value of $index is strictly greater then length of $list
21
- // -------------------------------------------------------------------------------
22
12
  // @return [List] | false
23
13
 
24
14
  @function remove-nth($list, $index) {
25
- @return replace-nth($list, $index, "");
15
+ @return replace-nth($list, $index, "");
26
16
  }
27
17
 
28
18
  // Alias
29
19
  @function without-nth($list, $index) {
30
- @return remove-nth($list, $index);
20
+ @return remove-nth($list, $index);
31
21
  }
@@ -6,22 +6,17 @@
6
6
  // -------------------------------------------------------------------------------
7
7
  // @dependence `replace()`
8
8
  // -------------------------------------------------------------------------------
9
- // @example remove(a b c, b) => a, c
10
- // @example remove(a b c, z) => a, b, c
11
- // @example remove(a b c b, b) => a, c b
12
- // @example remove(a b c b, b, true) => a, c
13
- // -------------------------------------------------------------------------------
14
9
  // @param $list [List] : list
15
10
  // @param $value [Literal] : value to remove
16
11
  // @param $recursive [Boolean] : enable / disable recursivity
17
12
  // -------------------------------------------------------------------------------
18
13
  // @return [List]
19
14
 
20
- @function remove($list, $value, $recursive: false) {
21
- @return replace($list, $value, null, $recursive);
15
+ @function remove($list, $value) {
16
+ @return replace($list, $value, null);
22
17
  }
23
18
 
24
19
  // Alias
25
- @function without($list, $value, $recursive: false) {
26
- @return remove($list, $value, $recursive);
20
+ @function without($list, $value) {
21
+ @return remove($list, $value);
27
22
  }
@@ -2,11 +2,7 @@
2
2
  // -------------------------------------------------------------------------------
3
3
  // @documentation http://sassylists.com/documentation/#replace-nth
4
4
  // -------------------------------------------------------------------------------
5
- // @example replace-nth(a b c, 2, z) => a, z, c
6
- // @example replace-nth(a b c, 0, z) => error
7
- // @example replace-nth(a b c, 10, z) => error
8
- // @example replace-nth(a b c, -1, z) => a, b, z
9
- // @example replace-nth(a b c, -10, z) => error
5
+ // @dependence `purge()`
10
6
  // -------------------------------------------------------------------------------
11
7
  // @param $list [List] : list
12
8
  // @param $index [Number] : index to update
@@ -19,29 +15,11 @@
19
15
  // @return [List] | false
20
16
 
21
17
  @function replace-nth($list, $index, $value) {
22
- @if type-of($index) != number {
23
- @warn "List index #{$index} is not a number for `replace-nth`/`remove-nth`.";
24
- @return false;
25
- }
18
+ @if type-of($index) != "number" or $index == 0 or abs($index) > length($list) {
19
+ @warn "Invalid index (#{$index}) for `replace-nth`.";
20
+ @return false;
21
+ }
26
22
 
27
- @if $index == 0 {
28
- @warn "List index 0 must be a non-zero integer for `replace-nth`/`remove-nth`.";
29
- @return false;
30
- }
31
-
32
- @if abs($index) > length($list) {
33
- @warn "List index is #{$index} but list is only #{length($list)} item long for `replace-nth`/`remove-nth`.";
34
- @return false;
35
- }
36
-
37
- $result: ();
38
- $index: if($index < 0, length($list) + $index + 1, $index);
39
-
40
- @for $i from 1 through length($list) {
41
- @if $value and $value != "" and $value != () {
42
- $result: append($result, if($i == $index, $value, nth($list, $i)));
43
- }
44
- }
45
-
46
- @return $result;
23
+ $list: set-nth($list, $index, $value);
24
+ @return if(not is-true($value), purge($list), $list);
47
25
  }
@@ -1,37 +1,28 @@
1
- // Replaces $old-value by $new-value in $list
1
+ // Replaces $old by $new in $list
2
2
  // -------------------------------------------------------------------------------
3
3
  // @documentation http://sassylists.com/documentation.html#replace
4
4
  // -------------------------------------------------------------------------------
5
- // @example replace( (a, b, c), b, z ) => a, z, c
6
- // @example replace( (a, b, c), y, z ) => a, b, c
7
- // @example replace( (a, b, c a), a, z ) => z, b, c z
8
- // @example replace( (a, b, c a), a, z, true ) => z, b, c z
9
- // -------------------------------------------------------------------------------
10
5
  // @param $list [List] : list
11
6
  // @param $old [Literal] : value to replace
12
- // @param $value [Literal] : new value for $old-value
13
- // @param $recursive [Boolean] : enable / disable recursivity
7
+ // @param $value [Literal] : new value for $old
14
8
  // -------------------------------------------------------------------------------
15
9
  // @return [List]
16
10
 
17
- @function replace($list, $old, $value, $recursive: false) {
18
- $result: ();
11
+ @function replace($list, $old, $value) {
12
+ $running: true;
19
13
 
20
- @each $item in $list {
21
- @if $item == $old {
22
- @if $value and $value != '' and $value != () {
23
- $result: append($result, $value);
24
- }
25
- }
14
+ @while $running {
15
+ $index: index($list, $old);
26
16
 
27
- @else if length($item) > 1 and $recursive {
28
- $result: append($result, replace($item, $old, $value, $recursive));
29
- }
17
+ @if not $index {
18
+ $running: false;
19
+ }
30
20
 
31
- @else {
32
- $result: append($result, $item);
33
- }
21
+ @else {
22
+ $list: set-nth($list, $index, $value);
34
23
  }
35
24
 
36
- @return $result;
25
+ }
26
+
27
+ @return if(not is-true($value), purge($list), $list);
37
28
  }
@@ -4,34 +4,28 @@
4
4
  // -------------------------------------------------------------------------------
5
5
  // @alias `mirror()`
6
6
  // -------------------------------------------------------------------------------
7
- // @example reverse(a b c) => c, b, a
8
- // @example reverse(a b (c a)) => c a, b, a
9
- // @example reverse(a b (c a), true) => a c, b, a
10
- // -------------------------------------------------------------------------------
11
7
  // @param $list [List] : list
12
- // @param $recursive [Boolean] : enable / disable recursivity
13
8
  // -------------------------------------------------------------------------------
14
9
  // @return [List]
15
10
 
16
- @function reverse($list, $recursive: false) {
17
- $result: ();
18
-
19
- @for $i from length($list) * -1 through -1 {
20
- $item: nth($list, abs($i));
11
+ @function reverse($list) {
12
+ $length: length($list);
13
+ $end: floor($length/2);
21
14
 
22
- @if length($item) > 1 and $recursive {
23
- $result: append($result, reverse($item, $recursive));
24
- }
15
+ @if $length < 2 {
16
+ @return $list;
17
+ }
25
18
 
26
- @else {
27
- $result: append($result, $item);
28
- }
29
- }
19
+ @for $i from 1 through $end {
20
+ $tmp: nth($list, $i);
21
+ $list: set-nth($list, $i, nth($list, -$i));
22
+ $list: set-nth($list, -$i, $tmp);
23
+ }
30
24
 
31
- @return $result;
25
+ @return $list;
32
26
  }
33
27
 
34
28
  // Alias
35
- @function mirror($list, $recursive: false) {
36
- @return reverse($list, $recursive);
29
+ @function mirror($list) {
30
+ @return reverse($list);
37
31
  }
@@ -4,24 +4,28 @@
4
4
  // -------------------------------------------------------------------------------
5
5
  // @alias `randomize()`
6
6
  // -------------------------------------------------------------------------------
7
- // @example shuffle(a b c d e) => b d c e a
8
- // -------------------------------------------------------------------------------
9
7
  // @param $list [List] : list
10
8
  // -------------------------------------------------------------------------------
11
9
  // @return [List]
12
10
 
13
11
  @function shuffle($list) {
14
- @for $i from -1 * length($list) through -1 {
15
- $i: abs($i);
16
- $j: random(length($list) - 1) + 1;
17
- $tmp: nth($list, $i);
18
- $list: set-nth($list, $i, nth($list, $j));
19
- $list: set-nth($list, $j, $tmp);
20
- }
12
+ $length: length($list);
13
+
14
+ @if $length < 2 {
21
15
  @return $list;
16
+ }
17
+
18
+ @for $i from -1 * $length through -1 {
19
+ $i: abs($i);
20
+ $j: random($length - 1) + 1;
21
+ $tmp: nth($list, $i);
22
+ $list: set-nth($list, $i, nth($list, $j));
23
+ $list: set-nth($list, $j, $tmp);
24
+ }
25
+ @return $list;
22
26
  }
23
27
 
24
28
  // Alias
25
29
  @function randomize($list) {
26
- @return shuffle($list);
30
+ @return shuffle($list);
27
31
  }
@@ -2,13 +2,6 @@
2
2
  // -------------------------------------------------------------------------------
3
3
  // @documentation http://sassylists.com/documentation/#slice
4
4
  // -------------------------------------------------------------------------------
5
- // @example slice(a b c d, 2, 3) => b, c
6
- // @example slice(a b c d, 3, 2) => error
7
- // @example slice(a b c d, 3, 5) => error
8
- // @example slice(a b c d, -1, 3) => error
9
- // @example slice(a b c d, 0, 3) => error
10
- // @example slice(a b c d, 3, 3) => c
11
- // -------------------------------------------------------------------------------
12
5
  // @param $list [List] : list
13
6
  // @param $start [Number] : start index
14
7
  // @param $end [Number] : end index
@@ -22,36 +15,35 @@
22
15
  // @return [List] | false
23
16
 
24
17
  @function slice($list, $start: 1, $end: length($list)) {
25
- @if type-of($start) != number or type-of($end) != number {
26
- @warn "List indexes #{$start} and #{$end} must be numbers for `slice`.";
27
- @return false;
28
- }
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 false;
21
+ }
29
22
 
30
- @if $start > $end {
31
- @warn "Start index is #{$start} but has to be lesser than or equals to the end index (#{$end}) for `slice`.";
32
- @return false;
33
- }
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 false;
26
+ }
34
27
 
35
- @if $start < 1 or $end < 1 {
36
- @warn "List indexes must be non-zero integers for `slice`.";
37
- @return false;
38
- }
28
+ @if $start < 1 or $end < 1 {
29
+ @warn "List indexes must be non-zero integers for `slice`.";
30
+ @return false;
31
+ }
39
32
 
40
- @if $start > length($list) {
41
- @warn "Start index is #{$start} but list is only #{length($list)} items long for `slice`.";
42
- @return false;
43
- }
33
+ @if $start > length($list) {
34
+ @warn "Start index is #{$start} but list is only #{length($list)} items long for `slice`.";
35
+ @return false;
36
+ }
44
37
 
45
- @if $end > length($list) {
46
- @warn "End index is #{$end} but list is only #{length($list)} items long for `slice`.";
47
- @return false;
48
- }
38
+ @if $end > length($list) {
39
+ @warn "End index is #{$end} but list is only #{length($list)} items long for `slice`.";
40
+ @return false;
41
+ }
49
42
 
50
- $result: ();
51
-
52
- @for $i from $start through $end {
53
- $result: append($result, nth($list, $i));
54
- }
43
+ $result: ();
44
+ @for $i from $start through $end {
45
+ $result: append($result, nth($list, $i), list-separator($list));
46
+ }
55
47
 
56
- @return $result;
48
+ @return $result;
57
49
  }
@@ -1,55 +1,41 @@
1
- // Sorts numeric values of $list
1
+ // Sorts values of $list using quick-sort algorithm
2
2
  // -------------------------------------------------------------------------------
3
3
  // @documentation http://sassylists.com/documentation/#sort
4
4
  // -------------------------------------------------------------------------------
5
5
  // @alias `order()`
6
6
  // -------------------------------------------------------------------------------
7
- // @example sort(5 12 4.7 6 69 6) => 4.7, 5, 6, 6, 12, 69
8
- // @example sort(5 12 4.7 "8" 6 14px 69 6) => 4.7, 5, 6, 6, 12, 69
7
+ // @dependence `str-compare()`
9
8
  // -------------------------------------------------------------------------------
10
9
  // @param $list [List] : list
11
- // @param $ascending [Boolean] : ascending or descending
12
- // -------------------------------------------------------------------------------
13
- // @raise [Warning] if not-number found
10
+ // @param $order [List] : order
14
11
  // -------------------------------------------------------------------------------
15
12
  // @return [List]
16
13
 
17
- @function sort($list) {
18
- $less: ();
19
- $equal: ();
20
- $large: ();
21
- $seed: ceil(length($list) / 2);
22
-
23
- @if length($list) > 1 {
24
- $seed: nth($list, $seed);
25
-
26
- @each $item in $list {
27
- @if comparable($seed, $item) {
28
- @if $item < $seed {
29
- $less: append($less, $item);
30
- }
31
-
32
- @else if $item == $seed {
33
- $equal: append($equal, $item);
34
- }
35
-
36
- @else {
37
- $large: append($large, $item);
38
- }
39
- }
40
-
41
- @else {
42
- @warn "Not integer value found. Omitted.";
43
- }
44
- }
45
-
46
- @return join(join(sort($less), $equal), sort($large));
14
+ @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") {
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 str-compare($item, $seed, $order) {
27
+ $less: append($less, $item, list-separator($list));
28
+ }
29
+ @else if not str-compare($item, $seed, $order) {
30
+ $large: append($large, $item, list-separator($list));
31
+ }
47
32
  }
48
-
49
- @return $list;
33
+ @return join(join(sort($less, $order), $equal), sort($large, $order));
34
+ }
35
+ @return $list;
50
36
  }
51
37
 
52
38
  // Alias
53
39
  @function order($list) {
54
- @return sort($list);
40
+ @return sort($list);
55
41
  }
@@ -1,33 +1,28 @@
1
- // Sums up all unitless values in $list
1
+ // Sums up all numeric values in $list
2
2
  // -------------------------------------------------------------------------------
3
3
  // @documentation http://sassylists.com/documentation/#sum
4
4
  // -------------------------------------------------------------------------------
5
- // @example sum(1 2 3 4 5) => 15
6
- // @example sum(1 a 2 b 3) => 6
7
- // @example sum(10px 3em 5%) => 0
8
- // @example sum(10px 3em 5%, true) => 18
9
- // -------------------------------------------------------------------------------
10
5
  // @param $list [List] : list
11
6
  // @param $force [Boolean] : enable / disable parseInt
12
7
  // -------------------------------------------------------------------------------
13
8
  // @return [Number]
14
9
 
15
10
  @function sum($list, $force: false) {
16
- $result: 0;
11
+ $result: 0;
17
12
 
18
- @each $item in $list {
19
- @if type-of($item) == number {
13
+ @each $item in $list {
14
+ @if type-of($item) == number {
20
15
 
21
- @if $force and not unitless($item) {
22
- $item: $item / ($item * 0 + 1);
23
- }
16
+ @if $force and not unitless($item) {
17
+ $item: $item / ($item * 0 + 1);
18
+ }
24
19
 
25
- @if unitless($item) {
26
- $result: $result + $item;
27
- }
20
+ @if unitless($item) {
21
+ $result: $result + $item;
22
+ }
28
23
 
29
- }
30
24
  }
25
+ }
31
26
 
32
- @return $result;
27
+ @return $result;
33
28
  }