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,59 @@
import { bench, describe } from 'vitest';
import { STANDARD } from '../helpers/bench-options.js';
import {
Option,
O,
TmMaybe,
} from '../helpers/imports.js';
// ---------------------------------------------------------------------------
// Option.from — non-nullish value
// ---------------------------------------------------------------------------
describe('Option.from — non-nullish value', () => {
bench('native-monad', () => { Option.from(42); }, STANDARD);
bench('fp-ts', () => { O.fromNullable(42); }, STANDARD);
bench('true-myth', () => { TmMaybe.of(42); }, STANDARD);
});
// ---------------------------------------------------------------------------
// Option.from — null value
// ---------------------------------------------------------------------------
describe('Option.from — null', () => {
bench('native-monad', () => { Option.from(null); }, STANDARD);
bench('fp-ts', () => { O.fromNullable(null); }, STANDARD);
bench('true-myth', () => { TmMaybe.of(null); }, STANDARD);
});
// ---------------------------------------------------------------------------
// Option.from — undefined value
// ---------------------------------------------------------------------------
describe('Option.from — undefined', () => {
bench('native-monad', () => { Option.from(undefined); }, STANDARD);
bench('fp-ts', () => { O.fromNullable(undefined); }, STANDARD);
bench('true-myth', () => { TmMaybe.of(undefined); }, STANDARD);
});
// ---------------------------------------------------------------------------
// Option.from — function that returns value
// ---------------------------------------------------------------------------
describe('Option.from — function returning value', () => {
const fn = () => 42;
bench('native-monad', () => { Option.from(fn); }, STANDARD);
// fp-ts: no function overload for fromNullable
// true-myth: no function overload for of
});
// ---------------------------------------------------------------------------
// Option.from — function that returns null
// ---------------------------------------------------------------------------
describe('Option.from — function returning null', () => {
const fn = () => null;
bench('native-monad', () => { Option.from(fn); }, STANDARD);
});