mirror of
https://github.com/kucherenko/jscpd.git
synced 2026-09-19 08:11:03 +08:00
ad7fc6ebdc
Extract YAML front matter and fenced code blocks from .md files and tokenize each segment with its resolved sub-language format (yaml, typescript, python, javascript, etc.), enabling jscpd to detect duplicates across languages embedded in Markdown documents. - Implement tokenizeMarkdown() with three-tier resolveFormat() lookup - Split markdown grammar into markdown-format.ts to break circular dep - Dispatch markdown format through createTokenMapBasedOnCode() - Separate .txt into its own format (removed from markdown.exts) - Export EXT_TO_FORMAT from formats.ts for sub-language resolution - Add 25-test suite covering all acceptance criteria (271 total) - Add fixtures/markdown/file3.md + file4.md for integration testing
2.3 KiB
2.3 KiB
title, description, version, author, tags, config
| title | description | version | author | tags | config | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| API Client Configuration Guide | A comprehensive guide to configuring and using the HTTP API client | 1.0.0 |
|
|
|
API Client Configuration Reference
This reference covers the configuration options and usage of the HTTP API client library.
TypeScript Client
The following TypeScript interface and function demonstrate the core client pattern:
interface ApiConfig {
baseUrl: string;
timeout: number;
retries: number;
headers: Record<string, string>;
}
async function fetchData(config: ApiConfig, path: string): Promise<Response> {
const url = `${config.baseUrl}${path}`;
const response = await fetch(url, {
headers: config.headers,
signal: AbortSignal.timeout(config.timeout),
});
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
return response;
}
function buildConfig(overrides: Partial<ApiConfig> = {}): ApiConfig {
return {
baseUrl: "https://api.example.com",
timeout: 30_000,
retries: 3,
headers: {
"accept": "application/json",
"content-type": "application/json",
},
...overrides,
};
}
Data Processing
Use the Python utility to compute statistics on response payloads:
def calculate_statistics(data: list[float]) -> dict:
n = len(data)
mean = sum(data) / n
variance = sum((x - mean) ** 2 for x in data) / n
std_dev = variance ** 0.5
sorted_data = sorted(data)
median = (
sorted_data[n // 2]
if n % 2 != 0
else (sorted_data[n // 2 - 1] + sorted_data[n // 2]) / 2
)
return {
"count": n,
"mean": mean,
"variance": variance,
"std_dev": std_dev,
"median": median,
"min": sorted_data[0],
"max": sorted_data[-1],
}
Notes
- All endpoints require bearer token authentication.
- Retry logic uses exponential backoff with a maximum of 3 attempts.
- Timeout applies per attempt, not across the total retry budget.