@quenty/loader 7.1.0 → 7.1.1-canary.438.5c31ea4.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
+ ## [7.1.1-canary.438.5c31ea4.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/loader@7.1.0...@quenty/loader@7.1.1-canary.438.5c31ea4.0) (2024-01-08)
7
+
8
+
9
+ ### Features
10
+
11
+ * Add Queue:GetCount() ([2e6ee3c](https://github.com/Quenty/NevermoreEngine/commit/2e6ee3cf54df42aebc84b192f2156afddedfd75d))
12
+
13
+
14
+ ### Performance Improvements
15
+
16
+ * Cache loader require values ([bab28c9](https://github.com/Quenty/NevermoreEngine/commit/bab28c969a91d0eb57086eb860be648ac36378e3))
17
+
18
+
19
+
20
+
21
+
6
22
  # [7.1.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/loader@7.0.0...@quenty/loader@7.1.0) (2023-12-14)
7
23
 
8
24
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quenty/loader",
3
- "version": "7.1.0",
3
+ "version": "7.1.1-canary.438.5c31ea4.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": "2c2dbbc0cb2fbb46b4f3270c559c63890fe18b26"
29
+ "gitHead": "5c31ea4ac189fb841386398a54bdea773e497420"
30
30
  }
package/src/Loader.lua CHANGED
@@ -12,6 +12,7 @@ Loader.__index = Loader
12
12
  function Loader.new(script)
13
13
  return setmetatable({
14
14
  _script = script;
15
+ _cache = {}
15
16
  }, Loader)
16
17
  end
17
18
 
@@ -26,11 +27,20 @@ end
26
27
 
27
28
  function Loader:__call(value)
28
29
  if type(value) == "string" then
30
+ local cache = rawget(self, "_cache")
31
+ if cache[value] ~= nil then
32
+ return cache[value]
33
+ end
34
+
29
35
  local object = self._script.Parent[value]
30
36
  if object:IsA("ObjectValue") then
31
- return require(waitForValue(object))
37
+ local result = require(waitForValue(object))
38
+ cache[value] = result
39
+ return result
32
40
  else
33
- return require(object)
41
+ local result = require(object)
42
+ cache[value] = result
43
+ return result
34
44
  end
35
45
  else
36
46
  return require(value)
package/src/Queue.lua CHANGED
@@ -1,7 +1,18 @@
1
1
  --[=[
2
- Private queue class for loading system.
2
+ Queue class with better performance characteristics than table.remove()
3
+
4
+ ```lua
5
+ local queue = Queue.new()
6
+ queue:PushRight("a")
7
+ queue:PushRight("b")
8
+ queue:PushRight("c")
9
+
10
+ while not queue:IsEmpty() do
11
+ local entry = queue:PopLeft()
12
+ print(entry) --> a, b, c
13
+ end
14
+ ```
3
15
 
4
- @private
5
16
  @class Queue
6
17
  ]=]
7
18
 
@@ -20,6 +31,23 @@ function Queue.new()
20
31
  }, Queue)
21
32
  end
22
33
 
34
+ --[=[
35
+ Gets the queues length
36
+ @return number
37
+ ]=]
38
+ function Queue:__len()
39
+ return self._last + 1 - self._first
40
+ end
41
+
42
+ --[=[
43
+ Returns the count of the queue
44
+
45
+ @return number
46
+ ]=]
47
+ function Queue:GetCount()
48
+ return self._last + 1 - self._first
49
+ end
50
+
23
51
  --[=[
24
52
  Pushes an entry to the left of the queue
25
53
  @param value T
@@ -78,4 +106,4 @@ function Queue:IsEmpty()
78
106
  return self._first > self._last
79
107
  end
80
108
 
81
- return Queue
109
+ return Queue