SassyLists 1.0.0 → 1.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.
Files changed (37) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +36 -35
  3. data/lib/SassyLists.rb +13 -15
  4. data/stylesheets/SassyLists/_chunk.scss +41 -41
  5. data/stylesheets/SassyLists/_contain.scss +17 -18
  6. data/stylesheets/SassyLists/_count-values.scss +18 -18
  7. data/stylesheets/SassyLists/_debug.scss +96 -94
  8. data/stylesheets/SassyLists/_explode.scss +49 -48
  9. data/stylesheets/SassyLists/_first.scss +23 -24
  10. data/stylesheets/SassyLists/_flatten.scss +35 -36
  11. data/stylesheets/SassyLists/_insert-nth.scss +46 -45
  12. data/stylesheets/SassyLists/_intersection.scss +28 -26
  13. data/stylesheets/SassyLists/_is-symmetrical.scss +18 -19
  14. data/stylesheets/SassyLists/_last-index.scss +20 -21
  15. data/stylesheets/SassyLists/_last.scss +17 -24
  16. data/stylesheets/SassyLists/_loop.scss +35 -36
  17. data/stylesheets/SassyLists/_prepend.scss +20 -20
  18. data/stylesheets/SassyLists/_purge.scss +27 -28
  19. data/stylesheets/SassyLists/_random-value.scss +29 -31
  20. data/stylesheets/SassyLists/_remove-duplicates.scss +24 -26
  21. data/stylesheets/SassyLists/_remove-nth.scss +19 -20
  22. data/stylesheets/SassyLists/_remove.scss +20 -21
  23. data/stylesheets/SassyLists/_replace-nth.scss +24 -25
  24. data/stylesheets/SassyLists/_replace.scss +29 -27
  25. data/stylesheets/SassyLists/_reverse.scss +29 -30
  26. data/stylesheets/SassyLists/_shuffle.scss +29 -31
  27. data/stylesheets/SassyLists/_slice.scss +48 -48
  28. data/stylesheets/SassyLists/_sort.scss +40 -41
  29. data/stylesheets/SassyLists/_sum.scss +28 -28
  30. data/stylesheets/SassyLists/_tail.scss +19 -0
  31. data/stylesheets/SassyLists/_to-string.scss +25 -26
  32. data/stylesheets/SassyLists/_union.scss +21 -24
  33. data/stylesheets/SassyLists/_walk.scss +24 -0
  34. data/stylesheets/SassyLists/helpers/_str-compare.scss +24 -26
  35. data/stylesheets/SassyLists/helpers/_true.scss +10 -14
  36. data/stylesheets/_SassyLists.scss +38 -38
  37. metadata +16 -20
