mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-07-18 06:28:11 -07:00
global: BIG snapshot
This commit is contained in:
@@ -2,17 +2,17 @@
|
||||
|
||||
import { localhost } from "../utils/env.js";
|
||||
|
||||
/** @type {Set<MetricAccessor<any>> | null} */
|
||||
/** @type {Set<AnyMetricPattern> | null} */
|
||||
export const unused = localhost ? new Set() : null;
|
||||
|
||||
/**
|
||||
* Walk and collect MetricAccessors
|
||||
* Walk and collect AnyMetricPatterns
|
||||
* @param {TreeNode | null | undefined} node
|
||||
* @param {Set<MetricAccessor<unknown>>} set
|
||||
* @param {Set<AnyMetricPattern>} set
|
||||
*/
|
||||
function walk(node, set) {
|
||||
if (node && "by" in node) {
|
||||
set.add(/** @type {MetricAccessor<unknown>} */ (node));
|
||||
set.add(/** @type {AnyMetricPattern} */ (node));
|
||||
} else if (node && typeof node === "object") {
|
||||
for (const value of Object.values(node)) {
|
||||
walk(/** @type {TreeNode | null | undefined} */ (value), set);
|
||||
@@ -21,7 +21,7 @@ function walk(node, set) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Collect all MetricAccessors from tree
|
||||
* Collect all AnyMetricPatterns from tree
|
||||
* @param {TreeNode} tree
|
||||
*/
|
||||
export function collect(tree) {
|
||||
@@ -30,7 +30,7 @@ export function collect(tree) {
|
||||
|
||||
/**
|
||||
* Mark a metric as used
|
||||
* @param {MetricAccessor<any>} metric
|
||||
* @param {AnyMetricPattern} metric
|
||||
*/
|
||||
export function markUsed(metric) {
|
||||
unused?.delete(metric);
|
||||
|
||||
Reference in New Issue
Block a user