@quenty/throttle 10.9.0 → 10.9.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 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
+ ## [10.9.1](https://github.com/Quenty/NevermoreEngine/compare/@quenty/throttle@10.9.0...@quenty/throttle@10.9.1) (2025-04-05)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * Add types to packages ([2374fb2](https://github.com/Quenty/NevermoreEngine/commit/2374fb2b043cfbe0e9b507b3316eec46a4e353a0))
12
+
13
+
14
+
15
+
16
+
6
17
  # [10.9.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/throttle@10.8.1...@quenty/throttle@10.9.0) (2025-02-18)
7
18
 
8
19
  **Note:** Version bump only for package @quenty/throttle
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quenty/throttle",
3
- "version": "10.9.0",
3
+ "version": "10.9.1",
4
4
  "description": "Adds the throttle function to Roblox",
5
5
  "keywords": [
6
6
  "Roblox",
@@ -26,7 +26,8 @@
26
26
  "Quenty"
27
27
  ],
28
28
  "dependencies": {
29
- "@quenty/loader": "^10.8.0"
29
+ "@quenty/loader": "^10.8.1",
30
+ "@quenty/typeutils": "^1.0.1"
30
31
  },
31
32
  "devDependencies": {
32
33
  "@quenty/loader": "file:../loader"
@@ -34,5 +35,5 @@
34
35
  "publishConfig": {
35
36
  "access": "public"
36
37
  },
37
- "gitHead": "184a407d8d7366c39009444c3c9a7023cb176471"
38
+ "gitHead": "78c3ac0ab08dd18085b6e6e6e4f745e76ed99f68"
38
39
  }
@@ -3,11 +3,17 @@
3
3
  @class ThrottledFunction
4
4
  ]=]
5
5
 
6
+ export type ThrottleConfig = {
7
+ leading: boolean?,
8
+ trailing: boolean?,
9
+ leadingFirstTimeOnly: boolean?,
10
+ }
11
+
6
12
  local ThrottledFunction = {}
7
13
  ThrottledFunction.ClassName = "ThrottledFunction"
8
14
  ThrottledFunction.__index = ThrottledFunction
9
15
 
10
- function ThrottledFunction.new(timeoutInSeconds, func, config)
16
+ function ThrottledFunction.new(timeoutInSeconds: number, func, config: ThrottleConfig)
11
17
  local self = setmetatable({}, ThrottledFunction)
12
18
 
13
19
  self._nextCallTimeStamp = 0
@@ -24,7 +30,7 @@ function ThrottledFunction.new(timeoutInSeconds, func, config)
24
30
  return self
25
31
  end
26
32
 
27
- function ThrottledFunction:Call(...)
33
+ function ThrottledFunction:Call<T...>(...: T...)
28
34
  if self._trailingValue then
29
35
  -- Update the next value to be dispatched
30
36
  self._trailingValue = table.pack(...)
@@ -72,14 +78,14 @@ function ThrottledFunction:_dispatch()
72
78
  end
73
79
  end
74
80
 
75
- function ThrottledFunction:_configureOrError(throttleConfig)
81
+ function ThrottledFunction:_configureOrError(throttleConfig: ThrottleConfig)
76
82
  if throttleConfig == nil then
77
83
  return
78
84
  end
79
85
 
80
86
  assert(type(throttleConfig) == "table", "Bad throttleConfig")
81
87
 
82
- for key, value in pairs(throttleConfig) do
88
+ for key, value in throttleConfig do
83
89
  assert(type(value) == "boolean", "Bad throttleConfig entry")
84
90
 
85
91
  if key == "leading" then
@@ -1,3 +1,4 @@
1
+ --!strict
1
2
  --[=[
2
3
  Debounce a existing function by timeout
3
4
 
@@ -7,6 +8,9 @@
7
8
  local require = require(script.Parent.loader).load(script)
8
9
 
9
10
  local ThrottledFunction = require("ThrottledFunction")
11
+ local TypeUtils = require("TypeUtils")
12
+
13
+ export type ThrottleConfig = ThrottledFunction.ThrottleConfig
10
14
 
11
15
  --[=[
12
16
  Provides a debounce function call on an operation.
@@ -18,14 +22,14 @@ local ThrottledFunction = require("ThrottledFunction")
18
22
  @param throttleConfig? { leading = true; trailing = true; }
19
23
  @return function
20
24
  ]=]
21
- local function throttle(timeoutInSeconds, func, throttleConfig)
25
+ local function throttle<T...>(timeoutInSeconds: number, func: (T...) -> ...any, throttleConfig: ThrottledFunction.ThrottleConfig): (T...) -> ()
22
26
  assert(type(timeoutInSeconds) == "number", "timeoutInSeconds is not a number")
23
27
  assert(type(func) == "function", "func is not a function")
24
28
 
25
29
  local throttled = ThrottledFunction.new(timeoutInSeconds, func, throttleConfig)
26
30
 
27
- return function(...)
28
- throttled:Call(...)
31
+ return function(...: T...)
32
+ throttled:Call(TypeUtils.anyValue(...))
29
33
  end
30
34
  end
31
35