@quenty/loader 10.5.0 → 10.6.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 CHANGED
@@ -3,6 +3,22 @@
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.6.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/loader@10.5.0...@quenty/loader@10.6.0) (2024-10-04)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * Maid:Add reports the correct method name in error ([3d31b0d](https://github.com/Quenty/NevermoreEngine/commit/3d31b0d5c6aa7c3bf280e102b1b37a3219ef2dba))
12
+
13
+
14
+ ### Performance Improvements
15
+
16
+ * Order maid tasks by most common access scenarios and reduce query of typeof() calls ([2f6c713](https://github.com/Quenty/NevermoreEngine/commit/2f6c7130f462188e77ee4789315e5692302280eb))
17
+
18
+
19
+
20
+
21
+
6
22
  # [10.5.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/loader@10.4.0...@quenty/loader@10.5.0) (2024-09-25)
7
23
 
8
24
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quenty/loader",
3
- "version": "10.5.0",
3
+ "version": "10.6.0",
4
4
  "description": "A simple module loader for Roblox",
5
5
  "keywords": [
6
6
  "Roblox",
@@ -26,5 +26,5 @@
26
26
  "publishConfig": {
27
27
  "access": "public"
28
28
  },
29
- "gitHead": "41715b15e2b48b2d22ff4f5277a8d4b7a0d32ef3"
29
+ "gitHead": "035abfa088c854a73e1c65b350267eaa17669646"
30
30
  }
package/src/Maid.lua CHANGED
@@ -103,34 +103,39 @@ function Maid:__newindex(index, newTask)
103
103
  end
104
104
 
105
105
  local tasks = self._tasks
106
- local oldTask = tasks[index]
106
+ local job = tasks[index]
107
107
 
108
- if oldTask == newTask then
108
+ if job == newTask then
109
109
  return
110
110
  end
111
111
 
112
112
  tasks[index] = newTask
113
113
 
114
- if oldTask then
115
- if type(oldTask) == "function" then
116
- oldTask()
117
- elseif type(oldTask) == "thread" then
114
+ if job then
115
+ local jobType = typeof(job)
116
+ if jobType == "function" then
117
+ job()
118
+ elseif jobType == "table" then
119
+ if type(job.Destroy) == "function" then
120
+ job:Destroy()
121
+ end
122
+ elseif jobType == "Instance" then
123
+ job:Destroy()
124
+ elseif jobType == "thread" then
118
125
  local cancelled
119
- if coroutine.running() ~= oldTask then
126
+ if coroutine.running() ~= job then
120
127
  cancelled = pcall(function()
121
- task.cancel(oldTask)
128
+ task.cancel(job)
122
129
  end)
123
130
  end
124
131
 
125
132
  if not cancelled then
126
133
  task.defer(function()
127
- task.cancel(oldTask)
134
+ task.cancel(job)
128
135
  end)
129
136
  end
130
- elseif typeof(oldTask) == "RBXScriptConnection" then
131
- oldTask:Disconnect()
132
- elseif oldTask.Destroy then
133
- oldTask:Destroy()
137
+ elseif jobType == "RBXScriptConnection" then
138
+ job:Disconnect()
134
139
  end
135
140
  end
136
141
  end
@@ -149,7 +154,7 @@ function Maid:Add(task)
149
154
  self[#self._tasks+1] = task
150
155
 
151
156
  if type(task) == "table" and (not task.Destroy) then
152
- warn("[Maid.GiveTask] - Gave table task without .Destroy\n\n" .. debug.traceback())
157
+ warn("[Maid.Add] - Gave table task without .Destroy\n\n" .. debug.traceback())
153
158
  end
154
159
 
155
160
  return task
@@ -229,9 +234,14 @@ function Maid:DoCleaning()
229
234
  local index, job = next(tasks)
230
235
  while job ~= nil do
231
236
  tasks[index] = nil
232
- if type(job) == "function" then
237
+ local jobType = typeof(job)
238
+ if jobType == "function" then
233
239
  job()
234
- elseif type(job) == "thread" then
240
+ elseif jobType == "table" and type(job.Destroy) == "function" then
241
+ job:Destroy()
242
+ elseif jobType == "Instance" then
243
+ job:Destroy()
244
+ elseif jobType == "thread" then
235
245
  local cancelled
236
246
  if coroutine.running() ~= job then
237
247
  cancelled = pcall(function()
@@ -245,10 +255,8 @@ function Maid:DoCleaning()
245
255
  task.cancel(toCancel)
246
256
  end)
247
257
  end
248
- elseif typeof(job) == "RBXScriptConnection" then
258
+ elseif jobType == "RBXScriptConnection" then
249
259
  job:Disconnect()
250
- elseif job.Destroy then
251
- job:Destroy()
252
260
  end
253
261
  index, job = next(tasks)
254
262
  end