@@ -1,37 +1,36 @@
1
- // Turns multidimensional $list into a one-level list
2
- // -------------------------------------------------------------------------------
3
- // @documentation http://sassylists.com/documentation.html#flatten
4
- // -------------------------------------------------------------------------------
5
- // @alias `unfold()`
6
- // -------------------------------------------------------------------------------
7
- // @param $list [List] : list
8
- // -------------------------------------------------------------------------------
9
- // @return [List]
10
-
11
- @function flatten($list) {
12
- $result: ();
13
-
14
- @if length($list) == 1 {
15
- @return $list;
16
- }
17
-
18
- @each $item in $list {
19
- @if length($item) > 1 {
20
- $flatten: flatten($item);
21
- @each $i in $flatten {
22
- $result: append($result, $i, list-separator($list));
23
- }
24
- }
25
-
26
- @else {
27
- $result: append($result, $item, list-separator($list));
28
- }
29
- }
30
-
31
- @return $result;
32
- }
33
-
34
- // Alias
35
- @function unfold($list) {
36
- @return 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 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: 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 flatten
33
+
34
+ @function unfold($list) {
35
+ @return flatten($list);
37
36
  }
@@ -1,45 +1,46 @@
1
- // Adds $value at $index in $list
2
- // -------------------------------------------------------------------------------
3
- // @documentation http://sassylists.com/documentation/#insert-nth
4
- // -------------------------------------------------------------------------------
5
- // @param $list [List] : list
6
- // @param $index [Number] : index to add
7
- // @param $value [Literal] : value to add
8
- // -------------------------------------------------------------------------------
9
- // @raise [Error] if $index isn't an integer
10
- // @raise [Error] if $index is strictly lesser than 1
11
- // @raise [Error] if $index is strictly greater than length of $list
12
- // -------------------------------------------------------------------------------
13
- // @return [List] | false
14
-
15
- @function insert-nth($list, $index, $value) {
16
- $length: length($list);
17
-
18
- @if type-of($index) != number {
19
- @warn "List index #{$index} is not a number for `insert-nth`.";
20
- @return false;
21
- }
22
-
23
- @if $index < 1 {
24
- @warn "List index #{$index} must be a non-zero integer for `insert-nth`";
25
- @return false;
26
- }
27
-
28
- @if $index > $length {
29
- @return append($list, $value, list-separator($list));
30
- }
31
-
32
- $result: ();
33
-
34
- @for $i from 1 through $length {
35
- @if $i == $index {
36
- @if is-true($value) {
37
- $result: append($result, $value, list-separator($list));
38
- }
39
- }
40
-
41
- $result: append($result, nth($list, $i), list-separator($list));
42
- }
43
-
44
- @return $result;
45
- }
1
+ // Adds $value at $index in $list
2
+ //
3
+ // @ignore Documentation: http://sassylists.com/documentation/#insert-nth
4
+ //
5
+ // @requires 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 `insert-nth`.
12
+ // @throws List index $index must be a non-zero integer for `insert-nth`.
13
+ //
14
+ // @return {List | Bool}
15
+
16
+ @function insert-nth($list, $index, $value) {
17
+ $length: length($list);
18
+
19
+ @if type-of($index) != number {
20
+ @warn "List index #{$index} is not a number for `insert-nth`.";
21
+ @return false;
22
+ }
23
+
24
+ @if $index < 1 {
25
+ @warn "List index #{$index} must be a non-zero integer for `insert-nth`.";
26
+ @return false;
27
+ }
28
+
29
+ @if $index > $length {
30
+ @return append($list, $value, list-separator($list));
31
+ }
32
+
33
+ $result: ();
34
+
35
+ @for $i from 1 through $length {
36
+ @if $i == $index {
37
+ @if is-true($value) {
38
+ $result: append($result, $value, list-separator($list));
39
+ }
40
+ }
41
+
42
+ $result: append($result, nth($list, $i), list-separator($list));
43
+ }
44
+
45
+ @return $result;
46
+ }
@@ -1,27 +1,29 @@
1
- // Returns a list of shared value from $list and $lists minus duplicates
2
- // -------------------------------------------------------------------------------
3
- // @documentation http://sassylists.com/documentation/#intersection
4
- // -------------------------------------------------------------------------------
5
- // @param $list [List] : first list
6
- // @param $lists [ArgList] : other lists
7
- // -------------------------------------------------------------------------------
8
- // @return [List]
9
-
10
- @function intersection($list, $lists...) {
11
- $result: $list;
12
-
13
- @each $list in $lists {
14
- $temp: ();
15
-
16
- @each $item in $result {
17
- @if not not index($list, $item) {
18
- $temp: append($temp, $item, list-separator($list));
19
- }
20
- }
21
-
22
- $result: $temp;
23
- }
24
-
25
- $result: remove-duplicates($result);
26
- @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/#intersection
4
+ //
5
+ // @requires remove-duplicates
6
+ //
7
+ // @param {List} $list - first list
8
+ // @param {ArgList} $lists - other lists
9
+ //
10
+ // @return {List}
11
+
12
+ @function intersection($list, $lists...) {
13
+ $result: $list;
14
+
15
+ @each $list in $lists {
16
+ $temp: ();
17
+
18
+ @each $item in $result {
19
+ @if not not index($list, $item) {
20
+ $temp: append($temp, $item, list-separator($list));
21
+ }
22
+ }
23
+
24
+ $result: $temp;
25
+ }
26
+
27
+ $result: remove-duplicates($result);
28
+ @return if(length($result) == 1, nth($result, 1), $result);
27
29
  }
@@ -1,20 +1,19 @@
1
- // Checks whether $list is symmetrical (one-level deep)
2
- // -------------------------------------------------------------------------------
3
- // @documentation http://sassylists.com/documentation/#is-symmetrical
4
- // -------------------------------------------------------------------------------
5
- // @alias `unfold()`
6
- // -------------------------------------------------------------------------------
7
- // @dependence `reverse()`
8
- // -------------------------------------------------------------------------------
9
- // @param $list [List] : list
10
- // -------------------------------------------------------------------------------
11
- // @return [Boolean]
12
-
13
- @function is-symmetrical($list) {
14
- @return $list == reverse($list);
15
- }
16
-
17
- // Alias
18
- @function is-mirror($list) {
19
- @return is-symmetrical($list);
1
+ // Checks whether $list is symmetrical (one-level deep)
2
+ //
3
+ // @ignore Documentation: http://sassylists.com/documentation/#is-symmetrical
4
+ //
5
+ // @requires reverse
6
+ //
7
+ // @param {List} $list - list to check
8
+ //
9
+ // @return {Bool}
10
+
11
+ @function is-symmetrical($list) {
12
+ @return $list == reverse($list);
13
+ }
14
+
15
+ // @alias is-symmetrical
16
+
17
+ @function is-mirror($list) {
18
+ @return is-symmetrical($list);
20
19
  }
@@ -1,21 +1,20 @@
1
- // Returns last index of $value in $list
2
- // -------------------------------------------------------------------------------
3
- // @documentation http://sassylists.com/documentation/#last-index
4
- // -------------------------------------------------------------------------------
5
- // @param $list [List] : list
6
- // @param $value [Literal] : value to be searched for
7
- // -------------------------------------------------------------------------------
8
- // @return [Number] | null
9
-
10
- @function last-index($list, $value) {
11
- $length: length($list);
12
-
13
- @for $i from $length * -1 through -1 {
14
- $i: abs($i);
15
- @if nth($list, $i) == $value {
16
- @return $i;
17
- }
18
- }
19
-
20
- @return null;
21
- }
1
+ // Returns last index of $value in $list
2
+ //
3
+ // @ignore Documentation: http://sassylists.com/documentation/#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 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,25 +1,18 @@
1
- // Returns last element of $list
2
- // -------------------------------------------------------------------------------
3
- // @documentation http://sassylists.com/documentation/#last
4
- // -------------------------------------------------------------------------------
5
- // @alias `tail()`
6
- // -------------------------------------------------------------------------------
7
- // @param $list [List] : list
8
- // -------------------------------------------------------------------------------
9
- // @raise [Error] if list is empty
10
- // -------------------------------------------------------------------------------
11
- // @return [Literal] | false
12
-
13
- @function last($list) {
14
- @if length($list) == 0 {
15
- @warn "Cannot find last item of empty list.";
16
- @return false;
17
- }
18
-
19
- @return nth($list, length($list));
20
- }
21
-
22
- // Alias
23
- @function tail($list) {
24
- @return last($list);
1
+ // Returns last element of $list
2
+ //
3
+ // @ignore Documentation: http://sassylists.com/documentation/#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 last($list) {
12
+ @if length($list) == 0 {
13
+ @warn "Cannot find last item of empty list.";
14
+ @return false;
15
+ }
16
+
17
+ @return nth($list, -1);
25
18
  }
@@ -1,37 +1,36 @@
1
- // Shift indexes from $list of $value
2
- // -------------------------------------------------------------------------------
3
- // @documentation http://sassylists.com/documentation/#loop
4
- // -------------------------------------------------------------------------------
5
- // @alias `shift-indexes()`
6
- // -------------------------------------------------------------------------------
7
- // @param $list [List] : list
8
- // @param $value [Number] : number of position between old and new indexes
9
- // -------------------------------------------------------------------------------
10
- // @raise [Error] if $value isn't an integer
11
- // -------------------------------------------------------------------------------
12
- // @return [List] | false
13
-
14
- @function loop($list, $value: 1) {
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);
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
35
- @function shift-indexes($list, $value: 1) {
36
- @return loop($list, $value);
1
+ // Shift indexes from $list of $value
2
+ //
3
+ // @ignore Documentation: http://sassylists.com/documentation/#loop
4
+ //
5
+ // @param {List} $list - list to update
6
+ // @param {Number} $value (1) - number of position between old and new indexes
7
+ //
8
+ // @throws $value is not a number for `loop`.
9
+ //
10
+ // @return {List | Bool}
11
+
12
+ @function loop($list, $value: 1) {
13
+ @if type-of($value) != "number" {
14
+ @warn "#{$value} is not a number for `loop`.";
15
+ @return false;
16
+ }
17
+
18
+ @if length($list) < 2 {
19
+ @return $list;
20
+ }
21
+
22
+ $result: ();
23
+ $length: length($list);
24
+
25
+ @for $i from 0 to $length {
26
+ $result: append($result, nth($list, ($i - $value) % $length + 1), list-separator($list));
27
+ }
28
+
29
+ @return $result;
30
+ }
31
+
32
+ // @alias shift-indexes
33
+
34
+ @function shift-indexes($list, $value: 1) {
35
+ @return loop($list, $value);
37
36
  }
@@ -1,20 +1,20 @@
1
- // Adds $value as first index of $list
2
- // -------------------------------------------------------------------------------
3
- // @documentation http://sassylists.com/documentation/#prepend
4
- // -------------------------------------------------------------------------------
5
- // @dependence `is-true()`
6
- // -------------------------------------------------------------------------------
7
- // @param $list [List] : list
8
- // @param $value [Literal] : value to prepend to the list
9
- // -------------------------------------------------------------------------------
10
- // @return [List]
11
-
12
- @function prepend($list, $value) {
13
- @if is-true($value) {
14
- @return join($value, $list, list-separator($list));
15
- }
16
-
17
- @else {
18
- @return $list;
19
- }
20
- }
1
+ // Adds $value as first index of $list
2
+ //
3
+ // @ignore Documentation: http://sassylists.com/documentation/#prepend
4
+ //
5
+ // @requires 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 prepend($list, $value) {
13
+ @if is-true($value) {
14
+ @return join($value, $list, list-separator($list));
15
+ }
16
+
17
+ @else {
18
+ @return $list;
19
+ }
20
+ }
@@ -1,28 +1,27 @@
1
- // Removes all false and null values from $list
2
- // -------------------------------------------------------------------------------
3
- // @documentation http://sassylists.com/documentation.html#purge
4
- // -------------------------------------------------------------------------------
5
- // @alias `clean()`
6
- // -------------------------------------------------------------------------------
7
- // @dependence `is-true()`
8
- // -------------------------------------------------------------------------------
9
- // @param $list [List] : list
10
- // -------------------------------------------------------------------------------
11
- // @return [List]
12
-
13
- @function purge($list) {
14
- $result: ();
15
-
16
- @each $item in $list {
17
- @if is-true($item) {
18
- $result: append($result, $item, list-separator($list));
19
- }
20
- }
21
-
22
- @return $result;
23
- }
24
-
25
- // Alias
26
- @function clean($list) {
27
- @return purge($list);
28
- }
1
+ // Removes all false and null values from $list
2
+ //
3
+ // @ignore Documentation: http://sassylists.com/documentation.html#purge
4
+ //
5
+ // @requires is-true
6
+ //
7
+ // @param {List} $list - list to purge
8
+ //
9
+ // @return {List}
10
+
11
+ @function purge($list) {
12
+ $result: ();
13
+
14
+ @each $item in $list {
15
+ @if is-true($item) {
16
+ $result: append($result, $item, list-separator($list));
17
+ }
18
+ }
19
+
20
+ @return $result;
21
+ }
22
+
23
+ // @alias purge
24
+
25
+ @function clean($list) {
26
+ @return purge($list);
27
+ }
@@ -1,32 +1,30 @@
1
- // Returns a random value of $list
2
- // -------------------------------------------------------------------------------
3
- // @documentation http://sassylists.com/documentation.html#random-value
4
- // -------------------------------------------------------------------------------
5
- // @alias `roll()`
6
- // @alias `luck()`
7
- // -------------------------------------------------------------------------------
8
- // @dependence `random()` (Ruby)
9
- // -------------------------------------------------------------------------------
10
- // @param $list [List] : List
11
- // -------------------------------------------------------------------------------
12
- // @raise [Error] if $list is empty
13
- // -------------------------------------------------------------------------------
14
- // @return [Literal] | false
15
-
16
- @function random-value($list) {
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);
23
- }
24
-
25
- // Aliases
26
- @function roll($list) {
27
- @return random-value($list);
28
- }
29
-
30
- @function luck($list) {
31
- @return 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 random-value($list) {
12
+ @if length($list) == 0 {
13
+ @warn "Cannot find a random value in an empty list.";
14
+ @return false;
15
+ }
16
+
17
+ @return nth($list, random(length($list)) + 1);
18
+ }
19
+
20
+ // @alias random-value
21
+
22
+ @function roll($list) {
23
+ @return random-value($list);
24
+ }
25
+
26
+ // @alias random-value
27
+
28
+ @function luck($list) {
29
+ @return random-value($list);
32
30
  }
@@ -1,27 +1,25 @@
1
- // Removes duplicate values from $list
2
- // -------------------------------------------------------------------------------
3
- // @documentation http://sassylists.com/documentation/#remove-duplicates
4
- // -------------------------------------------------------------------------------
5
- // @alias `unique()`
6
- // -------------------------------------------------------------------------------
7
- // @param $list [List] : list
8
- // @param $recursive [Boolean] : enable / disable recursivity
9
- // -------------------------------------------------------------------------------
10
- // @return [List]
11
-
12
- @function remove-duplicates($list) {
13
- $result: ();
14
-
15
- @each $item in $list {
16
- @if not index($result, $item) {
17
- $result: append($result, $item, list-separator($list));
18
- }
19
- }
20
-
21
- @return $result;
22
- }
23
-
24
- // Alias
25
- @function unique($list, $recursive: false) {
26
- @return remove-duplicates($list, $recursive);
1
+ // Removes duplicate values from $list
2
+ //
3
+ // @ignore Documentation: http://sassylists.com/documentation/#remove-duplicates
4
+ //
5
+ // @param {List} $list - list to remove duplicates from
6
+ //
7
+ // @return {List}
8
+
9
+ @function 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 remove-duplicates
22
+
23
+ @function unique($list, $recursive: false) {
24
+ @return remove-duplicates($list, $recursive);
27
25
  }