SassyLists 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +36 -36
- data/lib/SassyLists.rb +13 -13
- data/stylesheets/SassyLists/_chunk.scss +41 -41
- 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/_explode.scss +49 -49
- data/stylesheets/SassyLists/_first.scss +23 -23
- data/stylesheets/SassyLists/_flatten.scss +35 -35
- data/stylesheets/SassyLists/_insert-nth.scss +46 -46
- data/stylesheets/SassyLists/_intersection.scss +28 -28
- data/stylesheets/SassyLists/_is-symmetrical.scss +18 -18
- data/stylesheets/SassyLists/_last-index.scss +20 -20
- data/stylesheets/SassyLists/_last.scss +17 -17
- data/stylesheets/SassyLists/_loop.scss +35 -35
- data/stylesheets/SassyLists/_prepend.scss +20 -20
- data/stylesheets/SassyLists/_purge.scss +27 -27
- data/stylesheets/SassyLists/_random-value.scss +29 -29
- data/stylesheets/SassyLists/_remove-duplicates.scss +24 -24
- data/stylesheets/SassyLists/_remove-nth.scss +19 -19
- data/stylesheets/SassyLists/_remove.scss +20 -20
- data/stylesheets/SassyLists/_replace-nth.scss +24 -24
- data/stylesheets/SassyLists/_replace.scss +29 -29
- data/stylesheets/SassyLists/_reverse.scss +29 -29
- data/stylesheets/SassyLists/_shuffle.scss +29 -29
- data/stylesheets/SassyLists/_slice.scss +48 -48
- data/stylesheets/SassyLists/_sort.scss +40 -40
- data/stylesheets/SassyLists/_sum.scss +28 -28
- data/stylesheets/SassyLists/_tail.scss +18 -18
- data/stylesheets/SassyLists/_to-string.scss +25 -25
- data/stylesheets/SassyLists/_union.scss +21 -21
- data/stylesheets/SassyLists/_walk.scss +23 -23
- data/stylesheets/SassyLists/helpers/_str-compare.scss +24 -24
- data/stylesheets/SassyLists/helpers/_true.scss +10 -10
- data/stylesheets/_SassyLists.scss +38 -38
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9188bd3fa596049952a7632069d04150021289bb
|
4
|
+
data.tar.gz: 2b8cd2fddcbe99bcaffa6e11c552eba1f9468bbe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 73b07f9d83ce6bfb68b36fda09a3d9ba3f1a3209d571dc8c3d383cf5c6b34cec1ca62438952e2b0f26ca03ce6145ef3384d59497d8c961dc5b1401736899b4d8
|
7
|
+
data.tar.gz: 9a6b283f587c8ed177db46f4b5beb675da1687e38f6fd2a07a19577736700c9714c53a6ed9320398f8a4ff705c7d28a4980ba5dbb06c77ab316a2a9466a12217
|
data/CHANGELOG.md
CHANGED
@@ -1,36 +1,36 @@
|
|
1
|
-
# Changelog
|
2
|
-
|
3
|
-
* `1.1.0`: added `walk()` and `tail()`, updated backward loops and fixed broken tests
|
4
|
-
* `1.0.0`: moving code base to Sass 3.3 + adding a Grunt workflow
|
5
|
-
* adding `explode`
|
6
|
-
* making use of `list-separator()` and `set-nth()`
|
7
|
-
* updating `sort()` to make it able to sort strings
|
8
|
-
* removing all notion of recursion for sake of simplicity
|
9
|
-
* making `count-values()` return a map
|
10
|
-
* minor fixes and improvements
|
11
|
-
* improving overall performances
|
12
|
-
* `0.4.9`: removing `compact()` alias for `purge()` (ref [#23](https://github.com/Team-Sass/SassyLists/issues/23))
|
13
|
-
* `0.4.8`: adding `shuffle()`
|
14
|
-
* `0.4.7`: dramatically improving `sort()` performances and removing all its dependencies
|
15
|
-
* `0.4.6`: fixing an issue when passing an empty list to `chunk()` and improved code quality
|
16
|
-
* `0.4.5`: making `sort()` able to return in descending order
|
17
|
-
* `0.4.4`: fixing a typo in `purge()`
|
18
|
-
* `0.4.3`: improving `insert-nth()`, `prepend()`, `replace-nth()` and `replace()` to prevent from adding empty lists
|
19
|
-
* `0.4.2`: improving `insert-nth()` and cleaning some indentation issues
|
20
|
-
* `0.4.1`: improving `intersection()` perf
|
21
|
-
* `0.4.0`: adding `intersection()`
|
22
|
-
* `0.3.5`: improving `debug()`, `to-string()` and `chunk()`
|
23
|
-
* `0.3.4`: fixing a minor issue in `insert-nth()`, `replace-nth()` and `prepend()`
|
24
|
-
* `0.3.3`: removing dependence to `purge()` from all functions; fixed an issue with `sort()`; fixed an issue with error messages
|
25
|
-
* `0.3.2`: removing dependence to `purge()` from `replace()`
|
26
|
-
* `0.3.1`: adding aliases and cleaned `to-string()`
|
27
|
-
* `0.3.0`: adding `contains()`, `flatten()`, `union()`
|
28
|
-
* `0.2.4`: improving `debug()`
|
29
|
-
* `0.2.3`: fixing important issues with comments
|
30
|
-
* `0.2.2`: moving all comments to invisible
|
31
|
-
* `0.2.1`: fixing an issue with `random-value()`
|
32
|
-
* `0.2.0`: adding `random-value()`
|
33
|
-
* `0.1.4`: fixing an issue with `sort()`, `is-symmetrical()`
|
34
|
-
* `0.1.3`: fixing an issue with `sort()`
|
35
|
-
* `0.1.2`: improving `debug()`
|
36
|
-
* `0.1.1`: initial commit
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
* `1.1.0`: added `walk()` and `tail()`, updated backward loops and fixed broken tests
|
4
|
+
* `1.0.0`: moving code base to Sass 3.3 + adding a Grunt workflow
|
5
|
+
* adding `explode`
|
6
|
+
* making use of `list-separator()` and `set-nth()`
|
7
|
+
* updating `sort()` to make it able to sort strings
|
8
|
+
* removing all notion of recursion for sake of simplicity
|
9
|
+
* making `count-values()` return a map
|
10
|
+
* minor fixes and improvements
|
11
|
+
* improving overall performances
|
12
|
+
* `0.4.9`: removing `compact()` alias for `purge()` (ref [#23](https://github.com/Team-Sass/SassyLists/issues/23))
|
13
|
+
* `0.4.8`: adding `shuffle()`
|
14
|
+
* `0.4.7`: dramatically improving `sort()` performances and removing all its dependencies
|
15
|
+
* `0.4.6`: fixing an issue when passing an empty list to `chunk()` and improved code quality
|
16
|
+
* `0.4.5`: making `sort()` able to return in descending order
|
17
|
+
* `0.4.4`: fixing a typo in `purge()`
|
18
|
+
* `0.4.3`: improving `insert-nth()`, `prepend()`, `replace-nth()` and `replace()` to prevent from adding empty lists
|
19
|
+
* `0.4.2`: improving `insert-nth()` and cleaning some indentation issues
|
20
|
+
* `0.4.1`: improving `intersection()` perf
|
21
|
+
* `0.4.0`: adding `intersection()`
|
22
|
+
* `0.3.5`: improving `debug()`, `to-string()` and `chunk()`
|
23
|
+
* `0.3.4`: fixing a minor issue in `insert-nth()`, `replace-nth()` and `prepend()`
|
24
|
+
* `0.3.3`: removing dependence to `purge()` from all functions; fixed an issue with `sort()`; fixed an issue with error messages
|
25
|
+
* `0.3.2`: removing dependence to `purge()` from `replace()`
|
26
|
+
* `0.3.1`: adding aliases and cleaned `to-string()`
|
27
|
+
* `0.3.0`: adding `contains()`, `flatten()`, `union()`
|
28
|
+
* `0.2.4`: improving `debug()`
|
29
|
+
* `0.2.3`: fixing important issues with comments
|
30
|
+
* `0.2.2`: moving all comments to invisible
|
31
|
+
* `0.2.1`: fixing an issue with `random-value()`
|
32
|
+
* `0.2.0`: adding `random-value()`
|
33
|
+
* `0.1.4`: fixing an issue with `sort()`, `is-symmetrical()`
|
34
|
+
* `0.1.3`: fixing an issue with `sort()`
|
35
|
+
* `0.1.2`: improving `debug()`
|
36
|
+
* `0.1.1`: initial commit
|
data/lib/SassyLists.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
|
-
require 'compass'
|
2
|
-
extension_path = File.expand_path(File.join(File.dirname(__FILE__), ".."))
|
3
|
-
Compass::Frameworks.register('SassyLists', :path => extension_path)
|
4
|
-
|
5
|
-
# Version is a number. If a version contains alphas, it will be created as a prerelease version
|
6
|
-
# Date is in the form of YYYY-MM-DD
|
7
|
-
module SassyLists
|
8
|
-
VERSION = "1.1.
|
9
|
-
DATE = "2014-06-28"
|
10
|
-
end
|
11
|
-
|
12
|
-
module Sass::Script::Functions
|
13
|
-
|
1
|
+
require 'compass'
|
2
|
+
extension_path = File.expand_path(File.join(File.dirname(__FILE__), ".."))
|
3
|
+
Compass::Frameworks.register('SassyLists', :path => extension_path)
|
4
|
+
|
5
|
+
# Version is a number. If a version contains alphas, it will be created as a prerelease version
|
6
|
+
# Date is in the form of YYYY-MM-DD
|
7
|
+
module SassyLists
|
8
|
+
VERSION = "1.1.1"
|
9
|
+
DATE = "2014-06-28"
|
10
|
+
end
|
11
|
+
|
12
|
+
module Sass::Script::Functions
|
13
|
+
|
14
14
|
end
|
@@ -1,42 +1,42 @@
|
|
1
|
-
// Chunks $list into $size large lists
|
2
|
-
//
|
3
|
-
// @ignore Documentation: http://sassylists.com/documentation/#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 `chunk`.
|
9
|
-
//
|
10
|
-
// @return {List | Bool}
|
11
|
-
|
12
|
-
@function chunk($list, $size) {
|
13
|
-
@if type-of($size) != "number" {
|
14
|
-
@warn "#{$size} is not a number for `chunk`.";
|
15
|
-
@return false;
|
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/#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 `chunk`.
|
9
|
+
//
|
10
|
+
// @return {List | Bool}
|
11
|
+
|
12
|
+
@function chunk($list, $size) {
|
13
|
+
@if type-of($size) != "number" {
|
14
|
+
@warn "#{$size} is not a number for `chunk`.";
|
15
|
+
@return false;
|
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/#contain
|
4
|
-
//
|
5
|
-
// @param {List} $list - list to check
|
6
|
-
// @param {*} $value - value to look for
|
7
|
-
//
|
8
|
-
// @return {Bool}
|
9
|
-
|
10
|
-
@function contain($list, $value) {
|
11
|
-
@return not not index($list, $value);
|
12
|
-
}
|
13
|
-
|
14
|
-
// @alias contain
|
15
|
-
|
16
|
-
@function include($list, $value) {
|
17
|
-
@return contain($list, $value);
|
1
|
+
// Returns whether $list contains $value
|
2
|
+
//
|
3
|
+
// @ignore Documentation: http://sassylists.com/documentation/#contain
|
4
|
+
//
|
5
|
+
// @param {List} $list - list to check
|
6
|
+
// @param {*} $value - value to look for
|
7
|
+
//
|
8
|
+
// @return {Bool}
|
9
|
+
|
10
|
+
@function contain($list, $value) {
|
11
|
+
@return not not index($list, $value);
|
12
|
+
}
|
13
|
+
|
14
|
+
// @alias contain
|
15
|
+
|
16
|
+
@function include($list, $value) {
|
17
|
+
@return 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/#count-values
|
4
|
-
//
|
5
|
-
// @param {List} $list - list to count values from
|
6
|
-
//
|
7
|
-
// @return {Map} Values mapped to their count
|
8
|
-
|
9
|
-
@function 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/#count-values
|
4
|
+
//
|
5
|
+
// @param {List} $list - list to count values from
|
6
|
+
//
|
7
|
+
// @return {Map} Values mapped to their count
|
8
|
+
|
9
|
+
@function 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
|
}
|
@@ -1,96 +1,96 @@
|
|
1
|
-
// Returns $list as a string
|
2
|
-
//
|
3
|
-
// @ignore Documentation: http://sassylists.com/documentation/#debug
|
4
|
-
//
|
5
|
-
// @param {List} $list - list to debug
|
6
|
-
// @param {Bool} $pre (false) - enable/disable variables type and proper indentation
|
7
|
-
// @param {Number} $level (1) - internal variable for recursion
|
8
|
-
//
|
9
|
-
// @return {String}
|
10
|
-
|
11
|
-
@function debug($list, $pre: false, $level: 1) {
|
12
|
-
@if length($list) == 0 {
|
13
|
-
@return "( )";
|
14
|
-
}
|
15
|
-
|
16
|
-
@if length($list) == 1 {
|
17
|
-
@return if($pre, "(" + type-of($list) + ") ", "") + $list;
|
18
|
-
}
|
19
|
-
|
20
|
-
$tab: " ";
|
21
|
-
$indent: "";
|
22
|
-
$break: if($pre, "\A ", "");
|
23
|
-
$length: length($list);
|
24
|
-
|
25
|
-
@for $i from 1 to $level {
|
26
|
-
$indent: $indent + $tab;
|
27
|
-
}
|
28
|
-
|
29
|
-
$result: "[" + $break;
|
30
|
-
|
31
|
-
@for $i from 1 through $length {
|
32
|
-
$item: nth($list, $i);
|
33
|
-
$result: $result + if($pre, $indent + $tab, " ");
|
34
|
-
|
35
|
-
@if length($item) > 1 {
|
36
|
-
$result: $result
|
37
|
-
+ if($pre, "(list: " + length($item) + ") ", "")
|
38
|
-
+ debug($item, $pre, $level + 1);
|
39
|
-
}
|
40
|
-
|
41
|
-
@else {
|
42
|
-
@if $pre {
|
43
|
-
$result: $result + "(" + type-of($item) + ") ";
|
44
|
-
}
|
45
|
-
|
46
|
-
@if length($item) == 0 {
|
47
|
-
$result: $result + "( )";
|
48
|
-
}
|
49
|
-
|
50
|
-
@else if type-of($item) == "string" {
|
51
|
-
$result: $result + quote($item);
|
52
|
-
}
|
53
|
-
|
54
|
-
@else if $item == null {
|
55
|
-
$result: $result + "null";
|
56
|
-
}
|
57
|
-
|
58
|
-
@else {
|
59
|
-
$result: $result + $item;
|
60
|
-
}
|
61
|
-
}
|
62
|
-
|
63
|
-
@if $i != $length {
|
64
|
-
$result: $result + "," + $break;
|
65
|
-
}
|
66
|
-
}
|
67
|
-
|
68
|
-
$result: $result + $break + if($pre, if($level > 1, $indent, ""), " ") + "]";
|
69
|
-
|
70
|
-
@return quote($result);
|
71
|
-
}
|
72
|
-
|
73
|
-
// Mixin displaying clean debug
|
74
|
-
//
|
75
|
-
// @param {List} $list - list
|
76
|
-
//
|
77
|
-
// @requires {function} debug
|
78
|
-
|
79
|
-
@mixin debug($list) {
|
80
|
-
body:before {
|
81
|
-
content: debug($list, true) !important;
|
82
|
-
|
83
|
-
display: block !important;
|
84
|
-
margin: 1em !important;
|
85
|
-
padding: .5em !important;
|
86
|
-
|
87
|
-
background: #EFEFEF !important;
|
88
|
-
border: 1px solid #DDD !important;
|
89
|
-
border-radius: .2em !important;
|
90
|
-
|
91
|
-
color: #333 !important;
|
92
|
-
font: .75em/1.5 "Courier New", monospace !important;
|
93
|
-
text-shadow: 0 1px white !important;
|
94
|
-
white-space: pre-wrap !important;
|
95
|
-
}
|
96
|
-
}
|
1
|
+
// Returns $list as a string
|
2
|
+
//
|
3
|
+
// @ignore Documentation: http://sassylists.com/documentation/#debug
|
4
|
+
//
|
5
|
+
// @param {List} $list - list to debug
|
6
|
+
// @param {Bool} $pre (false) - enable/disable variables type and proper indentation
|
7
|
+
// @param {Number} $level (1) - internal variable for recursion
|
8
|
+
//
|
9
|
+
// @return {String}
|
10
|
+
|
11
|
+
@function debug($list, $pre: false, $level: 1) {
|
12
|
+
@if length($list) == 0 {
|
13
|
+
@return "( )";
|
14
|
+
}
|
15
|
+
|
16
|
+
@if length($list) == 1 {
|
17
|
+
@return if($pre, "(" + type-of($list) + ") ", "") + $list;
|
18
|
+
}
|
19
|
+
|
20
|
+
$tab: " ";
|
21
|
+
$indent: "";
|
22
|
+
$break: if($pre, "\A ", "");
|
23
|
+
$length: length($list);
|
24
|
+
|
25
|
+
@for $i from 1 to $level {
|
26
|
+
$indent: $indent + $tab;
|
27
|
+
}
|
28
|
+
|
29
|
+
$result: "[" + $break;
|
30
|
+
|
31
|
+
@for $i from 1 through $length {
|
32
|
+
$item: nth($list, $i);
|
33
|
+
$result: $result + if($pre, $indent + $tab, " ");
|
34
|
+
|
35
|
+
@if length($item) > 1 {
|
36
|
+
$result: $result
|
37
|
+
+ if($pre, "(list: " + length($item) + ") ", "")
|
38
|
+
+ debug($item, $pre, $level + 1);
|
39
|
+
}
|
40
|
+
|
41
|
+
@else {
|
42
|
+
@if $pre {
|
43
|
+
$result: $result + "(" + type-of($item) + ") ";
|
44
|
+
}
|
45
|
+
|
46
|
+
@if length($item) == 0 {
|
47
|
+
$result: $result + "( )";
|
48
|
+
}
|
49
|
+
|
50
|
+
@else if type-of($item) == "string" {
|
51
|
+
$result: $result + quote($item);
|
52
|
+
}
|
53
|
+
|
54
|
+
@else if $item == null {
|
55
|
+
$result: $result + "null";
|
56
|
+
}
|
57
|
+
|
58
|
+
@else {
|
59
|
+
$result: $result + $item;
|
60
|
+
}
|
61
|
+
}
|
62
|
+
|
63
|
+
@if $i != $length {
|
64
|
+
$result: $result + "," + $break;
|
65
|
+
}
|
66
|
+
}
|
67
|
+
|
68
|
+
$result: $result + $break + if($pre, if($level > 1, $indent, ""), " ") + "]";
|
69
|
+
|
70
|
+
@return quote($result);
|
71
|
+
}
|
72
|
+
|
73
|
+
// Mixin displaying clean debug
|
74
|
+
//
|
75
|
+
// @param {List} $list - list
|
76
|
+
//
|
77
|
+
// @requires {function} debug
|
78
|
+
|
79
|
+
@mixin debug($list) {
|
80
|
+
body:before {
|
81
|
+
content: debug($list, true) !important;
|
82
|
+
|
83
|
+
display: block !important;
|
84
|
+
margin: 1em !important;
|
85
|
+
padding: .5em !important;
|
86
|
+
|
87
|
+
background: #EFEFEF !important;
|
88
|
+
border: 1px solid #DDD !important;
|
89
|
+
border-radius: .2em !important;
|
90
|
+
|
91
|
+
color: #333 !important;
|
92
|
+
font: .75em/1.5 "Courier New", monospace !important;
|
93
|
+
text-shadow: 0 1px white !important;
|
94
|
+
white-space: pre-wrap !important;
|
95
|
+
}
|
96
|
+
}
|
@@ -1,50 +1,50 @@
|
|
1
|
-
// Explode $string into a list using $break as a breaker
|
2
|
-
//
|
3
|
-
// @ignore Documentation: http://sassylists.com/documentation/#explode
|
4
|
-
//
|
5
|
-
// @param {String} $string - string to explode
|
6
|
-
// @param {String} $separator ('') - string to use as a delimiter
|
7
|
-
//
|
8
|
-
// @throws $string is not a string for `explode`.
|
9
|
-
// @throws $delimiter is not a string for `explode`.
|
10
|
-
//
|
11
|
-
// @return {List | Bool}
|
12
|
-
|
13
|
-
@function explode($string, $delimiter: '') {
|
14
|
-
@if type-of($string) != "string" {
|
15
|
-
@warn "`explode` function expecting a string; #{type-of($string)} given.";
|
16
|
-
@return false;
|
17
|
-
}
|
18
|
-
|
19
|
-
@if type-of($delimiter) != "string" {
|
20
|
-
@warn "`explode` function expecting a string; #{type-of($delimiter)} given.";
|
21
|
-
@return false;
|
22
|
-
}
|
23
|
-
|
24
|
-
$result: ();
|
25
|
-
$length: str-length($string);
|
26
|
-
|
27
|
-
@if str-length($delimiter) == 0 {
|
28
|
-
@for $i from 1 through $length {
|
29
|
-
$result: append($result, str-slice($string, $i, $i));
|
30
|
-
}
|
31
|
-
@return $result;
|
32
|
-
}
|
33
|
-
|
34
|
-
$running: true;
|
35
|
-
$remaining: $string;
|
36
|
-
|
37
|
-
@while $running {
|
38
|
-
$index: str-index($remaining, $delimiter);
|
39
|
-
@if not $index or $index == 0 {
|
40
|
-
$running: false;
|
41
|
-
}
|
42
|
-
@else {
|
43
|
-
$slice: str-slice($remaining, 1, $index - 1);
|
44
|
-
$result: append($result, $slice);
|
45
|
-
$remaining: str-slice($remaining, $index + str-length($delimiter));
|
46
|
-
}
|
47
|
-
}
|
48
|
-
|
49
|
-
@return append($result, $remaining);
|
1
|
+
// Explode $string into a list using $break as a breaker
|
2
|
+
//
|
3
|
+
// @ignore Documentation: http://sassylists.com/documentation/#explode
|
4
|
+
//
|
5
|
+
// @param {String} $string - string to explode
|
6
|
+
// @param {String} $separator ('') - string to use as a delimiter
|
7
|
+
//
|
8
|
+
// @throws $string is not a string for `explode`.
|
9
|
+
// @throws $delimiter is not a string for `explode`.
|
10
|
+
//
|
11
|
+
// @return {List | Bool}
|
12
|
+
|
13
|
+
@function explode($string, $delimiter: '') {
|
14
|
+
@if type-of($string) != "string" {
|
15
|
+
@warn "`explode` function expecting a string; #{type-of($string)} given.";
|
16
|
+
@return false;
|
17
|
+
}
|
18
|
+
|
19
|
+
@if type-of($delimiter) != "string" {
|
20
|
+
@warn "`explode` function expecting a string; #{type-of($delimiter)} given.";
|
21
|
+
@return false;
|
22
|
+
}
|
23
|
+
|
24
|
+
$result: ();
|
25
|
+
$length: str-length($string);
|
26
|
+
|
27
|
+
@if str-length($delimiter) == 0 {
|
28
|
+
@for $i from 1 through $length {
|
29
|
+
$result: append($result, str-slice($string, $i, $i));
|
30
|
+
}
|
31
|
+
@return $result;
|
32
|
+
}
|
33
|
+
|
34
|
+
$running: true;
|
35
|
+
$remaining: $string;
|
36
|
+
|
37
|
+
@while $running {
|
38
|
+
$index: str-index($remaining, $delimiter);
|
39
|
+
@if not $index or $index == 0 {
|
40
|
+
$running: false;
|
41
|
+
}
|
42
|
+
@else {
|
43
|
+
$slice: str-slice($remaining, 1, $index - 1);
|
44
|
+
$result: append($result, $slice);
|
45
|
+
$remaining: str-slice($remaining, $index + str-length($delimiter));
|
46
|
+
}
|
47
|
+
}
|
48
|
+
|
49
|
+
@return append($result, $remaining);
|
50
50
|
}
|
@@ -1,24 +1,24 @@
|
|
1
|
-
// Returns first element of $list
|
2
|
-
//
|
3
|
-
// @ignore Documentation: http://sassylists.com/documentation/#first
|
4
|
-
//
|
5
|
-
// @param {List} $list - list to retrieve first item from
|
6
|
-
//
|
7
|
-
// @throws Cannot find first item of empty list.
|
8
|
-
//
|
9
|
-
// @return {*}
|
10
|
-
|
11
|
-
@function first($list) {
|
12
|
-
@if length($list) == 0 {
|
13
|
-
@warn "Cannot find first item of empty list.";
|
14
|
-
@return false;
|
15
|
-
}
|
16
|
-
|
17
|
-
@return nth($list, 1);
|
18
|
-
}
|
19
|
-
|
20
|
-
// @alias first
|
21
|
-
|
22
|
-
@function head($list) {
|
23
|
-
@return first($list);
|
1
|
+
// Returns first element of $list
|
2
|
+
//
|
3
|
+
// @ignore Documentation: http://sassylists.com/documentation/#first
|
4
|
+
//
|
5
|
+
// @param {List} $list - list to retrieve first item from
|
6
|
+
//
|
7
|
+
// @throws Cannot find first item of empty list.
|
8
|
+
//
|
9
|
+
// @return {*}
|
10
|
+
|
11
|
+
@function first($list) {
|
12
|
+
@if length($list) == 0 {
|
13
|
+
@warn "Cannot find first item of empty list.";
|
14
|
+
@return false;
|
15
|
+
}
|
16
|
+
|
17
|
+
@return nth($list, 1);
|
18
|
+
}
|
19
|
+
|
20
|
+
// @alias first
|
21
|
+
|
22
|
+
@function head($list) {
|
23
|
+
@return first($list);
|
24
24
|
}
|