SassyLists 0.4.6 → 0.4.7
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.
- data/CHANGELOG.md +1 -0
- data/lib/SassyLists.rb +2 -2
- data/stylesheets/SassyLists/_sort.scss +24 -38
- metadata +2 -2
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
* `0.4.7`: dramatically improving `sort()` performances and removing all its dependencies
|
3
4
|
* `0.4.6`: fixing an issue when passing an empty list to `chunk()` and improved code quality
|
4
5
|
* `0.4.5`: making `sort()` able to return in descending order
|
5
6
|
* `0.4.4`: fixing a typo in `purge()`
|
data/lib/SassyLists.rb
CHANGED
@@ -5,8 +5,8 @@ Compass::Frameworks.register('SassyLists', :path => extension_path)
|
|
5
5
|
# Version is a number. If a version contains alphas, it will be created as a prerelease version
|
6
6
|
# Date is in the form of YYYY-MM-DD
|
7
7
|
module SassyLists
|
8
|
-
VERSION = "0.4.
|
9
|
-
DATE = "2013-12-
|
8
|
+
VERSION = "0.4.7"
|
9
|
+
DATE = "2013-12-30"
|
10
10
|
end
|
11
11
|
|
12
12
|
module Sass::Script::Functions
|
@@ -4,69 +4,55 @@
|
|
4
4
|
// -------------------------------------------------------------------------------
|
5
5
|
// @alias `order()`
|
6
6
|
// -------------------------------------------------------------------------------
|
7
|
-
// @dependence `last()`
|
8
|
-
// @dependence `insert-nth()`
|
9
|
-
// @dependence `reverse()`
|
10
|
-
// -------------------------------------------------------------------------------
|
11
7
|
// @example sort(5 12 4.7 6 69 6) => 4.7, 5, 6, 6, 12, 69
|
12
8
|
// @example sort(5 12 4.7 "8" 6 14px 69 6) => 4.7, 5, 6, 6, 12, 69
|
13
9
|
// -------------------------------------------------------------------------------
|
14
10
|
// @param $list [List] : list
|
15
11
|
// @param $ascending [Boolean] : ascending or descending
|
16
12
|
// -------------------------------------------------------------------------------
|
17
|
-
// @raise [Warning] if not
|
13
|
+
// @raise [Warning] if not-number found
|
18
14
|
// -------------------------------------------------------------------------------
|
19
15
|
// @return [List]
|
20
16
|
|
21
|
-
@function sort($list
|
22
|
-
$
|
17
|
+
@function sort($list) {
|
18
|
+
$less: ();
|
19
|
+
$equal: ();
|
20
|
+
$large: ();
|
21
|
+
$seed: ceil(length($list) / 2);
|
23
22
|
|
24
23
|
@if length($list) > 1 {
|
24
|
+
$seed: nth($list, $seed);
|
25
25
|
|
26
|
-
@
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
@if unitless($item) {
|
32
|
-
|
33
|
-
@if $item > last($result) {
|
34
|
-
$result: append($result, $item);
|
35
|
-
}
|
36
|
-
|
37
|
-
@else {
|
38
|
-
$index: 0;
|
39
|
-
|
40
|
-
@for $i from length($result) * -1 through -1 {
|
41
|
-
$i: abs($i);
|
42
|
-
|
43
|
-
@if $item <= nth($result, $i) {
|
44
|
-
$index: $i;
|
45
|
-
}
|
46
|
-
}
|
47
|
-
|
48
|
-
$result: insert-nth($result, $index, $item);
|
49
|
-
}
|
26
|
+
@each $item in $list {
|
27
|
+
@if comparable($seed, $item) {
|
28
|
+
@if $item < $seed {
|
29
|
+
$less: append($less, $item);
|
30
|
+
}
|
50
31
|
|
32
|
+
@else if $item == $seed {
|
33
|
+
$equal: append($equal, $item);
|
51
34
|
}
|
52
35
|
|
53
36
|
@else {
|
54
|
-
|
37
|
+
$large: append($large, $item);
|
55
38
|
}
|
56
|
-
|
57
|
-
}
|
39
|
+
}
|
58
40
|
|
59
41
|
@else {
|
60
42
|
@warn "Not integer value found. Omitted.";
|
61
43
|
}
|
62
44
|
}
|
63
|
-
}
|
64
45
|
|
65
|
-
|
66
|
-
$
|
46
|
+
$less: sort($less);
|
47
|
+
$large: sort($large);
|
48
|
+
|
49
|
+
$result: join($less, $equal);
|
50
|
+
$result: join($result, $large);
|
51
|
+
|
52
|
+
@return $result;
|
67
53
|
}
|
68
54
|
|
69
|
-
@return $
|
55
|
+
@return $list;
|
70
56
|
}
|
71
57
|
|
72
58
|
// Alias
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: SassyLists
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-12-
|
12
|
+
date: 2013-12-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sass
|