Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ See `docs/benchmark.md` for full documentation.
`url_github_file`, `url_npm_package`, `url_logo`, `package_is_published`
(consumed by fuz_ui's `Library` and by build-time tooling)
- `result.ts` - Result type pattern
- `error.ts` - error utilities (`UnreachableError`, `unreachable` assertion)
- `error.ts` - error utilities (`UnreachableError`, `unreachable` assertion, `to_error_message` thrown-value → string)
- `args.ts` - CLI argument parsing with Zod validation

- `types.ts` - `Flavored` (loose nominal typing, no cast needed) and `Branded`
Expand Down Expand Up @@ -187,7 +187,7 @@ See `docs/benchmark.md` for full documentation.
- explicit file extensions in imports
- tab indentation, 100 character width
- no re-exports - import directly from the source module (e.g., import baseline
functions from `benchmark_baseline.js`, not from `benchmark.js`)
functions from `benchmark_baseline.ts`, not from `benchmark.ts`)
- no backwards compatibility preservation - breaking changes are acceptable

## Configuration
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ npm i -D @fuzdev/fuz_util
Import modules at their full paths:

```ts
import {type Result, unwrap} from '@fuzdev/fuz_util/result.js';
import {random_int} from '@fuzdev/fuz_util/random.js';
import {type Result, unwrap} from '@fuzdev/fuz_util/result.ts';
import {random_int} from '@fuzdev/fuz_util/random.ts';
```

`.ts` imports also work:
Expand Down
10 changes: 5 additions & 5 deletions docs/benchmark.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Comprehensive statistical analysis, percentile tracking, and rich output formatt
## Quick Start

```ts
import {Benchmark} from '@fuzdev/fuz_util/benchmark.js';
import {Benchmark} from '@fuzdev/fuz_util/benchmark.ts';

const bench = new Benchmark({
duration_ms: 5000, // Run each task for 5 seconds
Expand Down Expand Up @@ -641,7 +641,7 @@ import {
stats_confidence_interval,
stats_outliers_iqr,
stats_outliers_mad,
} from '@fuzdev/fuz_util/stats.js';
} from '@fuzdev/fuz_util/stats.ts';

// Calculate statistics on any numeric array
const values = [1.2, 1.5, 1.3, 1.4, 1.6, 10.0]; // 10.0 is an outlier
Expand Down Expand Up @@ -765,7 +765,7 @@ function benchmark_stats_compare(
Use `benchmark_stats_compare()` to determine if performance differences are statistically significant:

```ts
import {benchmark_stats_compare} from '@fuzdev/fuz_util/benchmark_stats.js';
import {benchmark_stats_compare} from '@fuzdev/fuz_util/benchmark_stats.ts';

