mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-04-24 14:49:58 -07:00
website: snapshot
This commit is contained in:
@@ -19,6 +19,17 @@ import { colors } from "../chart/colors.js";
|
||||
|
||||
/** @typedef {ReturnType<typeof createContext>} PartialContext */
|
||||
|
||||
/**
|
||||
* @template {(colors: Colors, ...args: any[]) => any} T
|
||||
* @param {T} fn
|
||||
* @returns {OmitFirstArg<T>}
|
||||
*/
|
||||
const bind = (fn) =>
|
||||
/** @type {any} */ (
|
||||
// @ts-ignore
|
||||
(...args) => fn(colors, ...args)
|
||||
);
|
||||
|
||||
/**
|
||||
* Create a context object with all dependencies for building partial options
|
||||
* @param {Object} args
|
||||
@@ -28,43 +39,15 @@ export function createContext({ brk }) {
|
||||
return {
|
||||
colors,
|
||||
brk,
|
||||
|
||||
/** @type {OmitFirstArg<typeof fromSizePattern>} */
|
||||
fromSizePattern: (pattern, unit, title) =>
|
||||
fromSizePattern(colors, pattern, unit, title),
|
||||
/** @type {OmitFirstArg<typeof fromFullnessPattern>} */
|
||||
fromFullnessPattern: (pattern, unit, title) =>
|
||||
fromFullnessPattern(colors, pattern, unit, title),
|
||||
/** @type {OmitFirstArg<typeof fromDollarsPattern>} */
|
||||
fromDollarsPattern: (pattern, unit, title) =>
|
||||
fromDollarsPattern(colors, pattern, unit, title),
|
||||
/** @type {OmitFirstArg<typeof fromFeeRatePattern>} */
|
||||
fromFeeRatePattern: (pattern, unit, title) =>
|
||||
fromFeeRatePattern(colors, pattern, unit, title),
|
||||
/** @type {OmitFirstArg<typeof fromCoinbasePattern>} */
|
||||
fromCoinbasePattern: (pattern, title) =>
|
||||
fromCoinbasePattern(colors, pattern, title),
|
||||
/** @type {OmitFirstArg<typeof fromValuePattern>} */
|
||||
fromValuePattern: (pattern, title, sumColor, cumulativeColor) =>
|
||||
fromValuePattern(colors, pattern, title, sumColor, cumulativeColor),
|
||||
/** @type {OmitFirstArg<typeof fromBitcoinPatternWithUnit>} */
|
||||
fromBitcoinPatternWithUnit: (pattern, unit, title, sumColor, cumulativeColor) =>
|
||||
fromBitcoinPatternWithUnit(colors, pattern, unit, title, sumColor, cumulativeColor),
|
||||
/** @type {OmitFirstArg<typeof fromBlockCountWithUnit>} */
|
||||
fromBlockCountWithUnit: (pattern, unit, title, sumColor, cumulativeColor) =>
|
||||
fromBlockCountWithUnit(
|
||||
colors,
|
||||
pattern,
|
||||
unit,
|
||||
title,
|
||||
sumColor,
|
||||
cumulativeColor,
|
||||
),
|
||||
/** @type {OmitFirstArg<typeof fromIntervalPattern>} */
|
||||
fromIntervalPattern: (pattern, unit, title, color) =>
|
||||
fromIntervalPattern(colors, pattern, unit, title, color),
|
||||
/** @type {fromSupplyPattern} */
|
||||
fromSupplyPattern: (pattern, title, color) =>
|
||||
fromSupplyPattern(pattern, title, color),
|
||||
fromSizePattern: bind(fromSizePattern),
|
||||
fromFullnessPattern: bind(fromFullnessPattern),
|
||||
fromDollarsPattern: bind(fromDollarsPattern),
|
||||
fromFeeRatePattern: bind(fromFeeRatePattern),
|
||||
fromCoinbasePattern: bind(fromCoinbasePattern),
|
||||
fromValuePattern: bind(fromValuePattern),
|
||||
fromBitcoinPatternWithUnit: bind(fromBitcoinPatternWithUnit),
|
||||
fromBlockCountWithUnit: bind(fromBlockCountWithUnit),
|
||||
fromIntervalPattern: bind(fromIntervalPattern),
|
||||
fromSupplyPattern,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user