Add untrack()

This commit is contained in:
Aaron Smith 2023-08-22 12:12:03 +01:00
parent 0105e33fac
commit 6700e1b1f6
6 changed files with 107 additions and 2 deletions

16
src/untrack.luau Normal file
View 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