SassyLists 2.0.0 → 2.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.
- 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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 08fe82b4659c4fbab4ee92f4b86801a4d794e103
|
4
|
+
data.tar.gz: 4ac22e42947a48ac6a4214931410c5ae6e4bbb5f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e64638ebc69f93b974b9b87e82d1a2f9177cf80b2a03a37754a922946fc05e104fefeec907e439ef3774c064737b2b6198f5359c1a35d34cc2beb498314e5de3
|
7
|
+
data.tar.gz: 24344e3fe3ce0809bed78b2c7e29c26ed6a71223b843e53ebbdd479a8bd2bcd4a22232202b1a0dc95d1dd190f3fe1dc3bf3deeffbec5f792809a5d4a606241b0
|
data/CHANGELOG.md
CHANGED
@@ -1,43 +1,44 @@
|
|
1
|
-
# Changelog
|
2
|
-
|
3
|
-
* `2.
|
4
|
-
|
5
|
-
* adding and
|
6
|
-
*
|
7
|
-
*
|
8
|
-
*
|
9
|
-
*
|
10
|
-
*
|
11
|
-
* `1.
|
12
|
-
|
13
|
-
*
|
14
|
-
*
|
15
|
-
*
|
16
|
-
*
|
17
|
-
*
|
18
|
-
*
|
19
|
-
*
|
20
|
-
* `0.4.
|
21
|
-
* `0.4.
|
22
|
-
* `0.4.
|
23
|
-
* `0.4.
|
24
|
-
* `0.4.
|
25
|
-
* `0.4.
|
26
|
-
* `0.4.
|
27
|
-
* `0.4.
|
28
|
-
* `0.4.
|
29
|
-
* `0.
|
30
|
-
* `0.3.
|
31
|
-
* `0.3.
|
32
|
-
* `0.3.
|
33
|
-
* `0.3.
|
34
|
-
* `0.3.
|
35
|
-
* `0.
|
36
|
-
* `0.2.
|
37
|
-
* `0.2.
|
38
|
-
* `0.2.
|
39
|
-
* `0.2.
|
40
|
-
* `0.
|
41
|
-
* `0.1.
|
42
|
-
* `0.1.
|
43
|
-
* `0.1.
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
* `2.1.0`: adding `sl-is-empty()`, `sl-to-list()` and `sl-comma-list()`
|
4
|
+
* `2.0.0`:
|
5
|
+
* adding `sl-to-map()`, `sl-every()` and `sl-some()`
|
6
|
+
* adding and improved tests
|
7
|
+
* prefixing all functions with `sl-`
|
8
|
+
* fixing an issue with `random-value()` sometimes failing
|
9
|
+
* changing all `false` returns into `null` in case of error
|
10
|
+
* removing Compass dependency
|
11
|
+
* `1.1.0`: adding `walk()` and `tail()`, updated backward loops and fixed broken tests
|
12
|
+
* `1.0.0`: moving code base to Sass 3.3 + adding a Grunt workflow
|
13
|
+
* adding `explode`
|
14
|
+
* making use of `list-separator()` and `set-nth()`
|
15
|
+
* updating `sort()` to make it able to sort strings
|
16
|
+
* removing all notion of recursion for sake of simplicity
|
17
|
+
* making `count-values()` return a map
|
18
|
+
* minor fixes and improvements
|
19
|
+
* improving overall performances
|
20
|
+
* `0.4.9`: removing `compact()` alias for `purge()` (ref [#23](https://github.com/Team-Sass/SassyLists/issues/23))
|
21
|
+
* `0.4.8`: adding `shuffle()`
|
22
|
+
* `0.4.7`: dramatically improving `sort()` performances and removing all its dependencies
|
23
|
+
* `0.4.6`: fixing an issue when passing an empty list to `chunk()` and improved code quality
|
24
|
+
* `0.4.5`: making `sort()` able to return in descending order
|
25
|
+
* `0.4.4`: fixing a typo in `purge()`
|
26
|
+
* `0.4.3`: improving `insert-nth()`, `prepend()`, `replace-nth()` and `replace()` to prevent from adding empty lists
|
27
|
+
* `0.4.2`: improving `insert-nth()` and cleaning some indentation issues
|
28
|
+
* `0.4.1`: improving `intersection()` perf
|
29
|
+
* `0.4.0`: adding `intersection()`
|
30
|
+
* `0.3.5`: improving `debug()`, `to-string()` and `chunk()`
|
31
|
+
* `0.3.4`: fixing a minor issue in `insert-nth()`, `replace-nth()` and `prepend()`
|
32
|
+
* `0.3.3`: removing dependence to `purge()` from all functions; fixed an issue with `sort()`; fixed an issue with error messages
|
33
|
+
* `0.3.2`: removing dependence to `purge()` from `replace()`
|
34
|
+
* `0.3.1`: adding aliases and cleaned `to-string()`
|
35
|
+
* `0.3.0`: adding `contains()`, `flatten()`, `union()`
|
36
|
+
* `0.2.4`: improving `debug()`
|
37
|
+
* `0.2.3`: fixing important issues with comments
|
38
|
+
* `0.2.2`: moving all comments to invisible
|
39
|
+
* `0.2.1`: fixing an issue with `random-value()`
|
40
|
+
* `0.2.0`: adding `random-value()`
|
41
|
+
* `0.1.4`: fixing an issue with `sort()`, `is-symmetrical()`
|
42
|
+
* `0.1.3`: fixing an issue with `sort()`
|
43
|
+
* `0.1.2`: improving `debug()`
|
44
|
+
* `0.1.1`: initial commit
|
data/README.md
CHANGED
@@ -1,73 +1,73 @@
|
|
1
|
-
# SassyLists [](http://badge.fury.io/rb/SassyLists)
|
2
|
-
|
3
|
-
Here is a
|
4
|
-
|
5
|
-
## How to use it
|
6
|
-
|
7
|
-
### Install with Gem
|
8
|
-
|
9
|
-
1. `gem install SassyLists`
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
* `sl-
|
20
|
-
* `sl-
|
21
|
-
* `sl-
|
22
|
-
* `sl-
|
23
|
-
* `sl-
|
24
|
-
* `sl-
|
25
|
-
* `sl-
|
26
|
-
* `sl-
|
27
|
-
* `sl-
|
28
|
-
* `sl-
|
29
|
-
* `sl-is-symmetrical()`: checks if list is symmetrical
|
30
|
-
* `sl-last()`: returns last item in list
|
31
|
-
* `sl-last-index()`: returns last index of value in list
|
32
|
-
* `sl-loop()`: shifts indexes in list
|
33
|
-
* `sl-prepend()`: prepends value to list
|
34
|
-
* `sl-purge()`: removes all `false` and `null` values from list
|
35
|
-
* `sl-random-value()`: returns random value from list
|
36
|
-
* `sl-remove()`: removes value in list
|
37
|
-
* `sl-remove-duplicates()`: removes duplicate values from list
|
38
|
-
* `sl-remove-nth()`: removes value at index
|
39
|
-
* `sl-replace()`: replaces value in list
|
40
|
-
* `sl-replace-nth()`: replaces value at index
|
41
|
-
* `sl-reverse()`: reverses list
|
42
|
-
* `sl-shuffle()`: shuffles list
|
43
|
-
* `sl-slice()`: slices list
|
44
|
-
* `sl-sort()`: sorts list
|
45
|
-
* `sl-some()`: returns whether some items from list pass test from given function
|
46
|
-
* `sl-sum()`: sums all unitless values in list
|
47
|
-
* `sl-tail()`: returns anything but the first element in list
|
48
|
-
* `sl-to-
|
49
|
-
* `sl-to-
|
50
|
-
* `sl-
|
51
|
-
* `sl-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
*
|
59
|
-
|
60
|
-
If you are looking for the last version of SassyLists running on Sass 3.2, install `0.4.9`.
|
61
|
-
|
62
|
-
Some functions depend on other functions. If you include functions individually, make sure to check for these dependencies in their respective docs.
|
63
|
-
|
64
|
-
## Also read
|
65
|
-
|
66
|
-
* [Official site](http://sassylists.com)
|
67
|
-
* [Advanced Sass list functions](http://hugogiraudel.com/2013/08/08/advanced-sass-list-functions/)
|
68
|
-
* [Advanced Sass list functions again](http://hugogiraudel.com/2013/10/09/advanced-sass-list-functions-again/)
|
69
|
-
* [How I made a Sass debug function](http://hugogiraudel.com/2013/10/21/sass-debug/)
|
70
|
-
|
71
|
-
## Credits
|
72
|
-
|
73
|
-
A
|
1
|
+
# SassyLists [](http://badge.fury.io/rb/SassyLists)
|
2
|
+
|
3
|
+
Here is a powerful toolbox providing you all the functions you need to manipulate your [Sass](http://sass-lang.com/) lists. See complete documentation [here](http://sassylists.com/).
|
4
|
+
|
5
|
+
## How to use it
|
6
|
+
|
7
|
+
### Install with Gem
|
8
|
+
|
9
|
+
1. `gem install SassyLists`
|
10
|
+
|
11
|
+
### Install with [Bower](http://bower.io/ "BOWER: A package manager for the web")
|
12
|
+
1. `bower install SassyLists --save-dev`
|
13
|
+
2. Import the partial in your Sass files
|
14
|
+
|
15
|
+
## What's in there?
|
16
|
+
|
17
|
+
* `sl-chunk()`: returns whether list contains $value
|
18
|
+
* `sl-comma-list()`: initializes an empty comma-separated list
|
19
|
+
* `sl-contain()`: returns whether the list contains the value
|
20
|
+
* `sl-count-values()`: counts the number of occurrences of each value of list
|
21
|
+
* `sl-debug()`: returns list as a string
|
22
|
+
* `sl-every()`: returns whether all items from list pass test from given function
|
23
|
+
* `sl-explode()`: explodes a string into a list using a string as a delimiter
|
24
|
+
* `sl-first()`: returns first item in list
|
25
|
+
* `sl-flatten()`: turns multidimensional list into a one-level list
|
26
|
+
* `sl-insert-nth()`: inserts value at index
|
27
|
+
* `sl-intersection()`: returns a list of shared values across all given lists
|
28
|
+
* `sl-is-empty()`: checks if list is empty
|
29
|
+
* `sl-is-symmetrical()`: checks if list is symmetrical
|
30
|
+
* `sl-last()`: returns last item in list
|
31
|
+
* `sl-last-index()`: returns last index of value in list
|
32
|
+
* `sl-loop()`: shifts indexes in list
|
33
|
+
* `sl-prepend()`: prepends value to list
|
34
|
+
* `sl-purge()`: removes all `false` and `null` values from list
|
35
|
+
* `sl-random-value()`: returns random value from list
|
36
|
+
* `sl-remove()`: removes value in list
|
37
|
+
* `sl-remove-duplicates()`: removes duplicate values from list
|
38
|
+
* `sl-remove-nth()`: removes value at index
|
39
|
+
* `sl-replace()`: replaces value in list
|
40
|
+
* `sl-replace-nth()`: replaces value at index
|
41
|
+
* `sl-reverse()`: reverses list
|
42
|
+
* `sl-shuffle()`: shuffles list
|
43
|
+
* `sl-slice()`: slices list
|
44
|
+
* `sl-sort()`: sorts list
|
45
|
+
* `sl-some()`: returns whether some items from list pass test from given function
|
46
|
+
* `sl-sum()`: sums all unitless values in list
|
47
|
+
* `sl-tail()`: returns anything but the first element in list
|
48
|
+
* `sl-to-list()`: casts value as list
|
49
|
+
* `sl-to-map()`: casts list as map using indexes as keys
|
50
|
+
* `sl-to-string()`: casts list as string (JS `.join()`)
|
51
|
+
* `sl-union()`: returns a list of values from given lists minus duplicates
|
52
|
+
* `sl-walk()`: applies a function to every item of list
|
53
|
+
|
54
|
+
If you feel like an explorer, you can have a look at the code [here](https://github.com/Team-Sass/SassyLists/tree/master/stylesheets).
|
55
|
+
|
56
|
+
## Requirements
|
57
|
+
|
58
|
+
* Sass ~> 3.3
|
59
|
+
|
60
|
+
If you are looking for the last version of SassyLists running on Sass 3.2, install `0.4.9`.
|
61
|
+
|
62
|
+
Some functions depend on other functions. If you include functions individually, make sure to check for these dependencies in their respective docs.
|
63
|
+
|
64
|
+
## Also read
|
65
|
+
|
66
|
+
* [Official site](http://sassylists.com)
|
67
|
+
* [Advanced Sass list functions](http://hugogiraudel.com/2013/08/08/advanced-sass-list-functions/)
|
68
|
+
* [Advanced Sass list functions again](http://hugogiraudel.com/2013/10/09/advanced-sass-list-functions-again/)
|
69
|
+
* [How I made a Sass debug function](http://hugogiraudel.com/2013/10/21/sass-debug/)
|
70
|
+
|
71
|
+
## Credits
|
72
|
+
|
73
|
+
A lot of thanks to all contributors and to [Team-Sass](https://github.com/Team-Sass) for their support.
|
data/lib/SassyLists.rb
CHANGED
@@ -1,21 +1,21 @@
|
|
1
|
-
extension_path = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
2
|
-
stylesheets_path = File.join(extension_path, 'stylesheets')
|
3
|
-
|
4
|
-
if (defined? Compass)
|
5
|
-
Compass::Frameworks.register('SassyLists', :path => extension_path)
|
6
|
-
else
|
7
|
-
# compass not found, register on the Sass path via the environment.
|
8
|
-
if ENV.has_key?("SASS_PATH")
|
9
|
-
ENV["SASS_PATH"] = ENV["SASS_PATH"] + File::PATH_SEPARATOR + stylesheets_path
|
10
|
-
else
|
11
|
-
ENV["SASS_PATH"] = stylesheets_path
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
# Version is a number. If a version contains alphas, it will be created as a prerelease version
|
16
|
-
# Date is in the form of YYYY-MM-DD
|
17
|
-
module SassyLists
|
18
|
-
VERSION = "2.
|
19
|
-
DATE = "2014-
|
20
|
-
end
|
21
|
-
|
1
|
+
extension_path = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
2
|
+
stylesheets_path = File.join(extension_path, 'stylesheets')
|
3
|
+
|
4
|
+
if (defined? Compass)
|
5
|
+
Compass::Frameworks.register('SassyLists', :path => extension_path)
|
6
|
+
else
|
7
|
+
# compass not found, register on the Sass path via the environment.
|
8
|
+
if ENV.has_key?("SASS_PATH")
|
9
|
+
ENV["SASS_PATH"] = ENV["SASS_PATH"] + File::PATH_SEPARATOR + stylesheets_path
|
10
|
+
else
|
11
|
+
ENV["SASS_PATH"] = stylesheets_path
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
# Version is a number. If a version contains alphas, it will be created as a prerelease version
|
16
|
+
# Date is in the form of YYYY-MM-DD
|
17
|
+
module SassyLists
|
18
|
+
VERSION = "2.1.0"
|
19
|
+
DATE = "2014-07-01"
|
20
|
+
end
|
21
|
+
|
@@ -1,42 +1,42 @@
|
|
1
|
-
// Chunks `$list` into `$size` large lists.
|
2
|
-
//
|
3
|
-
// @ignore Documentation: http://sassylists.com/documentation
|
4
|
-
//
|
5
|
-
// @param {List} $list - list to chunk
|
6
|
-
// @param {Number} $size - length of lists
|
7
|
-
//
|
8
|
-
// @throws $size is not a number for `sl-chunk`.
|
9
|
-
//
|
10
|
-
// @return {List | Null}
|
11
|
-
|
12
|
-
@function sl-chunk($list, $size) {
|
13
|
-
@if type-of($size) != "number" {
|
14
|
-
@warn "#{$size} is not a number for `sl-chunk`.";
|
15
|
-
@return null;
|
16
|
-
}
|
17
|
-
|
18
|
-
@if $size >= length($list) {
|
19
|
-
@return $list;
|
20
|
-
}
|
21
|
-
|
22
|
-
$index: 1;
|
23
|
-
$result: ();
|
24
|
-
$length: length($list);
|
25
|
-
$end: ceil($length / $size);
|
26
|
-
|
27
|
-
@for $i from 1 through $end {
|
28
|
-
$tmp: ();
|
29
|
-
|
30
|
-
@for $j from 1 through $size {
|
31
|
-
@if $index <= $length {
|
32
|
-
$is-orphan: $length % $size == 1 and $j == 1;
|
33
|
-
$tmp: if($is-orphan, nth($list, $index), append($tmp, nth($list, $index)));
|
34
|
-
}
|
35
|
-
$index: $index + 1;
|
36
|
-
}
|
37
|
-
|
38
|
-
$result: append($result, $tmp);
|
39
|
-
}
|
40
|
-
|
41
|
-
@return $result;
|
1
|
+
// Chunks `$list` into `$size` large lists.
|
2
|
+
//
|
3
|
+
// @ignore Documentation: http://sassylists.com/documentation.html#sl-chunk
|
4
|
+
//
|
5
|
+
// @param {List} $list - list to chunk
|
6
|
+
// @param {Number} $size - length of lists
|
7
|
+
//
|
8
|
+
// @throws $size is not a number for `sl-chunk`.
|
9
|
+
//
|
10
|
+
// @return {List | Null}
|
11
|
+
|
12
|
+
@function sl-chunk($list, $size) {
|
13
|
+
@if type-of($size) != "number" {
|
14
|
+
@warn "#{$size} is not a number for `sl-chunk`.";
|
15
|
+
@return null;
|
16
|
+
}
|
17
|
+
|
18
|
+
@if $size >= length($list) {
|
19
|
+
@return $list;
|
20
|
+
}
|
21
|
+
|
22
|
+
$index: 1;
|
23
|
+
$result: ();
|
24
|
+
$length: length($list);
|
25
|
+
$end: ceil($length / $size);
|
26
|
+
|
27
|
+
@for $i from 1 through $end {
|
28
|
+
$tmp: ();
|
29
|
+
|
30
|
+
@for $j from 1 through $size {
|
31
|
+
@if $index <= $length {
|
32
|
+
$is-orphan: $length % $size == 1 and $j == 1;
|
33
|
+
$tmp: if($is-orphan, nth($list, $index), append($tmp, nth($list, $index)));
|
34
|
+
}
|
35
|
+
$index: $index + 1;
|
36
|
+
}
|
37
|
+
|
38
|
+
$result: append($result, $tmp);
|
39
|
+
}
|
40
|
+
|
41
|
+
@return $result;
|
42
42
|
}
|
@@ -1,18 +1,18 @@
|
|
1
|
-
// Returns whether `$list` contains `$value`.
|
2
|
-
//
|
3
|
-
// @ignore Documentation: http://sassylists.com/documentation
|
4
|
-
//
|
5
|
-
// @param {List} $list - list to check
|
6
|
-
// @param {*} $value - value to look for
|
7
|
-
//
|
8
|
-
// @return {Bool}
|
9
|
-
|
10
|
-
@function sl-contain($list, $value) {
|
11
|
-
@return not not index($list, $value);
|
12
|
-
}
|
13
|
-
|
14
|
-
// @alias sl-contain
|
15
|
-
|
16
|
-
@function sl-include($list, $value) {
|
17
|
-
@return sl-contain($list, $value);
|
1
|
+
// Returns whether `$list` contains `$value`.
|
2
|
+
//
|
3
|
+
// @ignore Documentation: http://sassylists.com/documentation.html#sl-contain
|
4
|
+
//
|
5
|
+
// @param {List} $list - list to check
|
6
|
+
// @param {*} $value - value to look for
|
7
|
+
//
|
8
|
+
// @return {Bool}
|
9
|
+
|
10
|
+
@function sl-contain($list, $value) {
|
11
|
+
@return not not index($list, $value);
|
12
|
+
}
|
13
|
+
|
14
|
+
// @alias sl-contain
|
15
|
+
|
16
|
+
@function sl-include($list, $value) {
|
17
|
+
@return sl-contain($list, $value);
|
18
18
|
}
|
@@ -1,19 +1,19 @@
|
|
1
|
-
// Counts the number of occurrences of each value of `$list`.
|
2
|
-
//
|
3
|
-
// @ignore Documentation: http://sassylists.com/documentation
|
4
|
-
//
|
5
|
-
// @param {List} $list - list to count values from
|
6
|
-
//
|
7
|
-
// @return {Map} Values mapped to their count
|
8
|
-
|
9
|
-
@function sl-count-values($list) {
|
10
|
-
$map: ();
|
11
|
-
|
12
|
-
@each $item in $list {
|
13
|
-
$index: map-get($map, $item);
|
14
|
-
$value: if($index, $index + 1, 1);
|
15
|
-
$map: map-merge($map, ($item: $value));
|
16
|
-
}
|
17
|
-
|
18
|
-
@return $map;
|
1
|
+
// Counts the number of occurrences of each value of `$list`.
|
2
|
+
//
|
3
|
+
// @ignore Documentation: http://sassylists.com/documentation.html#sl-count-values
|
4
|
+
//
|
5
|
+
// @param {List} $list - list to count values from
|
6
|
+
//
|
7
|
+
// @return {Map} Values mapped to their count
|
8
|
+
|
9
|
+
@function sl-count-values($list) {
|
10
|
+
$map: ();
|
11
|
+
|
12
|
+
@each $item in $list {
|
13
|
+
$index: map-get($map, $item);
|
14
|
+
$value: if($index, $index + 1, 1);
|
15
|
+
$map: map-merge($map, ($item: $value));
|
16
|
+
}
|
17
|
+
|
18
|
+
@return $map;
|
19
19
|
}
|