initial commit

This commit is contained in:
2026-03-30 08:34:35 +02:00
commit 49d8ea67ba
103 changed files with 22387 additions and 0 deletions

View File

@@ -0,0 +1,39 @@
import { bench, describe } from 'vitest';
import { STANDARD } from '../helpers/bench-options.js';
import {
Result,
ntFromThrowable,
E,
TmResult,
} from '../helpers/imports.js';
// ---------------------------------------------------------------------------
// Result.from — success (no throw)
// ---------------------------------------------------------------------------
describe('Result.from — success (no throw)', () => {
const fn = () => 42;
bench('native-monad', () => { Result.from(fn); }, STANDARD);
bench('neverthrow', () => { ntFromThrowable(fn)(); }, STANDARD);
bench('fp-ts', () => { E.tryCatch(fn, () => 'error'); }, STANDARD);
bench('true-myth', () => { TmResult.tryOr('error', fn); }, STANDARD);
// ts-results-es: no from/tryCatch
// oxide.ts: no from/tryCatch
});
// ---------------------------------------------------------------------------
// Result.from — failure (throws)
// ---------------------------------------------------------------------------
describe('Result.from — failure (throws)', () => {
const thrower = () => {
throw new Error('fail');
};
const mapErr = () => 'error' as const;
bench('native-monad', () => { Result.from(thrower, mapErr); }, STANDARD);
bench('neverthrow', () => { ntFromThrowable(thrower, mapErr)(); }, STANDARD);
bench('fp-ts', () => { E.tryCatch(thrower, mapErr); }, STANDARD);
bench('true-myth', () => { TmResult.tryOr('error', thrower); }, STANDARD);
});