SassyLists 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +36 -36
  3. data/lib/SassyLists.rb +13 -13
  4. data/stylesheets/SassyLists/_chunk.scss +41 -41
  5. data/stylesheets/SassyLists/_contain.scss +17 -17
  6. data/stylesheets/SassyLists/_count-values.scss +18 -18
  7. data/stylesheets/SassyLists/_debug.scss +96 -96
  8. data/stylesheets/SassyLists/_explode.scss +49 -49
  9. data/stylesheets/SassyLists/_first.scss +23 -23
  10. data/stylesheets/SassyLists/_flatten.scss +35 -35
  11. data/stylesheets/SassyLists/_insert-nth.scss +46 -46
  12. data/stylesheets/SassyLists/_intersection.scss +28 -28
  13. data/stylesheets/SassyLists/_is-symmetrical.scss +18 -18
  14. data/stylesheets/SassyLists/_last-index.scss +20 -20
  15. data/stylesheets/SassyLists/_last.scss +17 -17
  16. data/stylesheets/SassyLists/_loop.scss +35 -35
  17. data/stylesheets/SassyLists/_prepend.scss +20 -20
  18. data/stylesheets/SassyLists/_purge.scss +27 -27
  19. data/stylesheets/SassyLists/_random-value.scss +29 -29
  20. data/stylesheets/SassyLists/_remove-duplicates.scss +24 -24
  21. data/stylesheets/SassyLists/_remove-nth.scss +19 -19
  22. data/stylesheets/SassyLists/_remove.scss +20 -20
  23. data/stylesheets/SassyLists/_replace-nth.scss +24 -24
  24. data/stylesheets/SassyLists/_replace.scss +29 -29
  25. data/stylesheets/SassyLists/_reverse.scss +29 -29
  26. data/stylesheets/SassyLists/_shuffle.scss +29 -29
  27. data/stylesheets/SassyLists/_slice.scss +48 -48
  28. data/stylesheets/SassyLists/_sort.scss +40 -40
  29. data/stylesheets/SassyLists/_sum.scss +28 -28
  30. data/stylesheets/SassyLists/_tail.scss +18 -18
  31. data/stylesheets/SassyLists/_to-string.scss +25 -25
  32. data/stylesheets/SassyLists/_union.scss +21 -21
  33. data/stylesheets/SassyLists/_walk.scss +23 -23
  34. data/stylesheets/SassyLists/helpers/_str-compare.scss +24 -24
  35. data/stylesheets/SassyLists/helpers/_true.scss +10 -10
  36. data/stylesheets/_SassyLists.scss +38 -38
  37. metadata +3 -3
@@ -1,21 +1,21 @@
1
- // Removes value(s) $value from $list
2
- //
3
- // @ignore Documentation: http://sassylists.com/documentation/#remove
4
- //
5
- // @requires 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 remove($list, $value) {
14
- @return replace($list, $value, null);
15
- }
16
-
17
- // @alias remove
18
-
19
- @function without($list, $value) {
20
- @return remove($list, $value);
1
+ // Removes value(s) $value from $list
2
+ //
3
+ // @ignore Documentation: http://sassylists.com/documentation/#remove
4
+ //
5
+ // @requires 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 remove($list, $value) {
14
+ @return replace($list, $value, null);
15
+ }
16
+
17
+ // @alias remove
18
+
19
+ @function without($list, $value) {
20
+ @return remove($list, $value);
21
21
  }
