mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-07-22 00:18:10 -07:00
global: replace most bps with ppm
This commit is contained in:
+759
-761
File diff suppressed because it is too large
Load Diff
@@ -3,9 +3,10 @@
|
||||
"url": "https://github.com/bitcoinresearchkit/brk/issues"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "node tests/basic.js && node tests/tree.js",
|
||||
"test": "node tests/hash_prefix.js && node tests/basic.js && node tests/metric_data.js && node tests/tree.js",
|
||||
"test:basic": "node tests/basic.js",
|
||||
"test:hash-prefix": "node tests/hash_prefix.js",
|
||||
"test:metric-data": "node tests/metric_data.js",
|
||||
"test:tree": "node tests/tree.js"
|
||||
},
|
||||
"description": "Bitcoin on-chain analytics client — thousands of metrics, block explorer, and address index",
|
||||
|
||||
@@ -6,50 +6,50 @@ console.log("Testing idiomatic API...\n");
|
||||
|
||||
// Test getter access (property)
|
||||
console.log("1. Getter access (.by.dateindex):");
|
||||
const all = await client.series.prices.split.close.usd.by.day1;
|
||||
const all = await client.series.price.split.close.usd.by.day1;
|
||||
console.log(` Got: ${all.data.length} items\n`);
|
||||
|
||||
// Test dynamic access (bracket notation)
|
||||
console.log("2. Dynamic access (.by['dateindex']):");
|
||||
const allDynamic = await client.series.prices.split.close.usd.by.day1;
|
||||
const allDynamic = await client.series.price.split.close.usd.by.day1;
|
||||
console.log(` Got: ${allDynamic.data.length} items\n`);
|
||||
|
||||
// Test fetch all (explicit .fetch())
|
||||
console.log("3. Explicit .fetch():");
|
||||
const allExplicit = await client.series.prices.split.close.usd.by.day1.fetch();
|
||||
const allExplicit = await client.series.price.split.close.usd.by.day1.fetch();
|
||||
console.log(` Got: ${allExplicit.data.length} items\n`);
|
||||
|
||||
// Test first(n)
|
||||
console.log("4. First 5 items (.first(5)):");
|
||||
const first5 = await client.series.prices.split.close.usd.by.day1.first(5);
|
||||
const first5 = await client.series.price.split.close.usd.by.day1.first(5);
|
||||
console.log(
|
||||
` Start: ${first5.start}, End: ${first5.end}, Got: ${first5.data.length} items\n`,
|
||||
);
|
||||
|
||||
// Test last(n)
|
||||
console.log("5. Last 5 items (.last(5)):");
|
||||
const last5 = await client.series.prices.split.close.usd.by.day1.last(5);
|
||||
const last5 = await client.series.price.split.close.usd.by.day1.last(5);
|
||||
console.log(
|
||||
` Start: ${last5.start}, End: ${last5.end}, Got: ${last5.data.length} items\n`,
|
||||
);
|
||||
|
||||
// Test slice(start, end)
|
||||
console.log("6. Slice 10-20 (.slice(10, 20)):");
|
||||
const sliced = await client.series.prices.split.close.usd.by.day1.slice(10, 20);
|
||||
const sliced = await client.series.price.split.close.usd.by.day1.slice(10, 20);
|
||||
console.log(
|
||||
` Start: ${sliced.start}, End: ${sliced.end}, Got: ${sliced.data.length} items\n`,
|
||||
);
|
||||
|
||||
// Test get(index) - single item
|
||||
console.log("7. Single item (.get(100)):");
|
||||
const single = await client.series.prices.split.close.usd.by.day1.get(100);
|
||||
const single = await client.series.price.split.close.usd.by.day1.get(100);
|
||||
console.log(
|
||||
` Start: ${single.start}, End: ${single.end}, Got: ${single.data.length} item(s)\n`,
|
||||
);
|
||||
|
||||
// Test skip(n).take(m) chaining
|
||||
console.log("8. Skip and take (.skip(100).take(10)):");
|
||||
const skipTake = await client.series.prices.split.close.usd.by.day1
|
||||
const skipTake = await client.series.price.split.close.usd.by.day1
|
||||
.skip(100)
|
||||
.take(10);
|
||||
console.log(
|
||||
@@ -58,7 +58,7 @@ console.log(
|
||||
|
||||
// Test fetchCsv
|
||||
console.log("9. Fetch as CSV (.last(3).fetchCsv()):");
|
||||
const csv = await client.series.prices.split.close.usd.by.day1
|
||||
const csv = await client.series.price.split.close.usd.by.day1
|
||||
.last(3)
|
||||
.fetchCsv();
|
||||
console.log(` CSV preview: ${csv.substring(0, 100)}...\n`);
|
||||
|
||||
@@ -11,7 +11,7 @@ console.log("Testing MetricData helpers...\n");
|
||||
|
||||
// Fetch a date-based metric
|
||||
console.log("1. Fetching price data (day1):");
|
||||
const price = await client.series.prices.split.close.usd.by.day1.first(5);
|
||||
const price = await client.series.price.split.close.usd.by.day1.first(5);
|
||||
console.log(` Start: ${price.start}, End: ${price.end}`);
|
||||
|
||||
// Test isDateBased
|
||||
@@ -95,7 +95,7 @@ if (count !== 5) throw new Error("Expected 5 iterations");
|
||||
|
||||
// Test with non-date-based index (height)
|
||||
console.log("\n11. Testing height-based metric:");
|
||||
const heightMetric = await client.series.prices.spot.usd.by.height.last(3);
|
||||
const heightMetric = await client.series.price.spot.usd.by.height.last(3);
|
||||
console.log(` Start: ${heightMetric.start}, End: ${heightMetric.end}`);
|
||||
if (heightMetric.isDateBased)
|
||||
throw new Error("height should not be date-based");
|
||||
@@ -133,7 +133,7 @@ console.log(` Iterated ${heightCount} items`);
|
||||
// Test different date indexes
|
||||
console.log("\n13. Testing month1:");
|
||||
const monthMetric =
|
||||
await client.series.prices.split.close.usd.by.month1.first(3);
|
||||
await client.series.price.split.close.usd.by.month1.first(3);
|
||||
const monthDates = monthMetric.dates();
|
||||
console.log(` First month: ${monthDates[0].toISOString()}`);
|
||||
// MonthIndex 0 = Jan 1, 2009
|
||||
@@ -236,7 +236,7 @@ console.log(` Roundtrip day1 100: ${testDate.toISOString()} -> ${roundtrip}`);
|
||||
|
||||
// Test slice with Date
|
||||
console.log("\n16. Testing slice with Date:");
|
||||
const dateSlice = await client.series.prices.split.close.usd.by.day1
|
||||
const dateSlice = await client.series.price.split.close.usd.by.day1
|
||||
.slice(new Date(Date.UTC(2020, 0, 1)), new Date(Date.UTC(2020, 0, 4)))
|
||||
.fetch();
|
||||
console.log(
|
||||
|
||||
@@ -42,6 +42,7 @@ function getAllMetrics(obj, path = "") {
|
||||
// Check if this is a metric pattern using the indexes() method
|
||||
if (isMetricPattern(attr)) {
|
||||
metrics.push({ path: currentPath, metric: attr });
|
||||
continue;
|
||||
}
|
||||
|
||||
// Recurse into nested tree nodes
|
||||
@@ -90,7 +91,7 @@ async function testAllEndpoints() {
|
||||
console.log(
|
||||
`FAIL: ${fullPath} -> ${e instanceof Error ? e.message : e}`,
|
||||
);
|
||||
return;
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user