const results = await bench.run();
const [result_a, result_b] = results;
Expand Down Expand Up @@ -805,13 +805,13 @@ interface BenchmarkComparison {
Save benchmark results to disk and compare against baselines for CI/CD regression detection:

```ts
import {Benchmark} from '@fuzdev/fuz_util/benchmark.js';
import {Benchmark} from '@fuzdev/fuz_util/benchmark.ts';
import {
benchmark_baseline_save,
benchmark_baseline_compare,
benchmark_baseline_format,
benchmark_baseline_format_json,
} from '@fuzdev/fuz_util/benchmark_baseline.js';
} from '@fuzdev/fuz_util/benchmark_baseline.ts';

const bench = new Benchmark();
bench.add('parse', () => parse(input));
Expand Down
16 changes: 8 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
"@fuzdev/fuz_code": "^0.46.1",
"@fuzdev/fuz_css": "^0.63.2",
"@fuzdev/fuz_ui": "^0.205.1",
"@fuzdev/gro": "^0.204.0",
"@fuzdev/gro": "^0.205.1",
"@fuzdev/mdz": "^0.1.0",
"@ryanatkn/eslint-config": "^0.12.1",
"@sveltejs/acorn-typescript": "^1.0.9",
Expand Down
2 changes: 1 addition & 1 deletion src/app.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ declare module 'virtual:fuz.css' {
export default css;
}
declare module 'virtual:pkg.json' {
import type {PkgJson} from '@fuzdev/fuz_util/pkg_json.js';
import type {PkgJson} from './lib/pkg_json.ts';
const pkg_json: PkgJson;
export default pkg_json;
}
6 changes: 3 additions & 3 deletions src/benchmarks/deep_equal.benchmark.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {Benchmark} from '$lib/benchmark.js';
import {deep_equal} from '$lib/deep_equal.js';
import type {BenchmarkGroup} from '$lib/benchmark_types.js';
import {Benchmark} from '../lib/benchmark.ts';
import {deep_equal} from '../lib/deep_equal.ts';
import type {BenchmarkGroup} from '../lib/benchmark_types.ts';

/* eslint-disable no-console, no-new-wrappers */

Expand Down
4 changes: 2 additions & 2 deletions src/benchmarks/deep_equal_comparison.benchmark.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {Benchmark} from '$lib/benchmark.js';
import {Benchmark} from '../lib/benchmark.ts';
import {dequal} from 'dequal';
import fastDeepEqual from 'fast-deep-equal';

import {deep_equal} from '$lib/deep_equal.js';
import {deep_equal} from '../lib/deep_equal.ts';

/* eslint-disable no-console */

Expand Down
8 changes: 4 additions & 4 deletions src/benchmarks/random.benchmark.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {Benchmark} from '$lib/benchmark.js';
import {create_random_alea} from '$lib/random_alea.js';
import {create_random_xoshiro} from '$lib/random_xoshiro.js';
import {Benchmark} from '../lib/benchmark.ts';
import {create_random_alea} from '../lib/random_alea.ts';
import {create_random_xoshiro} from '../lib/random_xoshiro.ts';

import {create_random_lcg, create_random_xorshift32} from '../test/random_test_helpers.js';
import {create_random_lcg, create_random_xorshift32} from '../test/random_test_helpers.ts';

/* eslint-disable no-console */

Expand Down
10 changes: 5 additions & 5 deletions src/benchmarks/random_quality.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@

/* eslint-disable no-console */

import {create_random_alea} from '$lib/random_alea.js';
import {create_random_xoshiro} from '$lib/random_xoshiro.js';
import {stats_mean, stats_variance} from '$lib/stats.js';
import {string_display_width, pad_width} from '$lib/string.js';
import {create_random_alea} from '../lib/random_alea.ts';
import {create_random_xoshiro} from '../lib/random_xoshiro.ts';
import {stats_mean, stats_variance} from '../lib/stats.ts';
import {string_display_width, pad_width} from '../lib/string.ts';

import {
type Prng,
create_random_lcg,
create_random_xorshift32,
} from '../test/random_test_helpers.js';
} from '../test/random_test_helpers.ts';

const deep = process.argv.includes('--deep');
const N = deep ? 10_000_000 : 1_000_000;
Expand Down
10 changes: 5 additions & 5 deletions src/benchmarks/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@
/* eslint-disable no-console */

import {readFile, writeFile} from 'node:fs/promises';
import {format_file} from '@fuzdev/gro/format_file.js';
import {format_file} from '@fuzdev/gro/format_file.ts';

import {Benchmark} from '$lib/benchmark.js';
import {Benchmark} from '../lib/benchmark.ts';
import {
benchmark_baseline_save,
benchmark_baseline_compare,
benchmark_baseline_format,
} from '$lib/benchmark_baseline.js';
import {slugify} from '$lib/path.js';
import {deep_equal} from '$lib/deep_equal.js';
} from '../lib/benchmark_baseline.ts';
import {slugify} from '../lib/path.ts';
import {deep_equal} from '../lib/deep_equal.ts';

const save_baseline = process.argv.includes('--save');
const BASELINE_PATH = 'src/benchmarks';
Expand Down
4 changes: 2 additions & 2 deletions src/benchmarks/slugify.benchmark.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {Benchmark} from '$lib/benchmark.js';
import {slugify} from '$lib/path.js';
import {Benchmark} from '../lib/benchmark.ts';
import {slugify} from '../lib/path.ts';

/* eslint-disable no-console */

Expand Down
2 changes: 1 addition & 1 deletion src/lib/array.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type {ArrayElement} from './types.js';
import type {ArrayElement} from './types.ts';

// TODO try to cange to readonly again, see if upstream errors are tolerably fixed
export const EMPTY_ARRAY: Array<any> = Object.freeze([]) as any;
Expand Down
12 changes: 6 additions & 6 deletions src/lib/benchmark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* @example
* ```ts
* import {Benchmark} from '@fuzdev/fuz_util/benchmark.js';
* import {Benchmark} from '@fuzdev/fuz_util/benchmark.ts';
*
* const bench = new Benchmark({
* duration_ms: 5000,
Expand All @@ -21,9 +21,9 @@
* @module
*/

import {is_promise, wait} from './async.js';
import {BenchmarkStats} from './benchmark_stats.js';
import {timer_default, time_unit_detect_best, time_format} from './time.js';
import {is_promise, wait} from './async.ts';
import {BenchmarkStats} from './benchmark_stats.ts';
import {timer_default, time_unit_detect_best, time_format} from './time.ts';
import {
benchmark_format_table,
benchmark_format_table_grouped,
Expand All @@ -32,13 +32,13 @@ import {
benchmark_format_json,
benchmark_format_number,
type BenchmarkFormatJsonOptions,
} from './benchmark_format.js';
} from './benchmark_format.ts';
import type {
BenchmarkConfig,
BenchmarkTask,
BenchmarkResult,
BenchmarkFormatTableOptions,
} from './benchmark_types.js';
} from './benchmark_types.ts';

// Default configuration values
const DEFAULT_DURATION_MS = 1000;
Expand Down
10 changes: 5 additions & 5 deletions src/lib/benchmark_baseline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ import {readFile, writeFile, mkdir, rm} from 'node:fs/promises';
import {join} from 'node:path';
import {z} from 'zod';

import {fs_exists} from './fs.js';
import {git_info_get} from './git.js';
import type {BenchmarkResult} from './benchmark_types.js';
import {fs_exists} from './fs.ts';
import {git_info_get} from './git.ts';
import type {BenchmarkResult} from './benchmark_types.ts';
import {
benchmark_stats_compare,
type BenchmarkComparison,
type BenchmarkStatsComparable,
} from './benchmark_stats.js';
import {stats_confidence_interval_from_summary, stats_cv} from './stats.js';
} from './benchmark_stats.ts';
import {stats_confidence_interval_from_summary, stats_cv} from './stats.ts';

// Version for forward compatibility - increment when schema changes
const BASELINE_VERSION = 3;
Expand Down
8 changes: 4 additions & 4 deletions src/lib/benchmark_format.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type {BenchmarkResult, BenchmarkGroup} from './benchmark_types.js';
import {time_unit_detect_best, time_format, TIME_UNIT_DISPLAY} from './time.js';
import {string_display_width, pad_width} from './string.js';
import {format_number} from './maths.js';
import type {BenchmarkResult, BenchmarkGroup} from './benchmark_types.ts';
import {time_unit_detect_best, time_format, TIME_UNIT_DISPLAY} from './time.ts';
import {string_display_width, pad_width} from './string.ts';
import {format_number} from './maths.ts';

/**
* Format results as an ASCII table with percentiles, min/max, and relative performance.
Expand Down
4 changes: 2 additions & 2 deletions src/lib/benchmark_stats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @module
*/

import {TIME_NS_PER_SEC, time_format_adaptive} from './time.js';
import {TIME_NS_PER_SEC, time_format_adaptive} from './time.ts';
import {
stats_mean,
stats_median,
Expand All @@ -18,7 +18,7 @@ import {
stats_outliers_mad,
stats_welch_t_test,
stats_t_distribution_p_value,
} from './stats.js';
} from './stats.ts';

/**
* Minimal stats interface for comparison.
Expand Down
4 changes: 2 additions & 2 deletions src/lib/benchmark_types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type {BenchmarkStats} from './benchmark_stats.js';
import type {Timer} from './time.js';
import type {BenchmarkStats} from './benchmark_stats.ts';
import type {Timer} from './time.ts';

/**
* Configuration options for a benchmark suite.
Expand Down
4 changes: 2 additions & 2 deletions src/lib/colors.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type {Flavored} from './types.js';
import {round} from './maths.js';
import type {Flavored} from './types.ts';
import {round} from './maths.ts';

// TODO for high-performance usecases, we may want to add variants for any that return a new array to reuse a single array
// I've run into cases where this is a massive perceptible UX difference
Expand Down
4 changes: 2 additions & 2 deletions src/lib/dag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
* @module
*/

import {AsyncSemaphore, create_deferred, type Deferred} from './async.js';
import {topological_sort, type Sortable} from './sort.js';
import {AsyncSemaphore, create_deferred, type Deferred} from './async.ts';
import {topological_sort, type Sortable} from './sort.ts';

/**
* Minimum shape for a DAG node.
Expand Down
2 changes: 1 addition & 1 deletion src/lib/diff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @module
*/

import {string_is_binary} from './string.js';
import {string_is_binary} from './string.ts';

/** Line diff result */
export interface DiffLine {
Expand Down
6 changes: 3 additions & 3 deletions src/lib/fact_hash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
import {hash_stream} from '@fuzdev/blake3_wasm';
import {z} from 'zod';

import {hash_blake3} from './hash_blake3.js';
import {to_hex} from './hex.js';
import type {Json} from './json.js';
import {hash_blake3} from './hash_blake3.ts';
import {to_hex} from './hex.ts';
import type {Json} from './json.ts';

/** Algorithm prefix on every fact hash. The colon is the separator. */
export const FACT_HASH_PREFIX = 'blake3:';
Expand Down
2 changes: 1 addition & 1 deletion src/lib/fact_store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* @module
*/

import type {FactHash} from './fact_hash.js';
import type {FactHash} from './fact_hash.ts';

/**
* Optional metadata + ref declarations on a `put` / `put_ref` call.
Expand Down
10 changes: 5 additions & 5 deletions src/lib/fetch.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {z} from 'zod';

import type {Flavored} from './types.js';
import type {Logger} from './log.js';
import {EMPTY_OBJECT} from './object.js';
import type {Result} from './result.js';
import {json_stringify_deterministic} from './json.js';
import type {Flavored} from './types.ts';
import type {Logger} from './log.ts';
import {EMPTY_OBJECT} from './object.ts';
import type {Result} from './result.ts';
import {json_stringify_deterministic} from './json.ts';

const DEFAULT_GITHUB_API_ACCEPT_HEADER = 'application/vnd.github+json';
const DEFAULT_GITHUB_API_VERSION_HEADER = '2022-11-28';
Expand Down
Loading