From 999c912580557486a50e79957410a214e8bddd3e Mon Sep 17 00:00:00 2001 From: IntegralsGetYouArea <109925156+IntegralsGetYouArea@users.noreply.github.com> Date: Mon, 28 Aug 2023 15:39:09 -0400 Subject: [PATCH 1/6] fix filter not filtering --- lib/init.luau | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/lib/init.luau b/lib/init.luau index 7dc5edf..f7d428c 100644 --- a/lib/init.luau +++ b/lib/init.luau @@ -94,17 +94,18 @@ function Net:__iter(filter: (k: number, v: any) -> (number?, any?)?, returnFilte local snapshot = self._bridge:snapshot() local i = 0 - -- Filters take in a key-value pair, the filter can remove this pair by returning ``k, nil``. - if filter then - for k, v in snapshot do - v = filter(v) - - if v then - snapshot[k] = v - else - table.remove(snapshot, k) + -- Filters take in a key-value pair, the filter can remove this pair by not adding it to the filtered_snapshot array. + do + local filtered_snapshot = {} + if filter then + for k, v in snapshot do + local filtered = filter(v) + if filtered then + table.insert(filtered_snapshot, v) + end end end + snapshot = filtered_snapshot end return function() From 9b98d4a7f2e79b7c2ac5052c20e62c33950f00ad Mon Sep 17 00:00:00 2001 From: IntegralsGetYouArea <109925156+IntegralsGetYouArea@users.noreply.github.com> Date: Mon, 28 Aug 2023 17:53:45 -0400 Subject: [PATCH 2/6] Update init.luau --- lib/init.luau | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/lib/init.luau b/lib/init.luau index f7d428c..4303354 100644 --- a/lib/init.luau +++ b/lib/init.luau @@ -95,18 +95,16 @@ function Net:__iter(filter: (k: number, v: any) -> (number?, any?)?, returnFilte local i = 0 -- Filters take in a key-value pair, the filter can remove this pair by not adding it to the filtered_snapshot array. - do - local filtered_snapshot = {} - if filter then - for k, v in snapshot do - local filtered = filter(v) - if filtered then - table.insert(filtered_snapshot, v) - end + local filteredSnapshot = {} + if filter then + for k, v in snapshot do + local filtered = filter(v) + if filtered then + table.insert(filteredSnapshot, v) end end - snapshot = filtered_snapshot end + snapshot = filteredSnapshot return function() i += 1 From a9d0d00f3690518354b741b3e7ddb59a76ba6da4 Mon Sep 17 00:00:00 2001 From: IntegralsGetYouArea <109925156+IntegralsGetYouArea@users.noreply.github.com> Date: Mon, 28 Aug 2023 18:13:44 -0400 Subject: [PATCH 3/6] Update init.luau --- lib/init.luau | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/init.luau b/lib/init.luau index 4303354..b527475 100644 --- a/lib/init.luau +++ b/lib/init.luau @@ -95,16 +95,16 @@ function Net:__iter(filter: (k: number, v: any) -> (number?, any?)?, returnFilte local i = 0 -- Filters take in a key-value pair, the filter can remove this pair by not adding it to the filtered_snapshot array. - local filteredSnapshot = {} if filter then + local filteredSnapshot = {} for k, v in snapshot do local filtered = filter(v) if filtered then table.insert(filteredSnapshot, v) end end + snapshot = filteredSnapshot end - snapshot = filteredSnapshot return function() i += 1 From 31fedea4744a3828dddff021b33f98a93a4572e6 Mon Sep 17 00:00:00 2001 From: IntegralsGetYouArea <109925156+IntegralsGetYouArea@users.noreply.github.com> Date: Mon, 28 Aug 2023 18:58:22 -0400 Subject: [PATCH 4/6] Update init.luau --- lib/init.luau | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/init.luau b/lib/init.luau index 81294e5..6d4aef8 100644 --- a/lib/init.luau +++ b/lib/init.luau @@ -103,6 +103,7 @@ function Net:__iter(filter: (k: number, v: any) -> (number?, any?)?, returnFilte table.insert(filteredSnapshot, v) end end + snapshot = filteredSnapshot end From 44cffda0b0e504dfe0eafdda45fe6e7b0f983d37 Mon Sep 17 00:00:00 2001 From: IntegralsGetYouArea <109925156+IntegralsGetYouArea@users.noreply.github.com> Date: Mon, 28 Aug 2023 18:58:42 -0400 Subject: [PATCH 5/6] Update init.luau --- lib/init.luau | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/init.luau b/lib/init.luau index 6d4aef8..db949a1 100644 --- a/lib/init.luau +++ b/lib/init.luau @@ -97,6 +97,7 @@ function Net:__iter(filter: (k: number, v: any) -> (number?, any?)?, returnFilte -- Filters take in a key-value pair, the filter can remove this pair by not adding it to the filtered_snapshot array. if filter then local filteredSnapshot = {} + for k, v in snapshot do local filtered = filter(v) if filtered then From 5fe344c32d88fb7f9fa194a908664f42a576d6c3 Mon Sep 17 00:00:00 2001 From: IntegralsGetYouArea <109925156+IntegralsGetYouArea@users.noreply.github.com> Date: Mon, 28 Aug 2023 19:03:59 -0400 Subject: [PATCH 6/6] Update init.luau --- lib/init.luau | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/init.luau b/lib/init.luau index db949a1..b8895a2 100644 --- a/lib/init.luau +++ b/lib/init.luau @@ -94,12 +94,13 @@ function Net:__iter(filter: (k: number, v: any) -> (number?, any?)?, returnFilte local snapshot = self._bridge:snapshot() local i = 0 - -- Filters take in a key-value pair, the filter can remove this pair by not adding it to the filtered_snapshot array. + -- When a filter is supplied, a new snapshot is created containing only filtered key-pair values if filter then local filteredSnapshot = {} for k, v in snapshot do local filtered = filter(v) + if filtered then table.insert(filteredSnapshot, v) end