@@ -1,24 +1,24 @@
1
- // Replaces value at $index from $list by $value
2
- //
3
- // @ignore Documentation: http://sassylists.com/documentation/#replace-nth
4
- //
5
- // @requires purge
6
- // @requires 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 `replace-nth`.
13
- //
14
- // @return {List | Bool}
15
-
16
- @function replace-nth($list, $index, $value) {
17
- @if type-of($index) != "number" or $index == 0 or abs($index) > length($list) {
18
- @warn "Invalid index (#{$index}) for `replace-nth`.";
19
- @return false;
20
- }
21
-
22
- $list: set-nth($list, $index, $value);
23
- @return if(not is-true($value), purge($list), $list);
24
- }
1
+ // Replaces value at $index from $list by $value
2
+ //
3
+ // @ignore Documentation: http://sassylists.com/documentation/#replace-nth
4
+ //
5
+ // @requires purge
6
+ // @requires 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 `replace-nth`.
13
+ //
14
+ // @return {List | Bool}
15
+
16
+ @function replace-nth($list, $index, $value) {
17
+ @if type-of($index) != "number" or $index == 0 or abs($index) > length($list) {
18
+ @warn "Invalid index (#{$index}) for `replace-nth`.";
19
+ @return false;
20
+ }
21
+
22
+ $list: set-nth($list, $index, $value);
23
+ @return if(not is-true($value), purge($list), $list);
24
+ }
@@ -1,30 +1,30 @@
1
- // Replaces $old by $new in $list
2
- //
3
- // @ignore Documentation: http://sassylists.com/documentation.html#replace
4
- //
5
- // @requires is-true
6
- //
7
- // @param {List} $list - list to update
8
- // @param {*} $old - value to replace
9
- // @param {*} $value - new value for $old
10
- //
11
- // @return {List}
12
-
13
- @function replace($list, $old, $value) {
14
- $running: true;
15
-
16
- @while $running {
17
- $index: index($list, $old);
18
-
19
- @if not $index {
20
- $running: false;
21
- }
22
-
23
- @else {
24
- $list: set-nth($list, $index, $value);
25
- }
26
-
27
- }
28
-
29
- @return if(not is-true($value), purge($list), $list);
1
+ // Replaces $old by $new in $list
2
+ //
3
+ // @ignore Documentation: http://sassylists.com/documentation.html#replace
4
+ //
5
+ // @requires is-true
6
+ //
7
+ // @param {List} $list - list to update
8
+ // @param {*} $old - value to replace
9
+ // @param {*} $value - new value for $old
10
+ //
11
+ // @return {List}
12
+
13
+ @function replace($list, $old, $value) {
14
+ $running: true;
15
+
16
+ @while $running {
17
+ $index: index($list, $old);
18
+
19
+ @if not $index {
20
+ $running: false;
21
+ }
22
+
23
+ @else {
24
+ $list: set-nth($list, $index, $value);
25
+ }
26
+
27
+ }
28
+
29
+ @return if(not is-true($value), purge($list), $list);
30
30
  }
@@ -1,30 +1,30 @@
1
- // Reverses the order of $list
2
- //
3
- // @ignore Documentation: http://sassylists.com/documentation/#reverse
4
- //
5
- // @param {List} $list - list to revers
6
- //
7
- // @return {List}
8
-
9
- @function 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 reverse
27
-
28
- @function mirror($list) {
29
- @return reverse($list);
1
+ // Reverses the order of $list
2
+ //
3
+ // @ignore Documentation: http://sassylists.com/documentation/#reverse
4
+ //
5
+ // @param {List} $list - list to revers
6
+ //
7
+ // @return {List}
8
+
9
+ @function 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 reverse
27
+
28
+ @function mirror($list) {
29
+ @return reverse($list);
30
30
  }
@@ -1,29 +1,29 @@
1
- // Shuffle function using Fisher-Yates method
2
- //
3
- // @ignore Documentation: http://sassylists.com/documentation/#shuffle
4
- //
5
- // @param {List} $list - list to shuffle
6
- //
7
- // @return {List}
8
-
9
- @function shuffle($list) {
10
- $length: length($list);
11
-
12
- @if $length < 2 {
13
- @return $list;
14
- }
15
-
16
- @for $i from $length through 1 {
17
- $j: random($length - 1) + 1;
18
- $tmp: nth($list, $i);
19
- $list: set-nth($list, $i, nth($list, $j));
20
- $list: set-nth($list, $j, $tmp);
21
- }
22
- @return $list;
23
- }
24
-
25
- // @alias shuffle
26
-
27
- @function randomize($list) {
28
- @return shuffle($list);
29
- }
1
+ // Shuffle function using Fisher-Yates method
2
+ //
3
+ // @ignore Documentation: http://sassylists.com/documentation/#shuffle
4
+ //
5
+ // @param {List} $list - list to shuffle
6
+ //
7
+ // @return {List}
8
+
9
+ @function shuffle($list) {
10
+ $length: length($list);
11
+
12
+ @if $length < 2 {
13
+ @return $list;
14
+ }
15
+
16
+ @for $i from $length through 1 {
17
+ $j: random($length - 1) + 1;
18
+ $tmp: nth($list, $i);
19
+ $list: set-nth($list, $i, nth($list, $j));
20
+ $list: set-nth($list, $j, $tmp);
21
+ }
22
+ @return $list;
23
+ }
24
+
25
+ // @alias shuffle
26
+
27
+ @function randomize($list) {
28
+ @return shuffle($list);
29
+ }
@@ -1,49 +1,49 @@
1
- // Slices $list between $start and $end
2
- //
3
- // @ignore Documentation: http://sassylists.com/documentation/#slice
4
- //
5
- // @param {List} $list - list to slice
6
- // @param {Number} $start (1) - start index
7
- // @param {Number} $end (length($list)) - end index
8
- //
9
- // @throws List indexes $start and $end must be numbers for `slice`.
10
- // @throws Start index has to be lesser than or equals to the end index for `slice`.
11
- // @throws List indexes must be non-zero integers for `slice`.
12
- // @throws Start index has to be lesser than or equal to list length for `slice`.
13
- // @throws End index has to be lesser than or equal to list length for `slice`.
14
- //
15
- // @return {List | Bool}
16
-
17
- @function slice($list, $start: 1, $end: length($list)) {
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
- }
22
-
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
- }
27
-
28
- @if $start < 1 or $end < 1 {
29
- @warn "List indexes must be non-zero integers for `slice`.";
30
- @return false;
31
- }
32
-
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
- }
37
-
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
- }
42
-
43
- $result: ();
44
- @for $i from $start through $end {
45
- $result: append($result, nth($list, $i), list-separator($list));
46
- }
47
-
48
- @return $result;
1
+ // Slices $list between $start and $end
2
+ //
3
+ // @ignore Documentation: http://sassylists.com/documentation/#slice
4
+ //
5
+ // @param {List} $list - list to slice
6
+ // @param {Number} $start (1) - start index
7
+ // @param {Number} $end (length($list)) - end index
8
+ //
9
+ // @throws List indexes $start and $end must be numbers for `slice`.
10
+ // @throws Start index has to be lesser than or equals to the end index for `slice`.
11
+ // @throws List indexes must be non-zero integers for `slice`.
12
+ // @throws Start index has to be lesser than or equal to list length for `slice`.
13
+ // @throws End index has to be lesser than or equal to list length for `slice`.
14
+ //
15
+ // @return {List | Bool}
16
+
17
+ @function slice($list, $start: 1, $end: length($list)) {
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
+ }
22
+
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
+ }
27
+
28
+ @if $start < 1 or $end < 1 {
29
+ @warn "List indexes must be non-zero integers for `slice`.";
30
+ @return false;
31
+ }
32
+
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
+ }
37
+
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
+ }
42
+
43
+ $result: ();
44
+ @for $i from $start through $end {
45
+ $result: append($result, nth($list, $i), list-separator($list));
46
+ }
47
+
48
+ @return $result;
49
49
  }
