SassyStrings 1.1.3 → 1.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +1 -0
- data/README.md +4 -4
- data/lib/SassyStrings.rb +2 -2
- data/stylesheets/private/_all.scss +2 -2
- data/stylesheets/private/_char-at.scss +7 -15
- data/stylesheets/private/_levenshtein.scss +63 -84
- data/stylesheets/private/_str-count.scss +15 -23
- data/stylesheets/private/_str-ends-with.scss +6 -14
- data/stylesheets/private/_str-explode.scss +28 -35
- data/stylesheets/private/_str-implode.scss +10 -18
- data/stylesheets/private/_str-last-index.scss +6 -14
- data/stylesheets/private/_str-lcfirst.scss +5 -13
- data/stylesheets/private/_str-pad.scss +10 -19
- data/stylesheets/private/_str-printf.scss +9 -18
- data/stylesheets/private/_str-repeat.scss +6 -14
- data/stylesheets/private/_str-replace.scss +11 -29
- data/stylesheets/private/_str-reverse.scss +7 -15
- data/stylesheets/private/_str-rot.scss +9 -18
- data/stylesheets/private/_str-shuffle.scss +17 -31
- data/stylesheets/private/_str-starts-with.scss +5 -13
- data/stylesheets/private/_str-trim.scss +5 -13
- data/stylesheets/private/_str-ucfirst.scss +5 -13
- data/stylesheets/private/_str-word-count.scss +6 -14
- data/stylesheets/private/_stringify.scss +13 -22
- data/stylesheets/public/_all.scss +3 -2
- data/stylesheets/public/_char-at.scss +12 -28
- data/stylesheets/public/_levenshtein.scss +3 -18
- data/stylesheets/public/_str-count.scss +8 -23
- data/stylesheets/public/_str-ends-with.scss +2 -17
- data/stylesheets/public/_str-explode.scss +3 -18
- data/stylesheets/public/_str-implode.scss +5 -17
- data/stylesheets/public/_str-last-index.scss +3 -18
- data/stylesheets/public/_str-lcfirst.scss +2 -15
- data/stylesheets/public/_str-pad.scss +8 -22
- data/stylesheets/public/_str-printf.scss +2 -16
- data/stylesheets/public/_str-repeat.scss +3 -18
- data/stylesheets/public/_str-replace.scss +7 -30
- data/stylesheets/public/_str-reverse.scss +2 -15
- data/stylesheets/public/_str-rot.scss +3 -18
- data/stylesheets/public/_str-shuffle.scss +6 -17
- data/stylesheets/public/_str-starts-with.scss +2 -17
- data/stylesheets/public/_str-trim.scss +2 -15
- data/stylesheets/public/_str-ucfirst.scss +2 -15
- data/stylesheets/public/_str-word-count.scss +6 -19
- data/stylesheets/public/_stringify.scss +2 -14
- metadata +45 -39
- checksums.yaml +0 -7
@@ -1,31 +1,15 @@
|
|
1
|
-
/*
|
2
|
-
* Return character from $string at $index
|
3
|
-
* ---
|
4
|
-
* @access public
|
5
|
-
* ---
|
6
|
-
* @since 1.0.0
|
7
|
-
* ---
|
8
|
-
* @param {string} $string - string to check
|
9
|
-
* @param {string} $index - index to inspect
|
10
|
-
* ---
|
11
|
-
* @return {string}
|
12
|
-
*/
|
13
|
-
|
14
1
|
@function char-at($string, $index) {
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
2
|
+
@if type-of($string) != "string" {
|
3
|
+
@error "`char-at` function expecting a string for $string; #{type-of($string)} given.";
|
4
|
+
}
|
5
|
+
|
6
|
+
@if type-of($index) != "number" {
|
7
|
+
@error "`char-at` function expecting a number for $index; #{type-of($index)} given.";
|
8
|
+
}
|
19
9
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
}
|
10
|
+
@if $index < 1 or $index > str-length($string) {
|
11
|
+
@error "Out of bounds $index for `char-at`.";
|
12
|
+
}
|
24
13
|
|
25
|
-
|
26
|
-
|
27
|
-
@return false;
|
28
|
-
}
|
29
|
-
|
30
|
-
@return _ss-char-at($string, $index);
|
31
|
-
}
|
14
|
+
@return _ss-char-at($string, $index);
|
15
|
+
}
|
@@ -1,26 +1,11 @@
|
|
1
|
-
/*
|
2
|
-
* Calculating Levenshtein distance between two strings
|
3
|
-
* ---
|
4
|
-
* @access public
|
5
|
-
* ---
|
6
|
-
* @since 1.0.0
|
7
|
-
* ---
|
8
|
-
* @param {string} $a - first string
|
9
|
-
* @param {string} $b - second string
|
10
|
-
* ---
|
11
|
-
* @return {number}
|
12
|
-
*/
|
13
|
-
|
14
1
|
@function levenshtein($a, $b) {
|
15
2
|
@if type-of($a) != "string" {
|
16
|
-
@
|
17
|
-
@return false;
|
3
|
+
@error "`str-count` function expecting a string for $a; #{type-of($a)} given.";
|
18
4
|
}
|
19
5
|
|
20
6
|
@if type-of($b) != "string" {
|
21
|
-
@
|
22
|
-
@return false;
|
7
|
+
@error "`str-count` function expecting a string for $b; #{type-of($b)} given.";
|
23
8
|
}
|
24
9
|
|
25
10
|
@return _ss-levenshtein($a, $b);
|
26
|
-
}
|
11
|
+
}
|
@@ -1,26 +1,11 @@
|
|
1
|
-
/*
|
2
|
-
* Count the number of occurrences of $needle in $string
|
3
|
-
* ---
|
4
|
-
* @access public
|
5
|
-
* ---
|
6
|
-
* @since 1.0.0
|
7
|
-
* ---
|
8
|
-
* @param {string} $string - string
|
9
|
-
* @param {string} $needle - substring to count in $string
|
10
|
-
* ---
|
11
|
-
* @return {number|false}
|
12
|
-
*/
|
13
|
-
|
14
1
|
@function str-count($string, $needle) {
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
}
|
2
|
+
@if type-of($string) != "string" {
|
3
|
+
@error "`str-count` function expecting a string for $string; #{type-of($string)} given.";
|
4
|
+
}
|
19
5
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
}
|
6
|
+
@if type-of($needle) != "string" {
|
7
|
+
@error "`str-count` function expecting a string for $needle; #{type-of($needle)} given.";
|
8
|
+
}
|
24
9
|
|
25
|
-
|
26
|
-
}
|
10
|
+
@return _ss-str-count($string, $needle);
|
11
|
+
}
|
@@ -1,25 +1,10 @@
|
|
1
|
-
/*
|
2
|
-
* Check whether $string ends with $needle
|
3
|
-
* ---
|
4
|
-
* @access public
|
5
|
-
* ---
|
6
|
-
* @since 1.0.0
|
7
|
-
* ---
|
8
|
-
* @param {string} $string - string to check
|
9
|
-
* @param {string} $needle - substring to check
|
10
|
-
* ---
|
11
|
-
* @return {bool}
|
12
|
-
*/
|
13
|
-
|
14
1
|
@function str-ends-with($string, $needle) {
|
15
2
|
@if type-of($string) != "string" {
|
16
|
-
@
|
17
|
-
@return false;
|
3
|
+
@error "`str-starts-with` function expecting a string for $string; #{type-of($string)} given.";
|
18
4
|
}
|
19
5
|
|
20
6
|
@if type-of($needle) != "string" {
|
21
|
-
@
|
22
|
-
@return false;
|
7
|
+
@error "`str-starts-with` function expecting a string for $needle; #{type-of($needle)} given.";
|
23
8
|
}
|
24
9
|
|
25
10
|
@return _ss-str-ends-with($string, $needle);
|
@@ -1,26 +1,11 @@
|
|
1
|
-
/*
|
2
|
-
* Split $string into several parts using $delimiter
|
3
|
-
* ---
|
4
|
-
* @access public
|
5
|
-
* ---
|
6
|
-
* @since 1.0.0
|
7
|
-
* ---
|
8
|
-
* @param {string} $string - string to split
|
9
|
-
* @param {string} $delimiter - string to use as a delimiter to split $string
|
10
|
-
* ---
|
11
|
-
* @return {list|false}
|
12
|
-
*/
|
13
|
-
|
14
1
|
@function str-explode($string, $delimiter: '') {
|
15
2
|
@if type-of($string) != "string" {
|
16
|
-
@
|
17
|
-
@return false;
|
3
|
+
@error "`explode` function expecting a string; #{type-of($string)} given.";
|
18
4
|
}
|
19
5
|
|
20
6
|
@if type-of($delimiter) != "string" {
|
21
|
-
@
|
22
|
-
@return false;
|
7
|
+
@error "`explode` function expecting a string; #{type-of($delimiter)} given.";
|
23
8
|
}
|
24
9
|
|
25
10
|
@return _ss-str-explode($string, $delimiter);
|
26
|
-
}
|
11
|
+
}
|
@@ -1,19 +1,7 @@
|
|
1
|
-
/*
|
2
|
-
* Implode $list into a string
|
3
|
-
* ---
|
4
|
-
* @access public
|
5
|
-
* ---
|
6
|
-
* @since 1.0.0
|
7
|
-
* ---
|
8
|
-
* @param {list} $list - list to convert to string
|
9
|
-
* ---
|
10
|
-
* @return {string}
|
11
|
-
*/
|
12
|
-
|
13
1
|
@function str-implode($list) {
|
14
|
-
|
15
|
-
|
16
|
-
|
2
|
+
@if type-of($list) != "list" {
|
3
|
+
@error '$list for str-implode must be a list';
|
4
|
+
}
|
17
5
|
|
18
|
-
|
19
|
-
}
|
6
|
+
@return _ss-str-implode($list);
|
7
|
+
}
|
@@ -1,26 +1,11 @@
|
|
1
|
-
/*
|
2
|
-
* Return last index of $needle in $string
|
3
|
-
* ---
|
4
|
-
* @access public
|
5
|
-
* ---
|
6
|
-
* @since 1.0.0
|
7
|
-
* ---
|
8
|
-
* @param {string} $string - string to search in
|
9
|
-
* @param {string} $needle - substring to search for
|
10
|
-
* ---
|
11
|
-
* @return {number | null | false}
|
12
|
-
*/
|
13
|
-
|
14
1
|
@function str-last-index($string, $needle) {
|
15
2
|
@if type-of($string) != "string" {
|
16
|
-
@
|
17
|
-
@return false;
|
3
|
+
@error "`str-last-index` function expecting a string for $string; #{type-of($string)} given.";
|
18
4
|
}
|
19
5
|
|
20
6
|
@if type-of($needle) != "string" {
|
21
|
-
@
|
22
|
-
@return false;
|
7
|
+
@error "`str-last-index` function expecting a string for $needle; #{type-of($needle)} given.";
|
23
8
|
}
|
24
9
|
|
25
10
|
@return _ss-str-last-index($string, $needle);
|
26
|
-
}
|
11
|
+
}
|
@@ -1,20 +1,7 @@
|
|
1
|
-
/*
|
2
|
-
* Lower case first character of $string
|
3
|
-
* ---
|
4
|
-
* @access public
|
5
|
-
* ---
|
6
|
-
* @since 1.0.0
|
7
|
-
* ---
|
8
|
-
* @param {string} $string - string to lower the first character
|
9
|
-
* ---
|
10
|
-
* @return {string}
|
11
|
-
*/
|
12
|
-
|
13
1
|
@function str-lcfirst($string) {
|
14
2
|
@if type-of($string) != "string" {
|
15
|
-
@
|
16
|
-
@return false;
|
3
|
+
@error "`str-lcfirst` function expecting a string for $string; #{type-of($string)} given.";
|
17
4
|
}
|
18
5
|
|
19
6
|
@return _ss-str-lcfirst($string);
|
20
|
-
}
|
7
|
+
}
|
@@ -1,33 +1,19 @@
|
|
1
|
-
/*
|
2
|
-
* Pad $string from $direction with $pad to reach $length characters
|
3
|
-
* ---
|
4
|
-
* @access public
|
5
|
-
* ---
|
6
|
-
* @since 1.0.0
|
7
|
-
* ---
|
8
|
-
* @param {string} $string - string to pad
|
9
|
-
* @param {number} $length - number of characters to go for in returned string
|
10
|
-
* @param {string} $pad - string to use to pad $string
|
11
|
-
* @param {string} $direction - direction left or right for padding
|
12
|
-
* ---
|
13
|
-
* @return {string|false}
|
14
|
-
*/
|
15
|
-
|
16
1
|
@function str-pad($string, $length, $pad: " ", $direction: left) {
|
17
2
|
@if type-of($string) != "string" {
|
18
|
-
@
|
19
|
-
@return false;
|
3
|
+
@error "`str-pad` function expecting a string for $string; #{type-of($string)} given.";
|
20
4
|
}
|
21
5
|
|
22
6
|
@if type-of($pad) != "string" {
|
23
|
-
@
|
24
|
-
@return false;
|
7
|
+
@error "`str-pad` function expecting a string for $pad; #{type-of($pad)} given.";
|
25
8
|
}
|
26
9
|
|
27
10
|
@if type-of($length) != "number" {
|
28
|
-
@
|
29
|
-
|
11
|
+
@error "`str-pad` function expecting a number for $length; #{type-of($length)} given.";
|
12
|
+
}
|
13
|
+
|
14
|
+
@if index(left right, $direction) == null {
|
15
|
+
@error "`str-pad` function expecting either `left` or `right` for $direction: #{$direction} given.";
|
30
16
|
}
|
31
17
|
|
32
18
|
@return _ss-str-pad($string, $length, $pad, $direction);
|
33
|
-
}
|
19
|
+
}
|
@@ -1,21 +1,7 @@
|
|
1
|
-
/*
|
2
|
-
* Replace occurrences of %s in $string by $elements
|
3
|
-
* ---
|
4
|
-
* @access public
|
5
|
-
* ---
|
6
|
-
* @since 1.0.0
|
7
|
-
* ---
|
8
|
-
* @param {string} $string - string to check
|
9
|
-
* @param {arglist} $elements - strings to use for replacements in %s
|
10
|
-
* ---
|
11
|
-
* @return {string | false}
|
12
|
-
*/
|
13
|
-
|
14
1
|
@function str-printf($string, $elements...) {
|
15
2
|
@if type-of($string) != "string" {
|
16
|
-
@
|
17
|
-
@return false;
|
3
|
+
@error "`str-printf` function expecting a string for $string; #{type-of($string)} given.";
|
18
4
|
}
|
19
5
|
|
20
6
|
@return _ss-str-printf($string, $elements...);
|
21
|
-
}
|
7
|
+
}
|
@@ -1,26 +1,11 @@
|
|
1
|
-
/*
|
2
|
-
* Repeat $string $times times
|
3
|
-
* ---
|
4
|
-
* @access public
|
5
|
-
* ---
|
6
|
-
* @since 1.0.0
|
7
|
-
* ---
|
8
|
-
* @param {string} $string - string to repeat
|
9
|
-
* @param {number} $times - number of times to repeat $string
|
10
|
-
* ---
|
11
|
-
* @return {string|false}
|
12
|
-
*/
|
13
|
-
|
14
1
|
@function str-repeat($string, $times) {
|
15
2
|
@if type-of($string) != "string" {
|
16
|
-
@
|
17
|
-
@return false;
|
3
|
+
@error "`str-repeat` function expecting a string for $string; #{type-of($string)} given.";
|
18
4
|
}
|
19
5
|
|
20
6
|
@if type-of($times) != "number" {
|
21
|
-
@
|
22
|
-
@return false;
|
7
|
+
@error "`str-repeat` function expecting a number for $times; #{type-of($times)} given.";
|
23
8
|
}
|
24
9
|
|
25
10
|
@return _ss-str-repeat($string, $times);
|
26
|
-
}
|
11
|
+
}
|
@@ -1,39 +1,16 @@
|
|
1
|
-
|
2
|
-
* Replace $old occurrences by $new in $string respecting $case-sensitive
|
3
|
-
* ---
|
4
|
-
* @access public
|
5
|
-
* ---
|
6
|
-
* @since 1.0.0
|
7
|
-
* ---
|
8
|
-
* @param {string} $string - string
|
9
|
-
* @param {string} $old - old substring to replace by $new
|
10
|
-
* @param {string} $new - new substring to replace $old
|
11
|
-
* @param {bool} $case-sensitive - case-sensitivity
|
12
|
-
* ---
|
13
|
-
* @return {string|false}
|
14
|
-
*/
|
15
|
-
|
16
|
-
@function str-replace($string, $old, $new: '', $case-sensitive: true) {
|
1
|
+
@function str-replace($string, $search, $replace: '') {
|
17
2
|
@if type-of($string) != "string" {
|
18
|
-
@
|
19
|
-
@return false;
|
20
|
-
}
|
21
|
-
|
22
|
-
@if type-of($old) != "string" {
|
23
|
-
@warn "`str-replace` function expecting a string for $old; #{type-of($old)} given.";
|
24
|
-
@return false;
|
3
|
+
@error "`str-replace` function expecting a string for $string; #{type-of($string)} given.";
|
25
4
|
}
|
26
5
|
|
27
|
-
@if type-of($
|
28
|
-
@
|
29
|
-
@return false;
|
6
|
+
@if type-of($search) != "string" {
|
7
|
+
@error "`str-replace` function expecting a string for $search; #{type-of($search)} given.";
|
30
8
|
}
|
31
9
|
|
32
|
-
@if
|
33
|
-
@
|
34
|
-
@return $string;
|
10
|
+
@if type-of($replace) != "string" {
|
11
|
+
@error "`str-replace` function expecting a string for $replace; #{type-of($replace)} given.";
|
35
12
|
}
|
36
13
|
|
37
|
-
@return _ss-str-replace($string, $
|
14
|
+
@return _ss-str-replace($string, $search, $replace);
|
38
15
|
}
|
39
16
|
|
@@ -1,20 +1,7 @@
|
|
1
|
-
/*
|
2
|
-
* Reverse $string
|
3
|
-
* ---
|
4
|
-
* @access public
|
5
|
-
* ---
|
6
|
-
* @since 1.0.0
|
7
|
-
* ---
|
8
|
-
* @param {string} $string - string to reverse
|
9
|
-
* ---
|
10
|
-
* @return {string|false}
|
11
|
-
*/
|
12
|
-
|
13
1
|
@function str-reverse($string) {
|
14
2
|
@if type-of($string) != "string" {
|
15
|
-
@
|
16
|
-
@return false;
|
3
|
+
@error "`str-reverse` function expecting a string for $string; #{type-of($string)} given.";
|
17
4
|
}
|
18
5
|
|
19
6
|
@return _ss-str-reverse($string);
|
20
|
-
}
|
7
|
+
}
|
@@ -1,26 +1,11 @@
|
|
1
|
-
/*
|
2
|
-
* Rotate all characters from the alphabet in $string by $rot positions
|
3
|
-
* ---
|
4
|
-
* @access public
|
5
|
-
* ---
|
6
|
-
* @since 1.0.0
|
7
|
-
* ---
|
8
|
-
* @param {string} $string - string to rotate
|
9
|
-
* @param {number} $rot - number of positions to switch in alphabet
|
10
|
-
* ---
|
11
|
-
* @return {string|false}
|
12
|
-
*/
|
13
|
-
|
14
1
|
@function str-rot($string, $rot: 13) {
|
15
2
|
@if type-of($string) != "string" {
|
16
|
-
@
|
17
|
-
@return false;
|
3
|
+
@error "`str-rot` function expecting a string for $string; #{type-of($string)} given.";
|
18
4
|
}
|
19
5
|
|
20
6
|
@if type-of($rot) != "number" {
|
21
|
-
@
|
22
|
-
@return false;
|
7
|
+
@error "`str-rot` function expecting a number for $rot; #{type-of($rot)} given.";
|
23
8
|
}
|
24
9
|
|
25
10
|
@return _ss-str-rot($string, $rot);
|
26
|
-
}
|
11
|
+
}
|