Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change Fusion.doCleanup to no longer be variadic #333

Merged
merged 3 commits into from
May 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/api-reference/memory/members/docleanup.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

```Lua
function Fusion.doCleanup(
...: unknown
task: unknown
): ()
```

Expand All @@ -30,7 +30,7 @@ Attempts to destroy all arguments based on their runtime type.
## Parameters

<h3 markdown>
...
task
<span class="fusiondoc-api-type">
: unknown
</span>
Expand Down
12 changes: 2 additions & 10 deletions src/Memory/doCleanup.luau
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ local task = nil -- Disable usage of Roblox's task scheduler
- an array - `cleanup` will be called on each item
]]

local function doCleanupOne(
local function doCleanup(
task: unknown
)
local taskType = typeof(task)
Expand Down Expand Up @@ -53,19 +53,11 @@ local function doCleanupOne(
-- It is important to iterate backwards through the table, since
-- objects are added in order of construction.
for index = #task, 1, -1 do
doCleanupOne(task[index])
doCleanup(task[index])
task[index] = nil
end
end
end
end

local function doCleanup(
...: unknown
)
for index = 1, select("#", ...) do
doCleanupOne(select(index, ...))
end
end

return doCleanup
3 changes: 1 addition & 2 deletions src/Types.luau
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ export type Fusion = {
version: Version,
Contextual: ContextualConstructor,

doCleanup: (...unknown) -> (),
doCleanup: (unknown) -> (),
scoped: ScopedConstructor,
deriveScope: <T>(existing: Scope<T>) -> Scope<T>,

Expand All @@ -271,7 +271,6 @@ export type Fusion = {
Attribute: (attributeName: string) -> SpecialKey,
AttributeChange: (attributeName: string) -> SpecialKey,
AttributeOut: (attributeName: string) -> SpecialKey,

}

return nil
14 changes: 0 additions & 14 deletions test/Spec/Memory/doCleanup.spec.luau
Original file line number Diff line number Diff line change
Expand Up @@ -132,18 +132,4 @@ return function()
expect(runs[2]).to.equal(2)
expect(runs[3]).to.equal(1)
end)

it("should clean up variadic arguments", function()
local expect = getfenv().expect

local numRuns = 0

local function doRun()
numRuns += 1
end

doCleanup(doRun, doRun, doRun)

expect(numRuns).to.equal(3)
end)
end