@@ -1,40 +1,40 @@
1
- // Sorts values of $list using quick-sort algorithm
2
- //
3
- // @ignore Documentation: http://sassylists.com/documentation/#sort
4
- //
5
- // @requires str-compare
6
- //
7
- // @param {List} $list - list to sort
8
- // @param {List} $order - order to respect
9
- //
10
- // @return {List}
11
-
12
- @function sort($list, $order: "!" "#" "$" "%" "&" "'" "(" ")" "*" "+" "," "-" "." "/" "[" "\\" "]" "^" "_" "{" "|" "}" "~" "0" "1" "2" "3" "4" "5" "6" "7" "8" "9" "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m" "n" "o" "p" "q" "r" "s" "t" "u" "v" "w" "x" "y" "z") {
13
- $less: ();
14
- $equal: ();
15
- $large: ();
16
- $length: length($list);
17
-
18
- @if $length > 1 {
19
- $seed: nth($list, ceil($length / 2));
20
- @each $item in $list {
21
- @if $item == $seed {
22
- $equal: append($equal, $item, list-separator($list));
23
- }
24
- @else if str-compare($item, $seed, $order) {
25
- $less: append($less, $item, list-separator($list));
26
- }
27
- @else if not str-compare($item, $seed, $order) {
28
- $large: append($large, $item, list-separator($list));
29
- }
30
- }
31
- @return join(join(sort($less, $order), $equal), sort($large, $order));
32
- }
33
- @return $list;
34
- }
35
-
36
- // @alias sort
37
-
38
- @function order($list) {
39
- @return sort($list);
40
- }
1
+ // Sorts values of $list using quick-sort algorithm
2
+ //
3
+ // @ignore Documentation: http://sassylists.com/documentation/#sort
4
+ //
5
+ // @requires str-compare
6
+ //
7
+ // @param {List} $list - list to sort
8
+ // @param {List} $order - order to respect
9
+ //
10
+ // @return {List}
11
+
12
+ @function sort($list, $order: "!" "#" "$" "%" "&" "'" "(" ")" "*" "+" "," "-" "." "/" "[" "\\" "]" "^" "_" "{" "|" "}" "~" "0" "1" "2" "3" "4" "5" "6" "7" "8" "9" "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m" "n" "o" "p" "q" "r" "s" "t" "u" "v" "w" "x" "y" "z") {
13
+ $less: ();
14
+ $equal: ();
15
+ $large: ();
16
+ $length: length($list);
17
+
18
+ @if $length > 1 {
19
+ $seed: nth($list, ceil($length / 2));
20
+ @each $item in $list {
21
+ @if $item == $seed {
22
+ $equal: append($equal, $item, list-separator($list));
23
+ }
24
+ @else if str-compare($item, $seed, $order) {
25
+ $less: append($less, $item, list-separator($list));
26
+ }
27
+ @else if not str-compare($item, $seed, $order) {
28
+ $large: append($large, $item, list-separator($list));
29
+ }
30
+ }
31
+ @return join(join(sort($less, $order), $equal), sort($large, $order));
32
+ }
33
+ @return $list;
34
+ }
35
+
36
+ // @alias sort
37
+
38
+ @function order($list) {
39
+ @return sort($list);
40
+ }
@@ -1,28 +1,28 @@
1
- // Sums up all numeric values in $list
2
- //
3
- // @ignore Documentation: http://sassylists.com/documentation/#sum
4
- //
5
- // @param {List} $list - list
6
- // @param {Boolean} $force (false) - enable/disable parseInt
7
- //
8
- // @return {Number}
9
-
10
- @function sum($list, $force: false) {
11
- $result: 0;
12
-
13
- @each $item in $list {
14
- @if type-of($item) == number {
15
-
16
- @if $force and not unitless($item) {
17
- $item: $item / ($item * 0 + 1);
18
- }
19
-
20
- @if unitless($item) {
21
- $result: $result + $item;
22
- }
23
-
24
- }
25
- }
26
-
27
- @return $result;
28
- }
1
+ // Sums up all numeric values in $list
2
+ //
3
+ // @ignore Documentation: http://sassylists.com/documentation/#sum
4
+ //
5
+ // @param {List} $list - list
6
+ // @param {Boolean} $force (false) - enable/disable parseInt
7
+ //
8
+ // @return {Number}
9
+
10
+ @function sum($list, $force: false) {
11
+ $result: 0;
12
+
13
+ @each $item in $list {
14
+ @if type-of($item) == number {
15
+
16
+ @if $force and not unitless($item) {
17
+ $item: $item / ($item * 0 + 1);
18
+ }
19
+
20
+ @if unitless($item) {
21
+ $result: $result + $item;
22
+ }
23
+
24
+ }
25
+ }
26
+
27
+ @return $result;
28
+ }
@@ -1,19 +1,19 @@
1
- // Returns the tail of $list: all items except the first (head)
2
- //
3
- // @ignore Documentation: http://sassylists.com/documentation/#tail
4
- //
5
- // @requires slice
6
- //
7
- // @param {List} $list - list to retrieve tail from
8
- //
9
- // @return {List | Bool}
10
-
11
- @function tail($list) {
12
- @return slice($list, 2);
13
- }
14
-
15
- // @alias tail
16
-
17
- @function rest($list) {
18
- @return tail($list);
1
+ // Returns the tail of $list: all items except the first (head)
2
+ //
3
+ // @ignore Documentation: http://sassylists.com/documentation/#tail
4
+ //
5
+ // @requires slice
6
+ //
7
+ // @param {List} $list - list to retrieve tail from
8
+ //
9
+ // @return {List | Bool}
10
+
11
+ @function tail($list) {
12
+ @return slice($list, 2);
13
+ }
14
+
15
+ // @alias tail
16
+
17
+ @function rest($list) {
18
+ @return tail($list);
19
19
  }
@@ -1,26 +1,26 @@
1
- // Joins all elements of $list with $glue
2
- //
3
- // @ignore Documentation: http://sassylists.com/documentation/#to-string
4
- //
5
- // @param {List} $list - list to cast
6
- // @param {String} $glue ('') - value to use as a join string
7
- //
8
- // @return {String}
9
-
10
- @function to-string($list, $glue: '') {
11
- $result: '';
12
- $length: length($list);
13
-
14
- @for $i from 1 through $length {
15
- $item: nth($list, $i);
16
- $result: $result + if(length($item) > 1, to-string($item, $glue), $item + $glue);
17
- }
18
-
19
- @return quote(str-slice($result, 1, str-length($glue) * -1 - 1));
20
- }
21
-
22
- // @alias to-string
23
-
24
- @function stringify($list, $glue: '') {
25
- @return to-string($list, $glue);
1
+ // Joins all elements of $list with $glue
2
+ //
3
+ // @ignore Documentation: http://sassylists.com/documentation/#to-string
4
+ //
5
+ // @param {List} $list - list to cast
6
+ // @param {String} $glue ('') - value to use as a join string
7
+ //
8
+ // @return {String}
9
+
10
+ @function to-string($list, $glue: '') {
11
+ $result: '';
12
+ $length: length($list);
13
+
14
+ @for $i from 1 through $length {
15
+ $item: nth($list, $i);
16
+ $result: $result + if(length($item) > 1, to-string($item, $glue), $item + $glue);
17
+ }
18
+
19
+ @return quote(str-slice($result, 1, str-length($glue) * -1 - 1));
20
+ }
21
+
22
+ // @alias to-string
23
+
24
+ @function stringify($list, $glue: '') {
25
+ @return to-string($list, $glue);
26
26
  }
@@ -1,21 +1,21 @@
1
- // Returns a list of values from $lists minus duplicates
2
- //
3
- // @ignore Documentation: http://sassylists.com/documentation/#union
4
- //
5
- // @requires flatten
6
- // @requires remove-duplicates
7
- //
8
- // @param {ArgList} $lists - lists to unify
9
- //
10
- // @return {List}
11
-
12
- @function union($lists...) {
13
- $result: remove-duplicates(flatten($lists));
14
- @return if(length($result) == 1, nth($result, 1), $result);
15
- }
16
-
17
- // @alias union
18
-
19
- @function merge($lists...) {
20
- @return union($lists...);
21
- }
1
+ // Returns a list of values from $lists minus duplicates
2
+ //
3
+ // @ignore Documentation: http://sassylists.com/documentation/#union
4
+ //
5
+ // @requires flatten
6
+ // @requires remove-duplicates
7
+ //
8
+ // @param {ArgList} $lists - lists to unify
9
+ //
10
+ // @return {List}
11
+
12
+ @function union($lists...) {
13
+ $result: remove-duplicates(flatten($lists));
14
+ @return if(length($result) == 1, nth($result, 1), $result);
15
+ }
16
+
17
+ // @alias union
18
+
19
+ @function merge($lists...) {
20
+ @return union($lists...);
21
+ }