mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-04-24 06:39:58 -07:00
website: snapshot
This commit is contained in:
@@ -18,3 +18,20 @@ export function range(start, end) {
|
||||
export function randomFromArray(array) {
|
||||
return array[Math.floor(Math.random() * array.length)];
|
||||
}
|
||||
|
||||
/**
|
||||
* Typed Object.entries that preserves key types
|
||||
* @template {Record<string, any>} T
|
||||
* @param {T} obj
|
||||
* @returns {[keyof T & string, T[keyof T & string]][]}
|
||||
*/
|
||||
export const entries = (obj) => /** @type {[keyof T & string, T[keyof T & string]][]} */ (Object.entries(obj));
|
||||
|
||||
/**
|
||||
* Type-safe includes that narrows the value type
|
||||
* @template T
|
||||
* @param {readonly T[]} arr
|
||||
* @param {unknown} value
|
||||
* @returns {value is T}
|
||||
*/
|
||||
export const includes = (arr, value) => arr.includes(/** @type {T} */ (value));
|
||||
|
||||
@@ -9,11 +9,6 @@ export const Unit = /** @type {const} */ ({
|
||||
btc: { id: "btc", name: "Bitcoin" },
|
||||
usd: { id: "usd", name: "US Dollars" },
|
||||
|
||||
// Cumulative value units (running totals)
|
||||
satsCumulative: { id: "sats-total", name: "Satoshis (Total)" },
|
||||
btcCumulative: { id: "btc-total", name: "Bitcoin (Total)" },
|
||||
usdCumulative: { id: "usd-total", name: "US Dollars (Total)" },
|
||||
|
||||
// Ratios & percentages
|
||||
percentage: { id: "percentage", name: "Percentage" },
|
||||
cagr: { id: "cagr", name: "CAGR (%/year)" },
|
||||
@@ -36,15 +31,12 @@ export const Unit = /** @type {const} */ ({
|
||||
|
||||
// Counts
|
||||
count: { id: "count", name: "Count" },
|
||||
countCumulative: { id: "count-total", name: "Count (Total)" },
|
||||
blocks: { id: "blocks", name: "Blocks" },
|
||||
|
||||
// Size
|
||||
bytes: { id: "bytes", name: "Bytes" },
|
||||
bytesCumulative: { id: "bytes-total", name: "Bytes (Total)" },
|
||||
vb: { id: "vb", name: "Virtual Bytes" },
|
||||
wu: { id: "wu", name: "Weight Units" },
|
||||
wuCumulative: { id: "wu-total", name: "Weight Units (Total)" },
|
||||
|
||||
// Mining
|
||||
hashRate: { id: "hashrate", name: "Hash Rate" },
|
||||
|
||||
Reference in New Issue
Block a user