@quenty/textfilterutils 10.10.0 → 10.10.1
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 +8 -0
- package/package.json +3 -3
- package/src/Shared/TextFilterUtils.lua +40 -22
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
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
|
+
## [10.10.1](https://github.com/Quenty/NevermoreEngine/compare/@quenty/textfilterutils@10.10.0...@quenty/textfilterutils@10.10.1) (2025-03-21)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @quenty/textfilterutils
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
6
14
|
# [10.10.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/textfilterutils@10.9.0...@quenty/textfilterutils@10.10.0) (2025-02-18)
|
|
7
15
|
|
|
8
16
|
**Note:** Version bump only for package @quenty/textfilterutils
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quenty/textfilterutils",
|
|
3
|
-
"version": "10.10.
|
|
3
|
+
"version": "10.10.1",
|
|
4
4
|
"description": "Utility functions for filtering text",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Roblox",
|
|
@@ -26,10 +26,10 @@
|
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@quenty/loader": "^10.8.0",
|
|
29
|
-
"@quenty/promise": "^10.10.
|
|
29
|
+
"@quenty/promise": "^10.10.1"
|
|
30
30
|
},
|
|
31
31
|
"publishConfig": {
|
|
32
32
|
"access": "public"
|
|
33
33
|
},
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "6b7c3e15e60cdb185986207b574e2b5591261e7a"
|
|
35
35
|
}
|
|
@@ -30,7 +30,11 @@ local TextFilterUtils = {}
|
|
|
30
30
|
@param textFilterContext TextFilterContext
|
|
31
31
|
@return Promise<string>
|
|
32
32
|
]=]
|
|
33
|
-
function TextFilterUtils.promiseNonChatStringForBroadcast(
|
|
33
|
+
function TextFilterUtils.promiseNonChatStringForBroadcast(
|
|
34
|
+
text: string,
|
|
35
|
+
fromUserId: number,
|
|
36
|
+
textFilterContext: Enum.TextFilterContext
|
|
37
|
+
)
|
|
34
38
|
assert(type(text) == "string", "Bad text")
|
|
35
39
|
assert(type(fromUserId) == "number", "Bad fromUserId")
|
|
36
40
|
assert(typeof(textFilterContext) == "EnumItem", "Bad textFilterContext")
|
|
@@ -39,7 +43,8 @@ function TextFilterUtils.promiseNonChatStringForBroadcast(text, fromUserId, text
|
|
|
39
43
|
TextFilterUtils.getNonChatStringForBroadcastAsync,
|
|
40
44
|
text,
|
|
41
45
|
fromUserId,
|
|
42
|
-
textFilterContext
|
|
46
|
+
textFilterContext
|
|
47
|
+
)
|
|
43
48
|
end
|
|
44
49
|
|
|
45
50
|
--[=[
|
|
@@ -51,7 +56,7 @@ end
|
|
|
51
56
|
@param text string
|
|
52
57
|
@return Promise<string>
|
|
53
58
|
]=]
|
|
54
|
-
function TextFilterUtils.promiseLegacyChatFilter(playerFrom, text)
|
|
59
|
+
function TextFilterUtils.promiseLegacyChatFilter(playerFrom: Player, text: string)
|
|
55
60
|
assert(typeof(playerFrom) == "Instance" and playerFrom:IsA("Player"), "Bad playerFrom")
|
|
56
61
|
assert(type(text) == "string", "Bad text")
|
|
57
62
|
|
|
@@ -81,7 +86,12 @@ end
|
|
|
81
86
|
@param textFilterContext TextFilterContext
|
|
82
87
|
@return Promise<string>
|
|
83
88
|
]=]
|
|
84
|
-
function TextFilterUtils.promiseNonChatStringForUserAsync(
|
|
89
|
+
function TextFilterUtils.promiseNonChatStringForUserAsync(
|
|
90
|
+
text: string,
|
|
91
|
+
fromUserId: number,
|
|
92
|
+
toUserId: number,
|
|
93
|
+
textFilterContext: Enum.TextFilterContext
|
|
94
|
+
)
|
|
85
95
|
assert(type(text) == "string", "Bad text")
|
|
86
96
|
assert(type(fromUserId) == "number", "Bad fromUserId")
|
|
87
97
|
assert(type(toUserId) == "number", "Bad toUserId")
|
|
@@ -92,7 +102,8 @@ function TextFilterUtils.promiseNonChatStringForUserAsync(text, fromUserId, toUs
|
|
|
92
102
|
text,
|
|
93
103
|
fromUserId,
|
|
94
104
|
toUserId,
|
|
95
|
-
textFilterContext
|
|
105
|
+
textFilterContext
|
|
106
|
+
)
|
|
96
107
|
end
|
|
97
108
|
|
|
98
109
|
--[=[
|
|
@@ -103,7 +114,11 @@ end
|
|
|
103
114
|
@param textFilterContext TextFilterContext
|
|
104
115
|
@return Promise<string>
|
|
105
116
|
]=]
|
|
106
|
-
function TextFilterUtils.getNonChatStringForBroadcastAsync(
|
|
117
|
+
function TextFilterUtils.getNonChatStringForBroadcastAsync(
|
|
118
|
+
text: string,
|
|
119
|
+
fromUserId: number,
|
|
120
|
+
textFilterContext: Enum.TextFilterContext
|
|
121
|
+
)
|
|
107
122
|
assert(type(text) == "string", "Bad text")
|
|
108
123
|
assert(type(fromUserId) == "number", "Bad fromUserId")
|
|
109
124
|
assert(typeof(textFilterContext) == "EnumItem", "Bad textFilterContext")
|
|
@@ -134,7 +149,12 @@ end
|
|
|
134
149
|
@param textFilterContext TextFilterContext
|
|
135
150
|
@return Promise<string>
|
|
136
151
|
]=]
|
|
137
|
-
function TextFilterUtils.getNonChatStringForUserAsync(
|
|
152
|
+
function TextFilterUtils.getNonChatStringForUserAsync(
|
|
153
|
+
text: string,
|
|
154
|
+
fromUserId: number,
|
|
155
|
+
toUserId: number,
|
|
156
|
+
textFilterContext: Enum.TextFilterContext
|
|
157
|
+
)
|
|
138
158
|
assert(type(text) == "string", "Bad text")
|
|
139
159
|
assert(type(fromUserId) == "number", "Bad fromUserId")
|
|
140
160
|
assert(type(toUserId) == "number", "Bad toUserId")
|
|
@@ -158,7 +178,7 @@ function TextFilterUtils.getNonChatStringForUserAsync(text, fromUserId, toUserId
|
|
|
158
178
|
end
|
|
159
179
|
|
|
160
180
|
function TextFilterUtils._promiseTextResult(getResult, ...)
|
|
161
|
-
local args = {...}
|
|
181
|
+
local args = { ... }
|
|
162
182
|
|
|
163
183
|
local promise = Promise.spawn(function(resolve, reject)
|
|
164
184
|
local text, err = getResult(unpack(args))
|
|
@@ -170,7 +190,7 @@ function TextFilterUtils._promiseTextResult(getResult, ...)
|
|
|
170
190
|
return reject("Bad text result")
|
|
171
191
|
end
|
|
172
192
|
|
|
173
|
-
resolve(text)
|
|
193
|
+
return resolve(text)
|
|
174
194
|
end)
|
|
175
195
|
|
|
176
196
|
return promise
|
|
@@ -187,10 +207,10 @@ function TextFilterUtils.hasNonFilteredText(text: string): boolean
|
|
|
187
207
|
end
|
|
188
208
|
|
|
189
209
|
local WHITESPACE = {
|
|
190
|
-
["\r"] = true
|
|
191
|
-
["\n"] = true
|
|
192
|
-
[" "] = true
|
|
193
|
-
["\t"] = true
|
|
210
|
+
["\r"] = true,
|
|
211
|
+
["\n"] = true,
|
|
212
|
+
[" "] = true,
|
|
213
|
+
["\t"] = true,
|
|
194
214
|
}
|
|
195
215
|
|
|
196
216
|
--[=[
|
|
@@ -199,14 +219,14 @@ local WHITESPACE = {
|
|
|
199
219
|
@param text string
|
|
200
220
|
@return number
|
|
201
221
|
]=]
|
|
202
|
-
function TextFilterUtils.getProportionFiltered(text: string)
|
|
222
|
+
function TextFilterUtils.getProportionFiltered(text: string): number
|
|
203
223
|
local filteredChars, unfilteredChars = TextFilterUtils.countFilteredCharacters(text)
|
|
204
224
|
local total = unfilteredChars + filteredChars
|
|
205
225
|
if total == 0 then
|
|
206
226
|
return 0
|
|
207
227
|
end
|
|
208
228
|
|
|
209
|
-
return filteredChars/total
|
|
229
|
+
return filteredChars / total
|
|
210
230
|
end
|
|
211
231
|
|
|
212
232
|
--[=[
|
|
@@ -217,11 +237,11 @@ end
|
|
|
217
237
|
@return number -- Unfiltered characters
|
|
218
238
|
@return number -- White space characters
|
|
219
239
|
]=]
|
|
220
|
-
function TextFilterUtils.countFilteredCharacters(text: string)
|
|
240
|
+
function TextFilterUtils.countFilteredCharacters(text: string): (number, number, number)
|
|
221
241
|
local filteredChars = 0
|
|
222
242
|
local unfilteredChars = 0
|
|
223
243
|
local whitespaceCharacters = 0
|
|
224
|
-
for i=1, #text do
|
|
244
|
+
for i = 1, #text do
|
|
225
245
|
local textChar = string.sub(text, i, i)
|
|
226
246
|
if textChar == "#" then
|
|
227
247
|
filteredChars = filteredChars + 1
|
|
@@ -235,15 +255,14 @@ function TextFilterUtils.countFilteredCharacters(text: string)
|
|
|
235
255
|
return filteredChars, unfilteredChars, whitespaceCharacters
|
|
236
256
|
end
|
|
237
257
|
|
|
238
|
-
|
|
239
258
|
--[=[
|
|
240
259
|
Adds in new lines and whitespace to the text
|
|
241
260
|
|
|
242
261
|
@param text string
|
|
243
262
|
@param filteredText string
|
|
244
|
-
@return
|
|
263
|
+
@return string
|
|
245
264
|
]=]
|
|
246
|
-
function TextFilterUtils.addBackInNewLinesAndWhitespace(text, filteredText)
|
|
265
|
+
function TextFilterUtils.addBackInNewLinesAndWhitespace(text: string, filteredText: string): string
|
|
247
266
|
assert(type(text) == "string", "Bad text")
|
|
248
267
|
assert(type(filteredText) == "string", "Bad filteredText")
|
|
249
268
|
|
|
@@ -296,5 +315,4 @@ function TextFilterUtils.addBackInNewLinesAndWhitespace(text, filteredText)
|
|
|
296
315
|
return newString
|
|
297
316
|
end
|
|
298
317
|
|
|
299
|
-
|
|
300
|
-
return TextFilterUtils
|
|
318
|
+
return TextFilterUtils
|