global: snapshot

This commit is contained in:
nym21
2026-04-08 01:38:03 +02:00
parent 0c14dfe924
commit 4c4c6fc840
79 changed files with 2040 additions and 1408 deletions

View File

@@ -0,0 +1,32 @@
/**
* @template V
* @param {number} [maxSize]
*/
export function createMapCache(maxSize = 100) {
/** @type {Map<string, V>} */
const map = new Map();
return {
/** @param {string} key @returns {V | undefined} */
get(key) {
return map.get(key);
},
/** @param {string} key @returns {boolean} */
has(key) {
return map.has(key);
},
/** @param {string} key @param {V} value */
set(key, value) {
if (map.size >= maxSize && !map.has(key)) {
const first = map.keys().next().value;
if (first !== undefined) map.delete(first);
}
map.set(key, value);
},
};
}
/**
* @template V
* @typedef {{ get: (key: string) => V | undefined, has: (key: string) => boolean, set: (key: string, value: V) => void }} MapCache
*/

View File

@@ -10,6 +10,7 @@ import { capture } from "./capture.js";
import { colors } from "../colors.js";
import { createRadios, createSelect, getElementById } from "../dom.js";
import { createPersistedValue } from "../persisted.js";
import { createMapCache } from "../cache.js";
import { onChange as onThemeChange } from "../theme.js";
import { throttle, debounce } from "../timing.js";
import { serdeBool, INDEX_FROM_LABEL } from "../serde.js";
@@ -190,9 +191,7 @@ export function createChart({ parent, brk, fitContent }) {
},
};
// Memory cache for instant index switching
/** @type {Map<string, AnySeriesData>} */
const cache = new Map();
const cache = createMapCache(Infinity);
// Range state: localStorage stores all ranges per-index, URL stores current range only
/** @typedef {{ from: number, to: number }} Range */

View File

@@ -0,0 +1,8 @@
import { BrkClient } from "../modules/brk-client/index.js";
// const brk = new BrkClient("https://bitview.space");
const brk = new BrkClient("/");
console.log(`VERSION = ${brk.VERSION}`);
export { brk };

View File

@@ -40,7 +40,7 @@ export const Unit = /** @type {const} */ ({
epoch: { id: "epoch", name: "Epoch" },
// Fees
feeRate: { id: "feerate", name: "Sats/vByte" },
feeRate: { id: "feerate", name: "Sat/vByte" },
// Rates
perSec: { id: "per-sec", name: "Per Second" },