@quenty/throttle 3.3.1-canary.244.f59530a.0 → 3.5.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 +12 -1
- package/package.json +3 -3
- package/src/Shared/ThrottledFunction.lua +8 -4
package/CHANGELOG.md
CHANGED
|
@@ -3,7 +3,18 @@
|
|
|
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
|
-
|
|
6
|
+
# [3.5.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/throttle@3.4.0...@quenty/throttle@3.5.0) (2022-01-17)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* Add ability to call leading upon the first execution. ([621c8c8](https://github.com/Quenty/NevermoreEngine/commit/621c8c83bd760c7b75714721a87cb042bd64be54))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
# [3.4.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/throttle@3.3.0...@quenty/throttle@3.4.0) (2022-01-07)
|
|
7
18
|
|
|
8
19
|
**Note:** Version bump only for package @quenty/throttle
|
|
9
20
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quenty/throttle",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.5.0",
|
|
4
4
|
"description": "Adds the throttle function to Roblox",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Roblox",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"Quenty"
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@quenty/loader": "3.
|
|
29
|
+
"@quenty/loader": "^3.4.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@quenty/loader": "file:../loader"
|
|
@@ -34,5 +34,5 @@
|
|
|
34
34
|
"publishConfig": {
|
|
35
35
|
"access": "public"
|
|
36
36
|
},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "c094ba8f4e128cdff08919d89de226d3d65247ce"
|
|
38
38
|
}
|
|
@@ -29,14 +29,15 @@ function ThrottledFunction:Call(...)
|
|
|
29
29
|
-- Update the next value to be dispatched
|
|
30
30
|
self._trailingValue = table.pack(...)
|
|
31
31
|
elseif self._nextCallTimeStamp <= tick() then
|
|
32
|
-
if self._callLeading then
|
|
32
|
+
if self._callLeading or self._callLeadingFirstTime then
|
|
33
|
+
self._callLeadingFirstTime = false
|
|
33
34
|
-- Dispatch immediately
|
|
34
35
|
self._nextCallTimeStamp = tick() + self._timeout
|
|
35
36
|
self._func(...)
|
|
36
37
|
elseif self._callTrailing then
|
|
37
38
|
-- Schedule for trailing at exactly timeout
|
|
38
39
|
self._trailingValue = table.pack(...)
|
|
39
|
-
delay(self._timeout, function()
|
|
40
|
+
task.delay(self._timeout, function()
|
|
40
41
|
if self.Destroy then
|
|
41
42
|
self:_dispatch()
|
|
42
43
|
end
|
|
@@ -44,12 +45,13 @@ function ThrottledFunction:Call(...)
|
|
|
44
45
|
else
|
|
45
46
|
error("[ThrottledFunction.Cleanup] - Trailing and leading are both disabled")
|
|
46
47
|
end
|
|
47
|
-
elseif self._callLeading or self._callTrailing then
|
|
48
|
+
elseif self._callLeading or self._callTrailing or self._callLeadingFirstTime then
|
|
49
|
+
self._callLeadingFirstTime = false
|
|
48
50
|
-- As long as either leading or trailing are set to true, we are good
|
|
49
51
|
local remainingTime = self._nextCallTimeStamp - tick()
|
|
50
52
|
self._trailingValue = table.pack(...)
|
|
51
53
|
|
|
52
|
-
delay(remainingTime, function()
|
|
54
|
+
task.delay(remainingTime, function()
|
|
53
55
|
if self.Destroy then
|
|
54
56
|
self:_dispatch()
|
|
55
57
|
end
|
|
@@ -82,6 +84,8 @@ function ThrottledFunction:_configureOrError(throttleConfig)
|
|
|
82
84
|
self._callLeading = value
|
|
83
85
|
elseif key == "trailing" then
|
|
84
86
|
self._callTrailing = value
|
|
87
|
+
elseif key == "leadingFirstTimeOnly" then
|
|
88
|
+
self._callLeadingFirstTime = value
|
|
85
89
|
else
|
|
86
90
|
error(("Bad key %q in config"):format(tostring(key)))
|
|
87
91
|
end
|