SassyLists 1.1.1 → 2.0.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 +8 -1
- data/README.md +73 -0
- data/lib/SassyLists.rb +15 -8
- data/stylesheets/SassyLists/_chunk.scss +6 -6
- data/stylesheets/SassyLists/_contain.scss +5 -5
- data/stylesheets/SassyLists/_count-values.scss +2 -2
- data/stylesheets/SassyLists/_debug.scss +6 -6
- data/stylesheets/SassyLists/_every.scss +17 -0
- data/stylesheets/SassyLists/_explode.scss +12 -9
- data/stylesheets/SassyLists/_first.scss +6 -6
- data/stylesheets/SassyLists/_flatten.scss +6 -6
- data/stylesheets/SassyLists/_insert-nth.scss +13 -11
- data/stylesheets/SassyLists/_intersection.scss +6 -4
- data/stylesheets/SassyLists/_is-symmetrical.scss +9 -7
- data/stylesheets/SassyLists/_last-index.scss +4 -4
- data/stylesheets/SassyLists/_last.scss +3 -3
- data/stylesheets/SassyLists/_loop.scss +10 -8
- data/stylesheets/SassyLists/_prepend.scss +8 -6
- data/stylesheets/SassyLists/_purge.scss +9 -7
- data/stylesheets/SassyLists/_random-value.scss +10 -10
- data/stylesheets/SassyLists/_remove-duplicates.scss +5 -5
- data/stylesheets/SassyLists/_remove-nth.scss +10 -8
- data/stylesheets/SassyLists/_remove.scss +9 -7
- data/stylesheets/SassyLists/_replace-nth.scss +11 -9
- data/stylesheets/SassyLists/_replace.scss +7 -4
- data/stylesheets/SassyLists/_reverse.scss +6 -6
- data/stylesheets/SassyLists/_shuffle.scss +6 -5
- data/stylesheets/SassyLists/_slice.scss +23 -18
- data/stylesheets/SassyLists/_some.scss +17 -0
- data/stylesheets/SassyLists/_sort.scss +11 -9
- data/stylesheets/SassyLists/_sum.scss +2 -2
- data/stylesheets/SassyLists/_tail.scss +10 -8
- data/stylesheets/SassyLists/_to-map.scss +51 -0
- data/stylesheets/SassyLists/_to-string.scss +6 -6
- data/stylesheets/SassyLists/_union.scss +11 -8
- data/stylesheets/SassyLists/_walk.scss +4 -4
- data/stylesheets/SassyLists/helpers/_missing-dependencies.scss +23 -0
- data/stylesheets/SassyLists/helpers/_str-compare.scss +5 -2
- data/stylesheets/SassyLists/helpers/_true.scss +2 -2
- data/stylesheets/_SassyLists.scss +5 -1
- metadata +13 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a296e7541de900b0667d9adc5982680695baf408
|
4
|
+
data.tar.gz: cfe6a3f3016520920a2109556c0315bef0fa0f59
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 130887373e83c97df31b98774bc78f8becd565fedbe99b2cb29278938ea0b1b7b95bbbda4038aded18c2881bc3c9ceea66d1ec6431e1c9d8580475867b4193dd
|
7
|
+
data.tar.gz: c832a9b26caee25bae587bf9519fd3b0d1a49d8256ec4c88837f24e7dcee0e1ecc40f210449ccb90628e4a1e364467cbe78ef6c2973c4e19c7554f48f45397cb
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,13 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
-
* `
|
3
|
+
* `2.0.0`:
|
4
|
+
* adding `to-map()`, `every()` and `some()`
|
5
|
+
* adding and improved tests
|
6
|
+
* prefixing all functions with `sl-`
|
7
|
+
* fixing an issue with `random-value()` sometimes failing
|
8
|
+
* changing all `false` returns into `null` in case of error
|
9
|
+
* removing Compass dependency
|
10
|
+
* `1.1.0`: adding `walk()` and `tail()`, updated backward loops and fixed broken tests
|
4
11
|
* `1.0.0`: moving code base to Sass 3.3 + adding a Grunt workflow
|
5
12
|
* adding `explode`
|
6
13
|
* making use of `list-separator()` and `set-nth()`
|
data/README.md
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
# SassyLists [](http://badge.fury.io/rb/SassyLists)
|
2
|
+
|
3
|
+
Here is a [Compass Extension](http://compass-style.org/) providing you all 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
|
+
2. Add `require 'SassyLists'` to your `config.rb`
|
11
|
+
3. Import it in your stylesheets with `@import 'SassyLists'`
|
12
|
+
|
13
|
+
### Install with [Bower](http://bower.io/ "BOWER: A package manager for the web")
|
14
|
+
1. `bower install SassyLists --save-dev`
|
15
|
+
2. Import the partial in your Sass files
|
16
|
+
|
17
|
+
## What's in there?
|
18
|
+
|
19
|
+
* `sl-chunk()`: returns whether list contains $value
|
20
|
+
* `sl-contain()`: returns whether the list contains the value
|
21
|
+
* `sl-count-values()`: counts the number of occurrences of each value of list
|
22
|
+
* `sl-debug()`: returns list as a string
|
23
|
+
* `sl-every()`: returns whether all items from list pass test from given function
|
24
|
+
* `sl-explode()`: explodes a string into a list using a string as a delimiter
|
25
|
+
* `sl-first()`: returns first item in list
|
26
|
+
* `sl-flatten()`: turns multidimensional list into a one-level list
|
27
|
+
* `sl-insert-nth()`: inserts value at index
|
28
|
+
* `sl-intersection()`: returns a list of shared values across all given lists
|
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-map()`: casts list as map using indexes as keys
|
49
|
+
* `sl-to-string()`: casts list as string (JS `.join()`)
|
50
|
+
* `sl-union()`: returns a list of values from given lists minus duplicates
|
51
|
+
* `sl-walk()`: applies a function to every item of list
|
52
|
+
|
53
|
+
If you feel like an explorer, you can have a look at the code [here](https://github.com/Team-Sass/SassyLists/tree/master/stylesheets).
|
54
|
+
|
55
|
+
## Requirements
|
56
|
+
|
57
|
+
* Sass ~> 3.3.0
|
58
|
+
* Compass ~> 1.0.0
|
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 million thanks to [Vinay Raghu](http://viii.in/) for making this Compass extension out of my original work and to [Team-Sass](https://github.com/Team-Sass) for their [Compass Extension template](https://github.com/Team-Sass/Compass-Extension-Template).
|
data/lib/SassyLists.rb
CHANGED
@@ -1,14 +1,21 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
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
|
4
14
|
|
5
15
|
# Version is a number. If a version contains alphas, it will be created as a prerelease version
|
6
16
|
# Date is in the form of YYYY-MM-DD
|
7
17
|
module SassyLists
|
8
|
-
VERSION = "
|
9
|
-
DATE = "2014-06-
|
18
|
+
VERSION = "2.0.0"
|
19
|
+
DATE = "2014-06-30"
|
10
20
|
end
|
11
21
|
|
12
|
-
module Sass::Script::Functions
|
13
|
-
|
14
|
-
end
|
@@ -1,18 +1,18 @@
|
|
1
|
-
// Chunks
|
1
|
+
// Chunks `$list` into `$size` large lists.
|
2
2
|
//
|
3
3
|
// @ignore Documentation: http://sassylists.com/documentation/#chunk
|
4
4
|
//
|
5
5
|
// @param {List} $list - list to chunk
|
6
6
|
// @param {Number} $size - length of lists
|
7
7
|
//
|
8
|
-
// @throws $size is not a number for `chunk`.
|
8
|
+
// @throws $size is not a number for `sl-chunk`.
|
9
9
|
//
|
10
|
-
// @return {List |
|
10
|
+
// @return {List | Null}
|
11
11
|
|
12
|
-
@function chunk($list, $size) {
|
12
|
+
@function sl-chunk($list, $size) {
|
13
13
|
@if type-of($size) != "number" {
|
14
|
-
@warn "#{$size} is not a number for `chunk`.";
|
15
|
-
@return
|
14
|
+
@warn "#{$size} is not a number for `sl-chunk`.";
|
15
|
+
@return null;
|
16
16
|
}
|
17
17
|
|
18
18
|
@if $size >= length($list) {
|
@@ -1,4 +1,4 @@
|
|
1
|
-
// Returns whether
|
1
|
+
// Returns whether `$list` contains `$value`.
|
2
2
|
//
|
3
3
|
// @ignore Documentation: http://sassylists.com/documentation/#contain
|
4
4
|
//
|
@@ -7,12 +7,12 @@
|
|
7
7
|
//
|
8
8
|
// @return {Bool}
|
9
9
|
|
10
|
-
@function contain($list, $value) {
|
10
|
+
@function sl-contain($list, $value) {
|
11
11
|
@return not not index($list, $value);
|
12
12
|
}
|
13
13
|
|
14
|
-
// @alias contain
|
14
|
+
// @alias sl-contain
|
15
15
|
|
16
|
-
@function include($list, $value) {
|
17
|
-
@return contain($list, $value);
|
16
|
+
@function sl-include($list, $value) {
|
17
|
+
@return sl-contain($list, $value);
|
18
18
|
}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
// Counts the number of occurrences of each value of
|
1
|
+
// Counts the number of occurrences of each value of `$list`.
|
2
2
|
//
|
3
3
|
// @ignore Documentation: http://sassylists.com/documentation/#count-values
|
4
4
|
//
|
@@ -6,7 +6,7 @@
|
|
6
6
|
//
|
7
7
|
// @return {Map} Values mapped to their count
|
8
8
|
|
9
|
-
@function count-values($list) {
|
9
|
+
@function sl-count-values($list) {
|
10
10
|
$map: ();
|
11
11
|
|
12
12
|
@each $item in $list {
|
@@ -1,4 +1,4 @@
|
|
1
|
-
// Returns
|
1
|
+
// Returns `$list` as a string, prettified if `$pre` is set to true.
|
2
2
|
//
|
3
3
|
// @ignore Documentation: http://sassylists.com/documentation/#debug
|
4
4
|
//
|
@@ -8,7 +8,7 @@
|
|
8
8
|
//
|
9
9
|
// @return {String}
|
10
10
|
|
11
|
-
@function debug($list, $pre: false, $level: 1) {
|
11
|
+
@function sl-debug($list, $pre: false, $level: 1) {
|
12
12
|
@if length($list) == 0 {
|
13
13
|
@return "( )";
|
14
14
|
}
|
@@ -35,7 +35,7 @@
|
|
35
35
|
@if length($item) > 1 {
|
36
36
|
$result: $result
|
37
37
|
+ if($pre, "(list: " + length($item) + ") ", "")
|
38
|
-
+ debug($item, $pre, $level + 1);
|
38
|
+
+ sl-debug($item, $pre, $level + 1);
|
39
39
|
}
|
40
40
|
|
41
41
|
@else {
|
@@ -74,11 +74,11 @@
|
|
74
74
|
//
|
75
75
|
// @param {List} $list - list
|
76
76
|
//
|
77
|
-
// @requires {function} debug
|
77
|
+
// @requires {function} sl-debug
|
78
78
|
|
79
|
-
@mixin debug($list) {
|
79
|
+
@mixin sl-debug($list) {
|
80
80
|
body:before {
|
81
|
-
content: debug($list, true)
|
81
|
+
content: sl-debug($list, true) !important;
|
82
82
|
|
83
83
|
display: block !important;
|
84
84
|
margin: 1em !important;
|
@@ -0,0 +1,17 @@
|
|
1
|
+
// Tests whether all items from `$list` pass the test implemented by `$function`.
|
2
|
+
//
|
3
|
+
// @param {List} $list - list to run test against
|
4
|
+
// @param {String} $function - function to run against every item from list
|
5
|
+
// @param {ArgList} $args - extra arguments to pass to the function
|
6
|
+
//
|
7
|
+
// @return {Bool}
|
8
|
+
|
9
|
+
@function sl-every($list, $function, $args...) {
|
10
|
+
@each $item in $list {
|
11
|
+
@if not call($function, $item, $args...) {
|
12
|
+
@return false;
|
13
|
+
}
|
14
|
+
}
|
15
|
+
|
16
|
+
@return true;
|
17
|
+
}
|
@@ -1,24 +1,24 @@
|
|
1
|
-
// Explode
|
1
|
+
// Explode `$string` into a list using `$delimiter` as a delimiter.
|
2
2
|
//
|
3
3
|
// @ignore Documentation: http://sassylists.com/documentation/#explode
|
4
4
|
//
|
5
5
|
// @param {String} $string - string to explode
|
6
6
|
// @param {String} $separator ('') - string to use as a delimiter
|
7
7
|
//
|
8
|
-
// @throws $string is not a string for `explode`.
|
9
|
-
// @throws $delimiter is not a string for `explode`.
|
8
|
+
// @throws $string is not a string for `sl-explode`.
|
9
|
+
// @throws $delimiter is not a string for `sl-explode`.
|
10
10
|
//
|
11
|
-
// @return {List |
|
11
|
+
// @return {List | Null}
|
12
12
|
|
13
|
-
@function explode($string, $delimiter: '') {
|
13
|
+
@function sl-explode($string, $delimiter: '') {
|
14
14
|
@if type-of($string) != "string" {
|
15
|
-
@warn "`explode` function expecting a string; #{type-of($string)} given.";
|
16
|
-
@return
|
15
|
+
@warn "`sl-explode` function expecting a string; #{type-of($string)} given.";
|
16
|
+
@return null;
|
17
17
|
}
|
18
18
|
|
19
19
|
@if type-of($delimiter) != "string" {
|
20
|
-
@warn "`explode` function expecting a string; #{type-of($delimiter)} given.";
|
21
|
-
@return
|
20
|
+
@warn "`sl-explode` function expecting a string; #{type-of($delimiter)} given.";
|
21
|
+
@return null;
|
22
22
|
}
|
23
23
|
|
24
24
|
$result: ();
|
@@ -28,6 +28,7 @@
|
|
28
28
|
@for $i from 1 through $length {
|
29
29
|
$result: append($result, str-slice($string, $i, $i));
|
30
30
|
}
|
31
|
+
|
31
32
|
@return $result;
|
32
33
|
}
|
33
34
|
|
@@ -36,9 +37,11 @@
|
|
36
37
|
|
37
38
|
@while $running {
|
38
39
|
$index: str-index($remaining, $delimiter);
|
40
|
+
|
39
41
|
@if not $index or $index == 0 {
|
40
42
|
$running: false;
|
41
43
|
}
|
44
|
+
|
42
45
|
@else {
|
43
46
|
$slice: str-slice($remaining, 1, $index - 1);
|
44
47
|
$result: append($result, $slice);
|
@@ -1,4 +1,4 @@
|
|
1
|
-
// Returns first element of
|
1
|
+
// Returns first element of `$list`.
|
2
2
|
//
|
3
3
|
// @ignore Documentation: http://sassylists.com/documentation/#first
|
4
4
|
//
|
@@ -8,17 +8,17 @@
|
|
8
8
|
//
|
9
9
|
// @return {*}
|
10
10
|
|
11
|
-
@function first($list) {
|
11
|
+
@function sl-first($list) {
|
12
12
|
@if length($list) == 0 {
|
13
13
|
@warn "Cannot find first item of empty list.";
|
14
|
-
@return
|
14
|
+
@return null;
|
15
15
|
}
|
16
16
|
|
17
17
|
@return nth($list, 1);
|
18
18
|
}
|
19
19
|
|
20
|
-
// @alias first
|
20
|
+
// @alias sl-first
|
21
21
|
|
22
|
-
@function head($list) {
|
23
|
-
@return first($list);
|
22
|
+
@function sl-head($list) {
|
23
|
+
@return sl-first($list);
|
24
24
|
}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
// Turns multidimensional
|
1
|
+
// Turns multidimensional `$list` into a one-level list.
|
2
2
|
//
|
3
3
|
// @ignore Documentation: http://sassylists.com/documentation.html#flatten
|
4
4
|
//
|
@@ -6,7 +6,7 @@
|
|
6
6
|
//
|
7
7
|
// @return {List}
|
8
8
|
|
9
|
-
@function flatten($list) {
|
9
|
+
@function sl-flatten($list) {
|
10
10
|
$result: ();
|
11
11
|
|
12
12
|
@if length($list) == 1 {
|
@@ -15,7 +15,7 @@
|
|
15
15
|
|
16
16
|
@each $item in $list {
|
17
17
|
@if length($item) > 1 {
|
18
|
-
$flatten: flatten($item);
|
18
|
+
$flatten: sl-flatten($item);
|
19
19
|
@each $i in $flatten {
|
20
20
|
$result: append($result, $i, list-separator($list));
|
21
21
|
}
|
@@ -29,8 +29,8 @@
|
|
29
29
|
@return $result;
|
30
30
|
}
|
31
31
|
|
32
|
-
// @alias flatten
|
32
|
+
// @alias sl-flatten
|
33
33
|
|
34
|
-
@function unfold($list) {
|
35
|
-
@return flatten($list);
|
34
|
+
@function sl-unfold($list) {
|
35
|
+
@return sl-flatten($list);
|
36
36
|
}
|
@@ -1,29 +1,31 @@
|
|
1
|
-
// Adds
|
1
|
+
// Adds `$value` at `$index` in `$list`.
|
2
2
|
//
|
3
3
|
// @ignore Documentation: http://sassylists.com/documentation/#insert-nth
|
4
4
|
//
|
5
|
-
// @requires is-true
|
5
|
+
// @requires sl-is-true
|
6
6
|
//
|
7
7
|
// @param {List} $list - list to update
|
8
8
|
// @param {Number} $index - index to add
|
9
9
|
// @param {*} $value - value to add
|
10
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`.
|
11
|
+
// @throws List index $index is not a number for `sl-insert-nth`.
|
12
|
+
// @throws List index $index must be a non-zero integer for `sl-insert-nth`.
|
13
13
|
//
|
14
|
-
// @return {List |
|
14
|
+
// @return {List | Null}
|
15
|
+
|
16
|
+
@function sl-insert-nth($list, $index, $value) {
|
17
|
+
@if sl-missing-dependencies(sl-is-true) == true { @return null; }
|
15
18
|
|
16
|
-
@function insert-nth($list, $index, $value) {
|
17
19
|
$length: length($list);
|
18
20
|
|
19
21
|
@if type-of($index) != number {
|
20
|
-
@warn "List index #{$index} is not a number for `insert-nth`.";
|
21
|
-
@return
|
22
|
+
@warn "List index #{$index} is not a number for `sl-insert-nth`.";
|
23
|
+
@return null;
|
22
24
|
}
|
23
25
|
|
24
26
|
@if $index < 1 {
|
25
|
-
@warn "List index #{$index} must be a non-zero integer for `insert-nth`.";
|
26
|
-
@return
|
27
|
+
@warn "List index #{$index} must be a non-zero integer for `sl-insert-nth`.";
|
28
|
+
@return null;
|
27
29
|
}
|
28
30
|
|
29
31
|
@if $index > $length {
|
@@ -34,7 +36,7 @@
|
|
34
36
|
|
35
37
|
@for $i from 1 through $length {
|
36
38
|
@if $i == $index {
|
37
|
-
@if is-true($value) {
|
39
|
+
@if sl-is-true($value) {
|
38
40
|
$result: append($result, $value, list-separator($list));
|
39
41
|
}
|
40
42
|
}
|
@@ -1,15 +1,17 @@
|
|
1
|
-
// Returns a list of shared value from
|
1
|
+
// Returns a list of shared value from `$list` and `$lists` minus duplicates.
|
2
2
|
//
|
3
3
|
// @ignore Documentation: http://sassylists.com/documentation/#intersection
|
4
4
|
//
|
5
|
-
// @requires remove-duplicates
|
5
|
+
// @requires sl-remove-duplicates
|
6
6
|
//
|
7
7
|
// @param {List} $list - first list
|
8
8
|
// @param {ArgList} $lists - other lists
|
9
9
|
//
|
10
10
|
// @return {List}
|
11
11
|
|
12
|
-
@function intersection($list, $lists...) {
|
12
|
+
@function sl-intersection($list, $lists...) {
|
13
|
+
@if sl-missing-dependencies(sl-remove-duplicates) == true { @return null; }
|
14
|
+
|
13
15
|
$result: $list;
|
14
16
|
|
15
17
|
@each $list in $lists {
|
@@ -24,6 +26,6 @@
|
|
24
26
|
$result: $temp;
|
25
27
|
}
|
26
28
|
|
27
|
-
$result: remove-duplicates($result);
|
29
|
+
$result: sl-remove-duplicates($result);
|
28
30
|
@return if(length($result) == 1, nth($result, 1), $result);
|
29
31
|
}
|
@@ -1,19 +1,21 @@
|
|
1
|
-
// Checks whether
|
1
|
+
// Checks whether `$list` is symmetrical.
|
2
2
|
//
|
3
3
|
// @ignore Documentation: http://sassylists.com/documentation/#is-symmetrical
|
4
4
|
//
|
5
|
-
// @requires reverse
|
5
|
+
// @requires sl-reverse
|
6
6
|
//
|
7
7
|
// @param {List} $list - list to check
|
8
8
|
//
|
9
9
|
// @return {Bool}
|
10
10
|
|
11
|
-
@function is-symmetrical($list) {
|
12
|
-
@
|
11
|
+
@function sl-is-symmetrical($list) {
|
12
|
+
@if sl-missing-dependencies(sl-reverse) == true { @return null; }
|
13
|
+
|
14
|
+
@return $list == sl-reverse($list);
|
13
15
|
}
|
14
16
|
|
15
|
-
// @alias is-symmetrical
|
17
|
+
// @alias sl-is-symmetrical
|
16
18
|
|
17
|
-
@function is-mirror($list) {
|
18
|
-
@return is-symmetrical($list);
|
19
|
+
@function sl-is-mirror($list) {
|
20
|
+
@return sl-is-symmetrical($list);
|
19
21
|
}
|
@@ -1,13 +1,13 @@
|
|
1
|
-
// Returns last index of
|
1
|
+
// Returns last index of `$value` in `$list`.
|
2
2
|
//
|
3
3
|
// @ignore Documentation: http://sassylists.com/documentation/#last-index
|
4
4
|
//
|
5
|
-
// @param {List}
|
6
|
-
// @param {*}
|
5
|
+
// @param {List} $list - list to search
|
6
|
+
// @param {*} $value - value to be searched for
|
7
7
|
//
|
8
8
|
// @return {Number | Null}
|
9
9
|
|
10
|
-
@function last-index($list, $value) {
|
10
|
+
@function sl-last-index($list, $value) {
|
11
11
|
$length: length($list);
|
12
12
|
|
13
13
|
@for $i from $length through 1 {
|
@@ -1,4 +1,4 @@
|
|
1
|
-
// Returns last element of
|
1
|
+
// Returns last element of `$list`.
|
2
2
|
//
|
3
3
|
// @ignore Documentation: http://sassylists.com/documentation/#last
|
4
4
|
//
|
@@ -8,10 +8,10 @@
|
|
8
8
|
//
|
9
9
|
// @return {*}
|
10
10
|
|
11
|
-
@function last($list) {
|
11
|
+
@function sl-last($list) {
|
12
12
|
@if length($list) == 0 {
|
13
13
|
@warn "Cannot find last item of empty list.";
|
14
|
-
@return
|
14
|
+
@return null;
|
15
15
|
}
|
16
16
|
|
17
17
|
@return nth($list, -1);
|
@@ -1,4 +1,6 @@
|
|
1
|
-
// Shift indexes from
|
1
|
+
// Shift indexes from `$list` of `$value`.
|
2
|
+
//
|
3
|
+
// @author Ana Tudor
|
2
4
|
//
|
3
5
|
// @ignore Documentation: http://sassylists.com/documentation/#loop
|
4
6
|
//
|
@@ -7,12 +9,12 @@
|
|
7
9
|
//
|
8
10
|
// @throws $value is not a number for `loop`.
|
9
11
|
//
|
10
|
-
// @return {List |
|
12
|
+
// @return {List | Null}
|
11
13
|
|
12
|
-
@function loop($list, $value: 1) {
|
14
|
+
@function sl-loop($list, $value: 1) {
|
13
15
|
@if type-of($value) != "number" {
|
14
|
-
@warn "#{$value} is not a number for `loop`.";
|
15
|
-
@return
|
16
|
+
@warn "#{$value} is not a number for `sl-loop`.";
|
17
|
+
@return null;
|
16
18
|
}
|
17
19
|
|
18
20
|
@if length($list) < 2 {
|
@@ -29,8 +31,8 @@
|
|
29
31
|
@return $result;
|
30
32
|
}
|
31
33
|
|
32
|
-
// @alias
|
34
|
+
// @alias sl-loop
|
33
35
|
|
34
|
-
@function shift-indexes($list, $value: 1) {
|
35
|
-
@return loop($list, $value);
|
36
|
+
@function sl-shift-indexes($list, $value: 1) {
|
37
|
+
@return sl-loop($list, $value);
|
36
38
|
}
|
@@ -1,16 +1,18 @@
|
|
1
|
-
// Adds
|
1
|
+
// Adds `$value` as first index of `$list`.
|
2
2
|
//
|
3
3
|
// @ignore Documentation: http://sassylists.com/documentation/#prepend
|
4
4
|
//
|
5
|
-
// @requires is-true
|
5
|
+
// @requires sl-is-true
|
6
6
|
//
|
7
|
-
// @param {List}
|
8
|
-
// @param {*}
|
7
|
+
// @param {List} $list - list to preprend value to
|
8
|
+
// @param {*} $value - value to prepend to the list
|
9
9
|
//
|
10
10
|
// @return {List}
|
11
11
|
|
12
|
-
@function prepend($list, $value) {
|
13
|
-
@if is-true
|
12
|
+
@function sl-prepend($list, $value) {
|
13
|
+
@if missing-dependencies(sl-is-true) == true { @return null; }
|
14
|
+
|
15
|
+
@if sl-is-true($value) {
|
14
16
|
@return join($value, $list, list-separator($list));
|
15
17
|
}
|
16
18
|
|
@@ -1,18 +1,20 @@
|
|
1
|
-
// Removes all false and null values from
|
1
|
+
// Removes all false and null values from `$list`.
|
2
2
|
//
|
3
3
|
// @ignore Documentation: http://sassylists.com/documentation.html#purge
|
4
4
|
//
|
5
|
-
// @requires is-true
|
5
|
+
// @requires sl-is-true
|
6
6
|
//
|
7
7
|
// @param {List} $list - list to purge
|
8
8
|
//
|
9
9
|
// @return {List}
|
10
10
|
|
11
|
-
@function purge($list) {
|
11
|
+
@function sl-purge($list) {
|
12
|
+
@if sl-missing-dependencies(sl-is-true) == true { @return null; }
|
13
|
+
|
12
14
|
$result: ();
|
13
15
|
|
14
16
|
@each $item in $list {
|
15
|
-
@if is-true($item) {
|
17
|
+
@if sl-is-true($item) {
|
16
18
|
$result: append($result, $item, list-separator($list));
|
17
19
|
}
|
18
20
|
}
|
@@ -20,8 +22,8 @@
|
|
20
22
|
@return $result;
|
21
23
|
}
|
22
24
|
|
23
|
-
// @alias purge
|
25
|
+
// @alias sl-purge
|
24
26
|
|
25
|
-
@function clean($list) {
|
26
|
-
@return purge($list);
|
27
|
+
@function sl-clean($list) {
|
28
|
+
@return sl-purge($list);
|
27
29
|
}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
// Returns a random value of
|
1
|
+
// Returns a random value of `$list`.
|
2
2
|
//
|
3
3
|
// @ignore Documentation: http://sassylists.com/documentation.html#random-value
|
4
4
|
//
|
@@ -8,23 +8,23 @@
|
|
8
8
|
//
|
9
9
|
// @return {*}
|
10
10
|
|
11
|
-
@function random-value($list) {
|
11
|
+
@function sl-random-value($list) {
|
12
12
|
@if length($list) == 0 {
|
13
13
|
@warn "Cannot find a random value in an empty list.";
|
14
|
-
@return
|
14
|
+
@return null;
|
15
15
|
}
|
16
16
|
|
17
|
-
@return nth($list, random(length($list))
|
17
|
+
@return nth($list, random(length($list)));
|
18
18
|
}
|
19
19
|
|
20
|
-
// @alias random-value
|
20
|
+
// @alias sl-random-value
|
21
21
|
|
22
|
-
@function roll($list) {
|
23
|
-
@return random-value($list);
|
22
|
+
@function sl-roll($list) {
|
23
|
+
@return sl-random-value($list);
|
24
24
|
}
|
25
25
|
|
26
|
-
// @alias random-value
|
26
|
+
// @alias sl-random-value
|
27
27
|
|
28
|
-
@function luck($list) {
|
29
|
-
@return random-value($list);
|
28
|
+
@function sl-luck($list) {
|
29
|
+
@return sl-random-value($list);
|
30
30
|
}
|