mirror of
https://github.com/centau/vide.git
synced 2026-08-20 14:41:37 +00:00
Add untrack()
This commit is contained in:
parent
0105e33fac
commit
6700e1b1f6
6 changed files with 107 additions and 2 deletions
16
src/untrack.luau
Normal file
16
src/untrack.luau
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
if not game then script = require "test/relative-string" end
|
||||
|
||||
local graph = require(script.Parent.graph)
|
||||
type Node<T> = graph.Node<T>
|
||||
local refs = graph.refs
|
||||
|
||||
local function untrack<T>(source: () -> T): T
|
||||
local initial = #refs
|
||||
local value = source()
|
||||
for i = initial, #refs do
|
||||
refs[i] = nil
|
||||
end
|
||||
return value
|
||||
end
|
||||
|
||||
return untrack
|
||||
Loading…
Add table
Add a link
Reference in a new issue