@quenty/string 2.2.1 → 2.2.2-canary.256.8cd6f5a.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.
- package/CHANGELOG.md +11 -0
- package/package.json +2 -2
- package/src/Shared/String.lua +15 -15
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [2.2.2-canary.256.8cd6f5a.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/string@2.2.1...@quenty/string@2.2.2-canary.256.8cd6f5a.0) (2022-03-27)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* Add types to core libraries ([6e685b3](https://github.com/Quenty/NevermoreEngine/commit/6e685b3cfbcd3816d15962769a4310a1ec57fb7e))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
## [2.2.1](https://github.com/Quenty/NevermoreEngine/compare/@quenty/string@2.2.0...@quenty/string@2.2.1) (2021-12-30)
|
|
7
18
|
|
|
8
19
|
**Note:** Version bump only for package @quenty/string
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quenty/string",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.2-canary.256.8cd6f5a.0",
|
|
4
4
|
"description": "This module provides utility functions for strings",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Roblox",
|
|
@@ -28,5 +28,5 @@
|
|
|
28
28
|
"publishConfig": {
|
|
29
29
|
"access": "public"
|
|
30
30
|
},
|
|
31
|
-
"gitHead": "
|
|
31
|
+
"gitHead": "8cd6f5a870e3e400eb53d147873062111e6ae8ed"
|
|
32
32
|
}
|
package/src/Shared/String.lua
CHANGED
|
@@ -12,7 +12,7 @@ local String = {}
|
|
|
12
12
|
@param pattern string? -- Defaults to whitespace
|
|
13
13
|
@return string
|
|
14
14
|
]=]
|
|
15
|
-
function String.trim(str, pattern)
|
|
15
|
+
function String.trim(str: string, pattern: string?): string
|
|
16
16
|
if not pattern then
|
|
17
17
|
return str:match("^%s*(.-)%s*$")
|
|
18
18
|
else
|
|
@@ -28,7 +28,7 @@ end
|
|
|
28
28
|
@param str string
|
|
29
29
|
@return string
|
|
30
30
|
]=]
|
|
31
|
-
function String.toCamelCase(str)
|
|
31
|
+
function String.toCamelCase(str: string): string
|
|
32
32
|
str = str:lower()
|
|
33
33
|
str = str:gsub("[ _](%a)", string.upper)
|
|
34
34
|
str = str:gsub("^%a", string.upper)
|
|
@@ -43,7 +43,7 @@ end
|
|
|
43
43
|
@param str string
|
|
44
44
|
@return string
|
|
45
45
|
]=]
|
|
46
|
-
function String.uppercaseFirstLetter(str)
|
|
46
|
+
function String.uppercaseFirstLetter(str: string): string
|
|
47
47
|
return str:gsub("^%a", string.upper)
|
|
48
48
|
end
|
|
49
49
|
|
|
@@ -52,7 +52,7 @@ end
|
|
|
52
52
|
@param str string
|
|
53
53
|
@return string
|
|
54
54
|
]=]
|
|
55
|
-
function String.toLowerCamelCase(str)
|
|
55
|
+
function String.toLowerCamelCase(str: string): string
|
|
56
56
|
str = str:lower()
|
|
57
57
|
str = str:gsub("[ _](%a)", string.upper)
|
|
58
58
|
str = str:gsub("^%a", string.lower)
|
|
@@ -66,7 +66,7 @@ end
|
|
|
66
66
|
@param str string
|
|
67
67
|
@return string
|
|
68
68
|
]=]
|
|
69
|
-
function String.toPrivateCase(str)
|
|
69
|
+
function String.toPrivateCase(str: string): string
|
|
70
70
|
return "_" .. str:sub(1, 1):lower() .. str:sub(2, #str)
|
|
71
71
|
end
|
|
72
72
|
|
|
@@ -76,7 +76,7 @@ end
|
|
|
76
76
|
@param pattern string? -- Defaults to whitespace
|
|
77
77
|
@return string
|
|
78
78
|
]=]
|
|
79
|
-
function String.trimFront(str, pattern)
|
|
79
|
+
function String.trimFront(str: string, pattern: string?): string
|
|
80
80
|
pattern = pattern or "%s";
|
|
81
81
|
return (str:gsub("^"..pattern.."*(.-)"..pattern.."*", "%1"))
|
|
82
82
|
end
|
|
@@ -92,7 +92,7 @@ end
|
|
|
92
92
|
@param char string
|
|
93
93
|
@return number
|
|
94
94
|
]=]
|
|
95
|
-
function String.checkNumOfCharacterInString(str, char)
|
|
95
|
+
function String.checkNumOfCharacterInString(str: string, char: string): number
|
|
96
96
|
local count = 0
|
|
97
97
|
for _ in string.gmatch(str, char) do
|
|
98
98
|
count = count + 1
|
|
@@ -105,7 +105,7 @@ end
|
|
|
105
105
|
@param str string
|
|
106
106
|
@return boolean
|
|
107
107
|
]=]
|
|
108
|
-
function String.isEmptyOrWhitespaceOrNil(str)
|
|
108
|
+
function String.isEmptyOrWhitespaceOrNil(str: string): boolean
|
|
109
109
|
return type(str) ~= "string" or str == "" or String.isWhitespace(str)
|
|
110
110
|
end
|
|
111
111
|
|
|
@@ -114,7 +114,7 @@ end
|
|
|
114
114
|
@param str string
|
|
115
115
|
@return boolean
|
|
116
116
|
]=]
|
|
117
|
-
function String.isWhitespace(str)
|
|
117
|
+
function String.isWhitespace(str: string): boolean
|
|
118
118
|
return string.match(str, "[%s]+") == str
|
|
119
119
|
end
|
|
120
120
|
|
|
@@ -124,7 +124,7 @@ end
|
|
|
124
124
|
@param characterLimit number
|
|
125
125
|
@return string
|
|
126
126
|
]=]
|
|
127
|
-
function String.elipseLimit(str, characterLimit)
|
|
127
|
+
function String.elipseLimit(str: string, characterLimit: number): string
|
|
128
128
|
if #str > characterLimit then
|
|
129
129
|
str = str:sub(1, characterLimit-3).."..."
|
|
130
130
|
end
|
|
@@ -137,7 +137,7 @@ end
|
|
|
137
137
|
@param prefix string
|
|
138
138
|
@return string
|
|
139
139
|
]=]
|
|
140
|
-
function String.removePrefix(str, prefix)
|
|
140
|
+
function String.removePrefix(str: string, prefix: string): string
|
|
141
141
|
if str:sub(1, #prefix) == prefix then
|
|
142
142
|
return str:sub(#prefix + 1)
|
|
143
143
|
else
|
|
@@ -151,7 +151,7 @@ end
|
|
|
151
151
|
@param postfix string
|
|
152
152
|
@return string
|
|
153
153
|
]=]
|
|
154
|
-
function String.removePostfix(str, postfix)
|
|
154
|
+
function String.removePostfix(str: string, postfix: string): string
|
|
155
155
|
if str:sub(-#postfix) == postfix then
|
|
156
156
|
return str:sub(1, -#(postfix) - 1)
|
|
157
157
|
else
|
|
@@ -165,7 +165,7 @@ end
|
|
|
165
165
|
@param postfix string
|
|
166
166
|
@return boolean
|
|
167
167
|
]=]
|
|
168
|
-
function String.endsWith(str, postfix)
|
|
168
|
+
function String.endsWith(str: string, postfix: string): boolean
|
|
169
169
|
return str:sub(-#postfix) == postfix
|
|
170
170
|
end
|
|
171
171
|
|
|
@@ -175,7 +175,7 @@ end
|
|
|
175
175
|
@param prefix string
|
|
176
176
|
@return boolean
|
|
177
177
|
]=]
|
|
178
|
-
function String.startsWith(str, prefix)
|
|
178
|
+
function String.startsWith(str: string, prefix: string): boolean
|
|
179
179
|
return str:sub(1, #prefix) == prefix
|
|
180
180
|
end
|
|
181
181
|
|
|
@@ -184,7 +184,7 @@ end
|
|
|
184
184
|
@param number string | number
|
|
185
185
|
@return string
|
|
186
186
|
]=]
|
|
187
|
-
function String.addCommas(number)
|
|
187
|
+
function String.addCommas(number: string | number): string
|
|
188
188
|
if type(number) == "number" then
|
|
189
189
|
number = tostring(number)
|
|
190
190
|
end
|