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,65 @@
import { bench, describe } from 'vitest';
import { STANDARD } from '../helpers/bench-options.js';
import {
okSome,
okNone,
errNone,
TsOk,
TsErr,
TsSome,
TsNone,
OxOk,
OxErr,
OxSome,
OxNone,
E,
O,
TmResult,
TmMaybe,
} from '../helpers/imports.js';
// ---------------------------------------------------------------------------
// OkSome — vs nested Result<Option<T>, E>
// ---------------------------------------------------------------------------
describe('Query construction — OkSome (primitive)', () => {
bench('native-monad', () => { okSome(42); }, STANDARD);
bench('ts-results-es (nested)', () => { TsOk(TsSome(42)); }, STANDARD);
bench('oxide.ts (nested)', () => { OxOk(OxSome(42)); }, STANDARD);
bench('fp-ts (nested)', () => { E.right(O.some(42)); }, STANDARD);
bench('true-myth (nested)', () => { TmResult.ok(TmMaybe.just(42)); }, STANDARD);
});
describe('Query construction — OkSome (object payload)', () => {
const value = { id: 1, name: 'Alice' };
bench('native-monad', () => { okSome(value); }, STANDARD);
bench('ts-results-es (nested)', () => { TsOk(TsSome(value)); }, STANDARD);
bench('oxide.ts (nested)', () => { OxOk(OxSome(value)); }, STANDARD);
bench('fp-ts (nested)', () => { E.right(O.some(value)); }, STANDARD);
bench('true-myth (nested)', () => { TmResult.ok(TmMaybe.just(value)); }, STANDARD);
});
// ---------------------------------------------------------------------------
// OkNone — vs nested Result<Option<T>, E>
// ---------------------------------------------------------------------------
describe('Query construction — OkNone (singleton)', () => {
bench('native-monad', () => { okNone(); }, STANDARD);
bench('ts-results-es (nested)', () => { TsOk(TsNone); }, STANDARD);
bench('oxide.ts (nested)', () => { OxOk(OxNone); }, STANDARD);
bench('fp-ts (nested)', () => { E.right(O.none); }, STANDARD);
bench('true-myth (nested)', () => { TmResult.ok(TmMaybe.nothing()); }, STANDARD);
});
// ---------------------------------------------------------------------------
// ErrNone — vs nested Err
// ---------------------------------------------------------------------------
describe('Query construction — ErrNone', () => {
bench('native-monad', () => { errNone('fail'); }, STANDARD);
bench('ts-results-es (nested)', () => { TsErr('fail'); }, STANDARD);
bench('oxide.ts (nested)', () => { OxErr('fail'); }, STANDARD);
bench('fp-ts (nested)', () => { E.left('fail'); }, STANDARD);
bench('true-myth (nested)', () => { TmResult.err('fail'); }, STANDARD);
});